Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion packages/vscode/src/diagnostics/analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ const YAML_EXTENSIONS = [".yaml", ".yml"];
const FIGRAM_FILE_PATTERNS = ["diagram.yaml", "diagram.yml", ".figram.yaml", ".figram.yml"];
const FIGRAM_ICONS_PATTERNS = ["figram-icons.yaml", "figram-icons.yml"];

// Special kinds that render as sections (containers) without icons
// These are valid kinds supported by the plugin but don't have icon entries
const SECTION_KINDS = new Set([
// VPC kinds
"network.vpc",
"virtual_networks",
"virtual_networks_classic",
// Subnet kinds
"network.subnet",
"subnet",
]);

function hasExtension(fileName: string, extensions: string[]): boolean {
return extensions.some((ext) => fileName.endsWith(ext));
}
Expand Down Expand Up @@ -141,7 +153,9 @@ export function analyzeDocument(document: vscode.TextDocument): AnalysisResult {
// Validate kind (only if provider is valid)
if (node.provider && node.kind && supportedProviders.includes(node.provider)) {
const providerIcons = iconsData[node.provider];
if (providerIcons && !providerIcons[node.kind]) {
// Allow section kinds (VPC/Subnet) even without icon entries
const isValidKind = providerIcons?.[node.kind] || SECTION_KINDS.has(node.kind);
if (!isValidKind) {
const lineInfo = findFieldLine(lines, node.id, "kind", node.kind);
issues.push({
severity: "warning",
Expand Down
21 changes: 4 additions & 17 deletions packages/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,19 @@ function registerInitCommand(): vscode.Disposable {
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
const cliResult = await detectCli(workspaceFolder);

const filename = await vscode.window.showInputBox({
prompt: "Enter filename for the new diagram file",
value: "diagram.yaml",
validateInput: (value) => {
if (!value.endsWith(".yaml") && !value.endsWith(".yml")) {
return "Filename must end with .yaml or .yml";
}
return null;
},
});

if (!filename) return;

outputChannel.appendLine(`\n[figram] Running init...`);

try {
await runCli(cliResult, {
args: ["init", "-o", filename],
args: ["init"],
cwd: workspaceFolder?.uri.fsPath,
...createCliHandlers(outputChannel),
onExit: async (code) => {
if (code === 0) {
vscode.window.showInformationMessage(`Created ${filename}`);
vscode.window.showInformationMessage("Created diagram.yaml");
const filePath = workspaceFolder
? vscode.Uri.joinPath(workspaceFolder.uri, filename)
: vscode.Uri.file(filename);
? vscode.Uri.joinPath(workspaceFolder.uri, "diagram.yaml")
: vscode.Uri.file("diagram.yaml");
const doc = await vscode.workspace.openTextDocument(filePath);
await vscode.window.showTextDocument(doc);
} else {
Expand Down