@vertaaux/cli 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/README.md +345 -0
  2. package/dist/auth/ci-token.d.ts +49 -0
  3. package/dist/auth/ci-token.d.ts.map +1 -0
  4. package/dist/auth/ci-token.js +83 -0
  5. package/dist/auth/device-flow.d.ts +66 -0
  6. package/dist/auth/device-flow.d.ts.map +1 -0
  7. package/dist/auth/device-flow.js +156 -0
  8. package/dist/auth/token-store.d.ts +53 -0
  9. package/dist/auth/token-store.d.ts.map +1 -0
  10. package/dist/auth/token-store.js +78 -0
  11. package/dist/baseline/diff.d.ts +57 -0
  12. package/dist/baseline/diff.d.ts.map +1 -0
  13. package/dist/baseline/diff.js +152 -0
  14. package/dist/baseline/hash.d.ts +54 -0
  15. package/dist/baseline/hash.d.ts.map +1 -0
  16. package/dist/baseline/hash.js +66 -0
  17. package/dist/baseline/manager.d.ts +89 -0
  18. package/dist/baseline/manager.d.ts.map +1 -0
  19. package/dist/baseline/manager.js +157 -0
  20. package/dist/cache/index.d.ts +8 -0
  21. package/dist/cache/index.d.ts.map +1 -0
  22. package/dist/cache/index.js +7 -0
  23. package/dist/cache/route-cache.d.ts +119 -0
  24. package/dist/cache/route-cache.d.ts.map +1 -0
  25. package/dist/cache/route-cache.js +213 -0
  26. package/dist/ci/changed-routes.d.ts +95 -0
  27. package/dist/ci/changed-routes.d.ts.map +1 -0
  28. package/dist/ci/changed-routes.js +304 -0
  29. package/dist/ci/github-api.d.ts +68 -0
  30. package/dist/ci/github-api.d.ts.map +1 -0
  31. package/dist/ci/github-api.js +138 -0
  32. package/dist/ci/gitlab-api.d.ts +75 -0
  33. package/dist/ci/gitlab-api.d.ts.map +1 -0
  34. package/dist/ci/gitlab-api.js +180 -0
  35. package/dist/ci/index.d.ts +6 -0
  36. package/dist/ci/index.d.ts.map +1 -0
  37. package/dist/ci/index.js +4 -0
  38. package/dist/commands/audit.d.ts +58 -0
  39. package/dist/commands/audit.d.ts.map +1 -0
  40. package/dist/commands/audit.js +862 -0
  41. package/dist/commands/baseline.d.ts +22 -0
  42. package/dist/commands/baseline.d.ts.map +1 -0
  43. package/dist/commands/baseline.js +210 -0
  44. package/dist/commands/comment.d.ts +14 -0
  45. package/dist/commands/comment.d.ts.map +1 -0
  46. package/dist/commands/comment.js +363 -0
  47. package/dist/commands/diff.d.ts +24 -0
  48. package/dist/commands/diff.d.ts.map +1 -0
  49. package/dist/commands/diff.js +196 -0
  50. package/dist/commands/doctor.d.ts +58 -0
  51. package/dist/commands/doctor.d.ts.map +1 -0
  52. package/dist/commands/doctor.js +338 -0
  53. package/dist/commands/download.d.ts +12 -0
  54. package/dist/commands/download.d.ts.map +1 -0
  55. package/dist/commands/download.js +183 -0
  56. package/dist/commands/explain.d.ts +62 -0
  57. package/dist/commands/explain.d.ts.map +1 -0
  58. package/dist/commands/explain.js +302 -0
  59. package/dist/commands/init.d.ts +12 -0
  60. package/dist/commands/init.d.ts.map +1 -0
  61. package/dist/commands/init.js +212 -0
  62. package/dist/commands/login.d.ts +14 -0
  63. package/dist/commands/login.d.ts.map +1 -0
  64. package/dist/commands/login.js +222 -0
  65. package/dist/commands/policy.d.ts +13 -0
  66. package/dist/commands/policy.d.ts.map +1 -0
  67. package/dist/commands/policy.js +347 -0
  68. package/dist/commands/upload.d.ts +12 -0
  69. package/dist/commands/upload.d.ts.map +1 -0
  70. package/dist/commands/upload.js +158 -0
  71. package/dist/config/defaults.d.ts +21 -0
  72. package/dist/config/defaults.d.ts.map +1 -0
  73. package/dist/config/defaults.js +49 -0
  74. package/dist/config/loader.d.ts +66 -0
  75. package/dist/config/loader.d.ts.map +1 -0
  76. package/dist/config/loader.js +167 -0
  77. package/dist/config/schema.d.ts +55 -0
  78. package/dist/config/schema.d.ts.map +1 -0
  79. package/dist/config/schema.js +6 -0
  80. package/dist/index.d.ts +9 -0
  81. package/dist/index.d.ts.map +1 -0
  82. package/dist/index.js +1090 -0
  83. package/dist/interactive/fix-wizard.d.ts +44 -0
  84. package/dist/interactive/fix-wizard.d.ts.map +1 -0
  85. package/dist/interactive/fix-wizard.js +286 -0
  86. package/dist/interactive/init-wizard.d.ts +32 -0
  87. package/dist/interactive/init-wizard.d.ts.map +1 -0
  88. package/dist/interactive/init-wizard.js +193 -0
  89. package/dist/interactive/prompts.d.ts +62 -0
  90. package/dist/interactive/prompts.d.ts.map +1 -0
  91. package/dist/interactive/prompts.js +78 -0
  92. package/dist/monorepo/detector.d.ts +70 -0
  93. package/dist/monorepo/detector.d.ts.map +1 -0
  94. package/dist/monorepo/detector.js +278 -0
  95. package/dist/monorepo/index.d.ts +9 -0
  96. package/dist/monorepo/index.d.ts.map +1 -0
  97. package/dist/monorepo/index.js +8 -0
  98. package/dist/monorepo/workspace.d.ts +142 -0
  99. package/dist/monorepo/workspace.d.ts.map +1 -0
  100. package/dist/monorepo/workspace.js +171 -0
  101. package/dist/output/envelope.d.ts +21 -0
  102. package/dist/output/envelope.d.ts.map +1 -0
  103. package/dist/output/envelope.js +27 -0
  104. package/dist/output/factory.d.ts +73 -0
  105. package/dist/output/factory.d.ts.map +1 -0
  106. package/dist/output/factory.js +60 -0
  107. package/dist/output/formats.d.ts +11 -0
  108. package/dist/output/formats.d.ts.map +1 -0
  109. package/dist/output/formats.js +41 -0
  110. package/dist/output/html.d.ts +45 -0
  111. package/dist/output/html.d.ts.map +1 -0
  112. package/dist/output/html.js +607 -0
  113. package/dist/output/human.d.ts +41 -0
  114. package/dist/output/human.d.ts.map +1 -0
  115. package/dist/output/human.js +274 -0
  116. package/dist/output/json.d.ts +42 -0
  117. package/dist/output/json.d.ts.map +1 -0
  118. package/dist/output/json.js +37 -0
  119. package/dist/output/junit.d.ts +56 -0
  120. package/dist/output/junit.d.ts.map +1 -0
  121. package/dist/output/junit.js +135 -0
  122. package/dist/output/markdown.d.ts +77 -0
  123. package/dist/output/markdown.d.ts.map +1 -0
  124. package/dist/output/markdown.js +411 -0
  125. package/dist/output/sarif.d.ts +160 -0
  126. package/dist/output/sarif.d.ts.map +1 -0
  127. package/dist/output/sarif.js +207 -0
  128. package/dist/policy/evaluator.d.ts +111 -0
  129. package/dist/policy/evaluator.d.ts.map +1 -0
  130. package/dist/policy/evaluator.js +362 -0
  131. package/dist/policy/index.d.ts +15 -0
  132. package/dist/policy/index.d.ts.map +1 -0
  133. package/dist/policy/index.js +11 -0
  134. package/dist/policy/loader.d.ts +97 -0
  135. package/dist/policy/loader.d.ts.map +1 -0
  136. package/dist/policy/loader.js +281 -0
  137. package/dist/policy/schema.d.ts +297 -0
  138. package/dist/policy/schema.d.ts.map +1 -0
  139. package/dist/policy/schema.js +230 -0
  140. package/dist/quality-gate/evaluator.d.ts +58 -0
  141. package/dist/quality-gate/evaluator.d.ts.map +1 -0
  142. package/dist/quality-gate/evaluator.js +274 -0
  143. package/dist/quality-gate/index.d.ts +10 -0
  144. package/dist/quality-gate/index.d.ts.map +1 -0
  145. package/dist/quality-gate/index.js +7 -0
  146. package/dist/quality-gate/types.d.ts +103 -0
  147. package/dist/quality-gate/types.d.ts.map +1 -0
  148. package/dist/quality-gate/types.js +23 -0
  149. package/dist/templates/azure-devops.d.ts +25 -0
  150. package/dist/templates/azure-devops.d.ts.map +1 -0
  151. package/dist/templates/azure-devops.js +109 -0
  152. package/dist/templates/circleci.d.ts +28 -0
  153. package/dist/templates/circleci.d.ts.map +1 -0
  154. package/dist/templates/circleci.js +86 -0
  155. package/dist/templates/github-actions.d.ts +81 -0
  156. package/dist/templates/github-actions.d.ts.map +1 -0
  157. package/dist/templates/github-actions.js +393 -0
  158. package/dist/templates/gitlab-ci.d.ts +26 -0
  159. package/dist/templates/gitlab-ci.d.ts.map +1 -0
  160. package/dist/templates/gitlab-ci.js +70 -0
  161. package/dist/templates/index.d.ts +72 -0
  162. package/dist/templates/index.d.ts.map +1 -0
  163. package/dist/templates/index.js +112 -0
  164. package/dist/templates/jenkins.d.ts +26 -0
  165. package/dist/templates/jenkins.d.ts.map +1 -0
  166. package/dist/templates/jenkins.js +110 -0
  167. package/dist/ui/banner.d.ts +31 -0
  168. package/dist/ui/banner.d.ts.map +1 -0
  169. package/dist/ui/banner.js +84 -0
  170. package/dist/ui/diagnostics.d.ts +39 -0
  171. package/dist/ui/diagnostics.d.ts.map +1 -0
  172. package/dist/ui/diagnostics.js +153 -0
  173. package/dist/ui/spinner.d.ts +61 -0
  174. package/dist/ui/spinner.d.ts.map +1 -0
  175. package/dist/ui/spinner.js +101 -0
  176. package/dist/ui/table.d.ts +63 -0
  177. package/dist/ui/table.d.ts.map +1 -0
  178. package/dist/ui/table.js +236 -0
  179. package/dist/utils/client.d.ts +82 -0
  180. package/dist/utils/client.d.ts.map +1 -0
  181. package/dist/utils/client.js +128 -0
  182. package/dist/utils/detect-env.d.ts +59 -0
  183. package/dist/utils/detect-env.d.ts.map +1 -0
  184. package/dist/utils/detect-env.js +115 -0
  185. package/dist/utils/exit-codes.d.ts +47 -0
  186. package/dist/utils/exit-codes.d.ts.map +1 -0
  187. package/dist/utils/exit-codes.js +61 -0
  188. package/dist/utils/logger.d.ts +87 -0
  189. package/dist/utils/logger.d.ts.map +1 -0
  190. package/dist/utils/logger.js +185 -0
  191. package/dist/utils/sanitize.d.ts +36 -0
  192. package/dist/utils/sanitize.d.ts.map +1 -0
  193. package/dist/utils/sanitize.js +64 -0
  194. package/dist/utils/validators.d.ts +41 -0
  195. package/dist/utils/validators.d.ts.map +1 -0
  196. package/dist/utils/validators.js +123 -0
  197. package/package.json +63 -0
  198. package/schemas/vertaaux.config.schema.json +103 -0
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Workspace audit orchestration for monorepos.
3
+ *
4
+ * Handles running audits across multiple workspaces with
5
+ * proper isolation and result aggregation.
6
+ */
7
+ /**
8
+ * Audit a single workspace.
9
+ *
10
+ * If URL not provided, uses the workspace's inferred URL.
11
+ * In future versions, this could start the dev server automatically.
12
+ *
13
+ * @param options - Workspace audit options
14
+ * @returns WorkspaceResult with audit outcome
15
+ */
16
+ export async function auditWorkspace(options) {
17
+ const startTime = Date.now();
18
+ const { workspace, baseUrl, port } = options;
19
+ // Determine URL to audit
20
+ const url = baseUrl ||
21
+ (port ? `http://localhost:${port}` : workspace.url) ||
22
+ `http://localhost:${workspace.port || 3000}`;
23
+ try {
24
+ // Note: The actual audit execution is delegated to the main audit logic
25
+ // This function provides the orchestration structure
26
+ // The audit command will call this and provide the actual audit implementation
27
+ const result = {
28
+ workspace,
29
+ auditResult: {
30
+ url,
31
+ status: "pending",
32
+ issues: [],
33
+ },
34
+ duration: Date.now() - startTime,
35
+ };
36
+ return result;
37
+ }
38
+ catch (error) {
39
+ return {
40
+ workspace,
41
+ auditResult: null,
42
+ error: error instanceof Error ? error : new Error(String(error)),
43
+ duration: Date.now() - startTime,
44
+ };
45
+ }
46
+ }
47
+ /**
48
+ * Generate matrix configuration for CI parallel execution.
49
+ *
50
+ * This generates a JSON structure suitable for GitHub Actions matrix strategy
51
+ * or similar CI systems that support parallel job execution.
52
+ *
53
+ * @param workspaces - List of workspaces to include in matrix
54
+ * @returns Matrix configuration object
55
+ *
56
+ * @example
57
+ * ```yaml
58
+ * # In GitHub Actions:
59
+ * jobs:
60
+ * detect-apps:
61
+ * runs-on: ubuntu-latest
62
+ * outputs:
63
+ * matrix: ${{ steps.detect.outputs.matrix }}
64
+ * steps:
65
+ * - id: detect
66
+ * run: echo "matrix=$(vertaa audit --detect-matrix --json)" >> $GITHUB_OUTPUT
67
+ *
68
+ * audit:
69
+ * needs: detect-apps
70
+ * strategy:
71
+ * matrix: ${{ fromJson(needs.detect-apps.outputs.matrix) }}
72
+ * steps:
73
+ * - run: vertaa audit --workspace ${{ matrix.name }}
74
+ * ```
75
+ */
76
+ export function generateMatrixConfig(workspaces) {
77
+ return {
78
+ include: workspaces.map((ws) => ({
79
+ name: ws.name,
80
+ path: ws.path,
81
+ url: ws.url,
82
+ port: ws.port,
83
+ appType: ws.appType,
84
+ })),
85
+ };
86
+ }
87
+ /**
88
+ * Aggregate results from multiple workspace audits.
89
+ *
90
+ * @param results - Array of workspace results
91
+ * @returns Aggregated results summary
92
+ */
93
+ export function aggregateResults(results) {
94
+ const aggregated = {
95
+ totalWorkspaces: results.length,
96
+ successfulAudits: 0,
97
+ failedAudits: 0,
98
+ totalIssues: 0,
99
+ issuesBySeverity: {
100
+ error: 0,
101
+ warning: 0,
102
+ info: 0,
103
+ },
104
+ workspaceResults: results,
105
+ totalDuration: 0,
106
+ };
107
+ for (const result of results) {
108
+ aggregated.totalDuration += result.duration;
109
+ if (result.error || !result.auditResult) {
110
+ aggregated.failedAudits++;
111
+ continue;
112
+ }
113
+ aggregated.successfulAudits++;
114
+ const issues = result.auditResult.issues || [];
115
+ aggregated.totalIssues += issues.length;
116
+ // Count issues by severity
117
+ for (const issue of issues) {
118
+ const severity = (issue.severity || "info").toLowerCase();
119
+ if (severity === "error" || severity === "critical") {
120
+ aggregated.issuesBySeverity.error++;
121
+ }
122
+ else if (severity === "warning" || severity === "serious") {
123
+ aggregated.issuesBySeverity.warning++;
124
+ }
125
+ else {
126
+ aggregated.issuesBySeverity.info++;
127
+ }
128
+ }
129
+ }
130
+ return aggregated;
131
+ }
132
+ /**
133
+ * Format aggregated results for display.
134
+ *
135
+ * @param aggregated - Aggregated results
136
+ * @returns Formatted string for console output
137
+ */
138
+ export function formatAggregatedResults(aggregated) {
139
+ const lines = [];
140
+ lines.push(`Monorepo Audit Summary`);
141
+ lines.push(`======================`);
142
+ lines.push(``);
143
+ lines.push(`Workspaces: ${aggregated.totalWorkspaces}`);
144
+ lines.push(` Successful: ${aggregated.successfulAudits}`);
145
+ lines.push(` Failed: ${aggregated.failedAudits}`);
146
+ lines.push(``);
147
+ lines.push(`Total Issues: ${aggregated.totalIssues}`);
148
+ lines.push(` Errors: ${aggregated.issuesBySeverity.error}`);
149
+ lines.push(` Warnings: ${aggregated.issuesBySeverity.warning}`);
150
+ lines.push(` Info: ${aggregated.issuesBySeverity.info}`);
151
+ lines.push(``);
152
+ lines.push(`Duration: ${(aggregated.totalDuration / 1000).toFixed(2)}s`);
153
+ // Per-workspace breakdown
154
+ lines.push(``);
155
+ lines.push(`Per-Workspace Results:`);
156
+ lines.push(`----------------------`);
157
+ for (const result of aggregated.workspaceResults) {
158
+ const issueCount = result.auditResult?.issues?.length || 0;
159
+ const status = result.error
160
+ ? "FAILED"
161
+ : result.cached
162
+ ? "CACHED"
163
+ : "OK";
164
+ const statusSymbol = result.error ? "X" : result.cached ? "~" : "+";
165
+ lines.push(` [${statusSymbol}] ${result.workspace.name}: ${issueCount} issues (${status})`);
166
+ if (result.error) {
167
+ lines.push(` Error: ${result.error.message}`);
168
+ }
169
+ }
170
+ return lines.join("\n");
171
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * JSON output envelope for CLI commands.
3
+ *
4
+ * Wraps all JSON output with metadata (version, timestamp, command, args).
5
+ * This satisfies the output contract requirement that JSON output includes
6
+ * provenance information for debugging and version tracking.
7
+ */
8
+ export interface OutputMeta {
9
+ version: string;
10
+ timestamp: string;
11
+ command: string;
12
+ args: string[];
13
+ }
14
+ export interface OutputEnvelope<T = unknown> {
15
+ meta: OutputMeta;
16
+ data: T;
17
+ }
18
+ export declare function createEnvelope<T>(data: T, command: string): OutputEnvelope<T>;
19
+ export declare function writeJsonOutput<T>(data: T, command: string): void;
20
+ export declare function writeOutput(content: string): void;
21
+ //# sourceMappingURL=envelope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/output/envelope.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO;IACzC,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,CAAC,CAAC;CACT;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,CAa7E;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAGjE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEjD"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * JSON output envelope for CLI commands.
3
+ *
4
+ * Wraps all JSON output with metadata (version, timestamp, command, args).
5
+ * This satisfies the output contract requirement that JSON output includes
6
+ * provenance information for debugging and version tracking.
7
+ */
8
+ import { getVersion } from "../ui/banner.js";
9
+ export function createEnvelope(data, command) {
10
+ return {
11
+ meta: {
12
+ version: getVersion(),
13
+ timestamp: new Date().toISOString(),
14
+ command,
15
+ // Filter out any args containing API keys or tokens
16
+ args: process.argv.slice(2).filter(a => !a.includes("VERTAAUX_API_KEY") && !a.includes("Bearer")),
17
+ },
18
+ data,
19
+ };
20
+ }
21
+ export function writeJsonOutput(data, command) {
22
+ const envelope = createEnvelope(data, command);
23
+ process.stdout.write(JSON.stringify(envelope, null, 2) + "\n");
24
+ }
25
+ export function writeOutput(content) {
26
+ process.stdout.write(content + "\n");
27
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Output formatter factory for CLI.
3
+ *
4
+ * Creates the appropriate formatter based on detected or explicit output format.
5
+ * Supports human, JSON, HTML, SARIF, and JUnit output with auto-detection.
6
+ */
7
+ import { type FormatHumanOptions } from "./human.js";
8
+ import { type FormatJsonOptions } from "./json.js";
9
+ import { type FormatHtmlOptions } from "./html.js";
10
+ import { type SarifOptions } from "./sarif.js";
11
+ import { type JunitOptions } from "./junit.js";
12
+ import { type OutputFormat } from "../utils/detect-env.js";
13
+ export interface AuditResult {
14
+ job_id?: string;
15
+ status?: string;
16
+ url?: string;
17
+ mode?: string;
18
+ progress?: number;
19
+ created_at?: string;
20
+ started_at?: string;
21
+ completed_at?: string;
22
+ scores?: Record<string, unknown>;
23
+ issues?: unknown;
24
+ error?: string;
25
+ }
26
+ export interface FormatOptions {
27
+ /** Human output options */
28
+ human?: FormatHumanOptions;
29
+ /** JSON output options */
30
+ json?: FormatJsonOptions;
31
+ /** HTML output options */
32
+ html?: FormatHtmlOptions;
33
+ /** SARIF output options */
34
+ sarif?: SarifOptions;
35
+ /** JUnit output options */
36
+ junit?: JunitOptions;
37
+ }
38
+ /**
39
+ * Formatter interface for audit results.
40
+ */
41
+ export interface Formatter {
42
+ /** The resolved output format */
43
+ format: OutputFormat;
44
+ /**
45
+ * Format the audit result.
46
+ * @param result - Audit result to format
47
+ * @param options - Format-specific options
48
+ * @returns Formatted string
49
+ */
50
+ formatResult(result: AuditResult, options?: FormatOptions): string;
51
+ }
52
+ /**
53
+ * Create a formatter for the specified or auto-detected output format.
54
+ *
55
+ * @param format - Explicit format or "auto" for auto-detection
56
+ * @returns A formatter instance
57
+ */
58
+ export declare function createOutput(format?: OutputFormat | "auto"): Formatter;
59
+ /**
60
+ * Quick format helper - formats result using auto-detected format.
61
+ *
62
+ * @param result - Audit result to format
63
+ * @param explicitFormat - Optional explicit format override
64
+ * @param options - Format-specific options
65
+ * @returns Formatted string
66
+ */
67
+ export declare function formatOutput(result: AuditResult, explicitFormat?: string, options?: FormatOptions): string;
68
+ export { formatAuditHuman } from "./human.js";
69
+ export { formatAuditJson, formatJson } from "./json.js";
70
+ export { formatAuditHtml } from "./html.js";
71
+ export { formatSarif } from "./sarif.js";
72
+ export { formatJunit } from "./junit.js";
73
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/output/factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAoB,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE/E,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,0BAA0B;IAC1B,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,0BAA0B;IAC1B,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,iCAAiC;IACjC,MAAM,EAAE,YAAY,CAAC;IACrB;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;CACpE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAE,YAAY,GAAG,MAAe,GAAG,SAAS,CA4B9E;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,WAAW,EACnB,cAAc,CAAC,EAAE,MAAM,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,MAAM,CAIR;AAGD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Output formatter factory for CLI.
3
+ *
4
+ * Creates the appropriate formatter based on detected or explicit output format.
5
+ * Supports human, JSON, HTML, SARIF, and JUnit output with auto-detection.
6
+ */
7
+ import { formatAuditHuman } from "./human.js";
8
+ import { formatAuditJson } from "./json.js";
9
+ import { formatAuditHtml } from "./html.js";
10
+ import { formatSarif } from "./sarif.js";
11
+ import { formatJunit } from "./junit.js";
12
+ import { detectOutputFormat } from "../utils/detect-env.js";
13
+ /**
14
+ * Create a formatter for the specified or auto-detected output format.
15
+ *
16
+ * @param format - Explicit format or "auto" for auto-detection
17
+ * @returns A formatter instance
18
+ */
19
+ export function createOutput(format = "auto") {
20
+ const resolvedFormat = format === "auto" ? detectOutputFormat() : format;
21
+ return {
22
+ format: resolvedFormat,
23
+ formatResult(result, options = {}) {
24
+ switch (resolvedFormat) {
25
+ case "human":
26
+ return formatAuditHuman(result, options.human);
27
+ case "json":
28
+ return formatAuditJson(result, options.json);
29
+ case "html":
30
+ return formatAuditHtml(result, options.html);
31
+ case "sarif":
32
+ return formatSarif(result, options.sarif);
33
+ case "junit":
34
+ return formatJunit(result, options.junit);
35
+ default:
36
+ // Default to JSON for unknown formats
37
+ return formatAuditJson(result, options.json);
38
+ }
39
+ },
40
+ };
41
+ }
42
+ /**
43
+ * Quick format helper - formats result using auto-detected format.
44
+ *
45
+ * @param result - Audit result to format
46
+ * @param explicitFormat - Optional explicit format override
47
+ * @param options - Format-specific options
48
+ * @returns Formatted string
49
+ */
50
+ export function formatOutput(result, explicitFormat, options) {
51
+ const format = explicitFormat || "auto";
52
+ const formatter = createOutput(format);
53
+ return formatter.formatResult(result, options);
54
+ }
55
+ // Re-export individual formatters for direct access
56
+ export { formatAuditHuman } from "./human.js";
57
+ export { formatAuditJson, formatJson } from "./json.js";
58
+ export { formatAuditHtml } from "./html.js";
59
+ export { formatSarif } from "./sarif.js";
60
+ export { formatJunit } from "./junit.js";
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Per-command format registry for CLI output.
3
+ *
4
+ * Defines which output formats each command supports, their defaults,
5
+ * and validates format selection with clear error messages.
6
+ */
7
+ export declare const COMMAND_FORMATS: Record<string, readonly string[]>;
8
+ export declare const COMMAND_DEFAULT_FORMAT: Record<string, string>;
9
+ export declare function validateFormat(command: string, format: string | undefined): string;
10
+ export declare function resolveCommandFormat(command: string, explicitFormat: string | undefined, machineMode: boolean): string;
11
+ //# sourceMappingURL=formats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../../src/output/formats.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAM7D,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMzD,CAAC;AAEF,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAclF;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,WAAW,EAAE,OAAO,GACnB,MAAM,CAMR"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Per-command format registry for CLI output.
3
+ *
4
+ * Defines which output formats each command supports, their defaults,
5
+ * and validates format selection with clear error messages.
6
+ */
7
+ export const COMMAND_FORMATS = {
8
+ audit: ["json", "sarif", "junit", "html", "human"],
9
+ comment: ["json", "markdown"],
10
+ explain: ["json", "human"],
11
+ "policy-show": ["json", "yaml"],
12
+ diff: ["json", "human"],
13
+ };
14
+ export const COMMAND_DEFAULT_FORMAT = {
15
+ audit: "human",
16
+ comment: "markdown",
17
+ explain: "human",
18
+ "policy-show": "yaml",
19
+ diff: "human",
20
+ };
21
+ export function validateFormat(command, format) {
22
+ const allowed = COMMAND_FORMATS[command];
23
+ if (!allowed)
24
+ return format || "json"; // unknown command, pass through
25
+ // Use default if no format specified
26
+ if (!format)
27
+ return COMMAND_DEFAULT_FORMAT[command] || allowed[0];
28
+ if (!allowed.includes(format)) {
29
+ const msg = `Error: Invalid format "${format}" for "${command}". Supported: ${allowed.join(", ")}`;
30
+ console.error(msg);
31
+ process.exit(2);
32
+ }
33
+ return format;
34
+ }
35
+ export function resolveCommandFormat(command, explicitFormat, machineMode) {
36
+ // Machine mode defaults to JSON unless explicitly overridden
37
+ if (machineMode && !explicitFormat) {
38
+ return "json";
39
+ }
40
+ return validateFormat(command, explicitFormat);
41
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * HTML output formatter for CLI.
3
+ *
4
+ * Generates standalone HTML reports with embedded CSS and JS.
5
+ * Reports are print-friendly and don't require external dependencies.
6
+ */
7
+ export interface Issue {
8
+ id?: string;
9
+ severity?: string;
10
+ category?: string;
11
+ description?: string;
12
+ title?: string;
13
+ selector?: string;
14
+ wcag_reference?: string;
15
+ recommendation?: string;
16
+ recommended_fix?: string;
17
+ }
18
+ export interface AuditResult {
19
+ job_id?: string;
20
+ status?: string;
21
+ url?: string;
22
+ mode?: string;
23
+ progress?: number;
24
+ created_at?: string;
25
+ started_at?: string;
26
+ completed_at?: string;
27
+ scores?: Record<string, unknown>;
28
+ issues?: unknown;
29
+ error?: string;
30
+ }
31
+ export interface FormatHtmlOptions {
32
+ /** Report title (default: "VertaaUX Audit Report") */
33
+ title?: string;
34
+ /** Whether to include inline JavaScript for interactivity */
35
+ interactive?: boolean;
36
+ }
37
+ /**
38
+ * Format audit result as standalone HTML report.
39
+ *
40
+ * @param result - Audit result object
41
+ * @param options - Formatting options
42
+ * @returns Complete HTML document string
43
+ */
44
+ export declare function formatAuditHtml(result: AuditResult, options?: FormatHtmlOptions): string;
45
+ //# sourceMappingURL=html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/output/html.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,KAAK;IACpB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAoiBD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CA8DR"}