@fairfox/polly 0.1.1 → 0.1.2
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/cli/polly.ts +9 -3
- package/package.json +2 -2
- package/vendor/analysis/src/extract/adr.ts +212 -0
- package/vendor/analysis/src/extract/architecture.ts +160 -0
- package/vendor/analysis/src/extract/contexts.ts +298 -0
- package/vendor/analysis/src/extract/flows.ts +309 -0
- package/vendor/analysis/src/extract/handlers.ts +321 -0
- package/vendor/analysis/src/extract/index.ts +9 -0
- package/vendor/analysis/src/extract/integrations.ts +329 -0
- package/vendor/analysis/src/extract/manifest.ts +298 -0
- package/vendor/analysis/src/extract/types.ts +389 -0
- package/vendor/analysis/src/index.ts +7 -0
- package/vendor/analysis/src/types/adr.ts +53 -0
- package/vendor/analysis/src/types/architecture.ts +245 -0
- package/vendor/analysis/src/types/core.ts +210 -0
- package/vendor/analysis/src/types/index.ts +18 -0
- package/vendor/verify/src/adapters/base.ts +164 -0
- package/vendor/verify/src/adapters/detection.ts +281 -0
- package/vendor/verify/src/adapters/event-bus/index.ts +480 -0
- package/vendor/verify/src/adapters/web-extension/index.ts +508 -0
- package/vendor/verify/src/adapters/websocket/index.ts +486 -0
- package/vendor/verify/src/cli.ts +430 -0
- package/vendor/verify/src/codegen/config.ts +354 -0
- package/vendor/verify/src/codegen/tla.ts +719 -0
- package/vendor/verify/src/config/parser.ts +303 -0
- package/vendor/verify/src/config/types.ts +113 -0
- package/vendor/verify/src/core/model.ts +267 -0
- package/vendor/verify/src/core/primitives.ts +106 -0
- package/vendor/verify/src/extract/handlers.ts +2 -0
- package/vendor/verify/src/extract/types.ts +2 -0
- package/vendor/verify/src/index.ts +150 -0
- package/vendor/verify/src/primitives/index.ts +102 -0
- package/vendor/verify/src/runner/docker.ts +283 -0
- package/vendor/verify/src/types.ts +51 -0
- package/vendor/visualize/src/cli.ts +365 -0
- package/vendor/visualize/src/codegen/structurizr.ts +770 -0
- package/vendor/visualize/src/index.ts +13 -0
- package/vendor/visualize/src/runner/export.ts +235 -0
- package/vendor/visualize/src/viewer/server.ts +485 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Main entry point for @fairfox/polly-visualize
|
|
2
|
+
|
|
3
|
+
// Export DSL generator
|
|
4
|
+
export * from "./codegen/structurizr";
|
|
5
|
+
|
|
6
|
+
// Export diagram exporter
|
|
7
|
+
export * from "./runner/export";
|
|
8
|
+
|
|
9
|
+
// Export interactive viewer
|
|
10
|
+
export * from "./viewer/server";
|
|
11
|
+
|
|
12
|
+
// Re-export analysis functionality for convenience
|
|
13
|
+
export { analyzeArchitecture, type ArchitectureAnalysis } from "@fairfox/polly-analysis";
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// Export static site using Structurizr CLI
|
|
2
|
+
// Uses Docker to run Structurizr CLI for generating a static HTML site
|
|
3
|
+
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
|
|
8
|
+
export interface ExportOptions {
|
|
9
|
+
/** DSL file path */
|
|
10
|
+
dslPath: string;
|
|
11
|
+
|
|
12
|
+
/** Output directory for static site */
|
|
13
|
+
outputDir: string;
|
|
14
|
+
|
|
15
|
+
/** Timeout in milliseconds */
|
|
16
|
+
timeout?: number;
|
|
17
|
+
|
|
18
|
+
/** Callback for progress updates */
|
|
19
|
+
onProgress?: (message: string) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ExportResult {
|
|
23
|
+
success: boolean;
|
|
24
|
+
siteDir: string;
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class DiagramExporter {
|
|
29
|
+
private static readonly DOCKER_IMAGE = "structurizr/cli:latest";
|
|
30
|
+
private static readonly DEFAULT_TIMEOUT = 120000; // 2 minutes
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Export static site using Structurizr CLI via Docker
|
|
34
|
+
*/
|
|
35
|
+
async export(options: ExportOptions): Promise<ExportResult> {
|
|
36
|
+
const { dslPath, outputDir, timeout = DiagramExporter.DEFAULT_TIMEOUT } = options;
|
|
37
|
+
|
|
38
|
+
// Validate DSL file exists
|
|
39
|
+
if (!fs.existsSync(dslPath)) {
|
|
40
|
+
return {
|
|
41
|
+
success: false,
|
|
42
|
+
siteDir: "",
|
|
43
|
+
error: `DSL file not found: ${dslPath}`,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Ensure output directory exists
|
|
48
|
+
if (!fs.existsSync(outputDir)) {
|
|
49
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Check if Docker is available
|
|
53
|
+
const dockerAvailable = await this.isDockerAvailable();
|
|
54
|
+
if (!dockerAvailable) {
|
|
55
|
+
return {
|
|
56
|
+
success: false,
|
|
57
|
+
siteDir: "",
|
|
58
|
+
error: "Docker is not available. Please install Docker to export the site.",
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Pull image if needed
|
|
63
|
+
options.onProgress?.("Checking Structurizr CLI image...");
|
|
64
|
+
const hasImage = await this.hasImage();
|
|
65
|
+
if (!hasImage) {
|
|
66
|
+
options.onProgress?.("Pulling Structurizr CLI image (this may take a moment)...");
|
|
67
|
+
await this.pullImage((line) => options.onProgress?.(line));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Export static site
|
|
71
|
+
options.onProgress?.("Generating static site...");
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
await this.exportStaticSite(dslPath, outputDir, timeout);
|
|
75
|
+
options.onProgress?.("✓ Static site generated successfully");
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
success: true,
|
|
79
|
+
siteDir: outputDir,
|
|
80
|
+
};
|
|
81
|
+
} catch (error) {
|
|
82
|
+
return {
|
|
83
|
+
success: false,
|
|
84
|
+
siteDir: "",
|
|
85
|
+
error: `Failed to export static site: ${error}`,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Export static HTML site using Structurizr CLI
|
|
92
|
+
*/
|
|
93
|
+
private async exportStaticSite(
|
|
94
|
+
dslPath: string,
|
|
95
|
+
outputDir: string,
|
|
96
|
+
timeout: number
|
|
97
|
+
): Promise<void> {
|
|
98
|
+
const dslDir = path.dirname(dslPath);
|
|
99
|
+
const dslFileName = path.basename(dslPath);
|
|
100
|
+
|
|
101
|
+
// Docker volume mounts
|
|
102
|
+
const workspaceMount = `${dslDir}:/usr/local/structurizr`;
|
|
103
|
+
const outputMount = `${outputDir}:/output`;
|
|
104
|
+
|
|
105
|
+
// Structurizr CLI command for static site export
|
|
106
|
+
const args = [
|
|
107
|
+
"run",
|
|
108
|
+
"--rm",
|
|
109
|
+
"-v",
|
|
110
|
+
workspaceMount,
|
|
111
|
+
"-v",
|
|
112
|
+
outputMount,
|
|
113
|
+
DiagramExporter.DOCKER_IMAGE,
|
|
114
|
+
"export",
|
|
115
|
+
"-workspace",
|
|
116
|
+
`/usr/local/structurizr/${dslFileName}`,
|
|
117
|
+
"-format",
|
|
118
|
+
"static",
|
|
119
|
+
"-output",
|
|
120
|
+
"/output",
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
await this.runDocker(args, timeout);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Check if Docker is available
|
|
128
|
+
*/
|
|
129
|
+
async isDockerAvailable(): Promise<boolean> {
|
|
130
|
+
try {
|
|
131
|
+
await this.runCommand("docker", ["--version"], 5000);
|
|
132
|
+
return true;
|
|
133
|
+
} catch {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Check if Structurizr CLI image is available
|
|
140
|
+
*/
|
|
141
|
+
async hasImage(): Promise<boolean> {
|
|
142
|
+
try {
|
|
143
|
+
const output = await this.runCommand(
|
|
144
|
+
"docker",
|
|
145
|
+
["images", "-q", DiagramExporter.DOCKER_IMAGE],
|
|
146
|
+
5000
|
|
147
|
+
);
|
|
148
|
+
return output.trim().length > 0;
|
|
149
|
+
} catch {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Pull Structurizr CLI image
|
|
156
|
+
*/
|
|
157
|
+
async pullImage(onProgress?: (line: string) => void): Promise<void> {
|
|
158
|
+
return new Promise((resolve, reject) => {
|
|
159
|
+
const proc = spawn("docker", ["pull", DiagramExporter.DOCKER_IMAGE]);
|
|
160
|
+
|
|
161
|
+
proc.stdout.on("data", (data) => {
|
|
162
|
+
onProgress?.(data.toString().trim());
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
proc.stderr.on("data", (data) => {
|
|
166
|
+
onProgress?.(data.toString().trim());
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
proc.on("close", (code) => {
|
|
170
|
+
if (code === 0) {
|
|
171
|
+
resolve();
|
|
172
|
+
} else {
|
|
173
|
+
reject(new Error(`Failed to pull image, exit code: ${code}`));
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
proc.on("error", (error) => {
|
|
178
|
+
reject(error);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Run Docker command
|
|
185
|
+
*/
|
|
186
|
+
private async runDocker(args: string[], timeout: number): Promise<string> {
|
|
187
|
+
return this.runCommand("docker", args, timeout);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Run shell command
|
|
192
|
+
*/
|
|
193
|
+
private async runCommand(command: string, args: string[], timeout: number): Promise<string> {
|
|
194
|
+
return new Promise((resolve, reject) => {
|
|
195
|
+
const proc = spawn(command, args);
|
|
196
|
+
let stdout = "";
|
|
197
|
+
let stderr = "";
|
|
198
|
+
|
|
199
|
+
const timer = setTimeout(() => {
|
|
200
|
+
proc.kill();
|
|
201
|
+
reject(new Error(`Command timed out after ${timeout}ms`));
|
|
202
|
+
}, timeout);
|
|
203
|
+
|
|
204
|
+
proc.stdout.on("data", (data) => {
|
|
205
|
+
stdout += data.toString();
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
proc.stderr.on("data", (data) => {
|
|
209
|
+
stderr += data.toString();
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
proc.on("close", (code) => {
|
|
213
|
+
clearTimeout(timer);
|
|
214
|
+
if (code === 0) {
|
|
215
|
+
resolve(stdout);
|
|
216
|
+
} else {
|
|
217
|
+
reject(new Error(`Command failed with exit code ${code}: ${stderr}`));
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
proc.on("error", (error) => {
|
|
222
|
+
clearTimeout(timer);
|
|
223
|
+
reject(error);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Export diagrams
|
|
231
|
+
*/
|
|
232
|
+
export async function exportDiagrams(options: ExportOptions): Promise<ExportResult> {
|
|
233
|
+
const exporter = new DiagramExporter();
|
|
234
|
+
return exporter.export(options);
|
|
235
|
+
}
|