Skip to content

Commit f2f4bb4

Browse files
Merge pull request #2 from Tripletex/chore/formatting-cleanup
Apply deno fmt formatting
2 parents 49d1625 + acf8126 commit f2f4bb4

35 files changed

Lines changed: 505 additions & 299 deletions

.mcp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"cwd": "."
1313
}
1414
}
15-
}
15+
}

README.md

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -562,55 +562,12 @@ deno task fmt
562562
### Project Structure
563563

564564
```
565-
mcp-dependency-version/
566-
├── main.ts # MCP server entry point
567-
├── deno.json # Deno configuration
568-
├── Dockerfile # Docker container build
569-
├── .mcp.json # MCP server registration
570-
├── README.md # Documentation
571-
├── src/
572-
│ ├── config/ # Configuration management
573-
│ │ ├── types.ts # Config types and defaults
574-
│ │ ├── loader.ts # Config file loading
575-
│ │ └── index.ts # Module exports
576-
│ ├── registries/ # Package registry clients
577-
│ │ ├── types.ts # Shared types
578-
│ │ ├── index.ts # Client factory
579-
│ │ ├── npm.ts # npm registry
580-
│ │ ├── maven.ts # Maven Central
581-
│ │ ├── pypi.ts # PyPI
582-
│ │ ├── cargo.ts # crates.io
583-
│ │ ├── go.ts # Go proxy
584-
│ │ ├── jsr.ts # JSR (jsr.io)
585-
│ │ ├── nuget.ts # NuGet
586-
│ │ └── docker.ts # Docker Hub
587-
│ ├── parsers/ # Dependency file parsers
588-
│ │ ├── types.ts # Parser types
589-
│ │ ├── index.ts # Parser factory
590-
│ │ ├── npm.ts # package.json
591-
│ │ ├── pypi.ts # requirements.txt
592-
│ │ ├── cargo.ts # Cargo.toml
593-
│ │ ├── go.ts # go.mod
594-
│ │ ├── maven.ts # pom.xml
595-
│ │ ├── gradle-groovy.ts # build.gradle
596-
│ │ ├── gradle-kotlin.ts # build.gradle.kts
597-
│ │ ├── deno.ts # deno.json
598-
│ │ ├── nuget.ts # *.csproj
599-
│ │ └── docker.ts # Dockerfile, docker-compose.yml
600-
│ ├── tools/ # MCP tool implementations
601-
│ │ ├── types.ts # Tool input/output types
602-
│ │ ├── lookup-version.ts # lookup_version tool
603-
│ │ ├── list-versions.ts # list_versions tool
604-
│ │ ├── check-vulnerabilities.ts # check_vulnerabilities tool
605-
│ │ ├── analyze-dependencies.ts # analyze_dependencies tool
606-
│ │ └── get-package-docs.ts # get_package_docs tool
607-
│ └── utils/
608-
│ ├── version.ts # Semver utilities
609-
│ ├── version.test.ts # Version tests
610-
│ ├── http.ts # HTTP utilities with auth
611-
│ ├── github.ts # GitHub API utilities
612-
│ ├── cache.ts # TTL cache
613-
│ └── vulnerability.ts # OSV vulnerability checking
565+
src/
566+
├── config/ # Configuration loading
567+
├── registries/ # Registry client implementations (npm, maven, pypi, etc.)
568+
├── parsers/ # Dependency file parsers (package.json, pom.xml, etc.)
569+
├── tools/ # MCP tool implementations
570+
└── utils/ # Shared utilities (version parsing, caching, HTTP)
614571
```
615572

616573
## API Reference

deno.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
},
1313
"imports": {
1414
"@modelcontextprotocol/sdk": "npm:@modelcontextprotocol/sdk@1.25.3",
15-
"zod": "npm:zod@3.25.76"
15+
"zod": "npm:zod@3.25.76",
16+
"@std/assert": "jsr:@std/assert@1.0.17"
1617
},
1718
"compilerOptions": {
1819
"strict": true,

deno.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config/loader.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function expandPath(path: string): string {
2828
*/
2929
function getConfigPath(): string {
3030
return expandPath(
31-
Deno.env.get("MCP_DEPENDENCY_VERSION_CONFIG") || DEFAULT_CONFIG_PATH
31+
Deno.env.get("MCP_DEPENDENCY_VERSION_CONFIG") || DEFAULT_CONFIG_PATH,
3232
);
3333
}
3434

@@ -68,7 +68,10 @@ export async function loadConfig(): Promise<Config> {
6868
userConfig = JSON.parse(content) as Partial<Config>;
6969
} catch (error) {
7070
if (!(error instanceof Deno.errors.NotFound)) {
71-
console.error(`Warning: Failed to load config from ${configPath}:`, error);
71+
console.error(
72+
`Warning: Failed to load config from ${configPath}:`,
73+
error,
74+
);
7275
}
7376
// Use defaults if no config file exists
7477
}
@@ -94,7 +97,10 @@ export function loadConfigSync(): Config {
9497
userConfig = JSON.parse(content) as Partial<Config>;
9598
} catch (error) {
9699
if (!(error instanceof Deno.errors.NotFound)) {
97-
console.error(`Warning: Failed to load config from ${configPath}:`, error);
100+
console.error(
101+
`Warning: Failed to load config from ${configPath}:`,
102+
error,
103+
);
98104
}
99105
}
100106

@@ -109,7 +115,7 @@ export function loadConfigSync(): Config {
109115
*/
110116
export function getRepositoryConfig(
111117
registry: Registry,
112-
repository?: string
118+
repository?: string,
113119
): RepositoryConfig {
114120
const config = loadConfigSync();
115121
const repos = config.repositories[registry];
@@ -123,7 +129,7 @@ export function getRepositoryConfig(
123129
if (!repo) {
124130
const available = Object.keys(repos).join(", ");
125131
throw new Error(
126-
`Repository '${repository}' not found for ${registry}. Available: ${available}`
132+
`Repository '${repository}' not found for ${registry}. Available: ${available}`,
127133
);
128134
}
129135
return repo;

src/parsers/cargo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function parse(content: string): ParsedDependency[] {
2525
}
2626

2727
const complexMatch = line.match(
28-
/^([a-zA-Z0-9_-]+)\s*=\s*\{.*version\s*=\s*"([^"]+)"/
28+
/^([a-zA-Z0-9_-]+)\s*=\s*\{.*version\s*=\s*"([^"]+)"/,
2929
);
3030
if (complexMatch) {
3131
deps.push({ name: complexMatch[1], version: complexMatch[2] });

src/parsers/deno.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function stripJsonComments(content: string): string {
7272
* jsr:@oak/oak@17 -> { registry: "jsr", name: "@oak/oak", version: "17" }
7373
*/
7474
function parseImportSpecifier(
75-
specifier: string
75+
specifier: string,
7676
): { registry: "jsr" | "npm"; name: string; version: string } | null {
7777
// Skip URL imports
7878
if (specifier.startsWith("http://") || specifier.startsWith("https://")) {
@@ -129,7 +129,9 @@ function parse(content: string): ParsedDependency[] {
129129

130130
// For npm: packages, prefix the name to indicate registry routing
131131
// For jsr: packages, use the name as-is
132-
const name = parsed.registry === "npm" ? `npm:${parsed.name}` : parsed.name;
132+
const name = parsed.registry === "npm"
133+
? `npm:${parsed.name}`
134+
: parsed.name;
133135

134136
deps.push({
135137
name,

src/parsers/docker.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,19 @@ function parseDockerfile(content: string): ParsedDependency[] {
7676
// Match FROM statements
7777
// FROM [--platform=...] image[:tag|@digest] [AS name]
7878
const fromMatch = trimmed.match(
79-
/^FROM\s+(?:--platform=[^\s]+\s+)?([^\s]+)(?:\s+AS\s+\w+)?$/i
79+
/^FROM\s+(?:--platform=[^\s]+\s+)?([^\s]+)(?:\s+AS\s+\w+)?$/i,
8080
);
8181

8282
if (fromMatch) {
8383
const imageRef = fromMatch[1];
8484
const parsed = parseImageReference(imageRef);
8585
if (parsed) {
8686
// Avoid duplicates
87-
if (!deps.some((d) => d.name === parsed.name && d.version === parsed.version)) {
87+
if (
88+
!deps.some((d) =>
89+
d.name === parsed.name && d.version === parsed.version
90+
)
91+
) {
8892
deps.push(parsed);
8993
}
9094
}
@@ -119,7 +123,11 @@ function parseDockerCompose(content: string): ParsedDependency[] {
119123
const parsed = parseImageReference(imageRef);
120124
if (parsed) {
121125
// Avoid duplicates
122-
if (!deps.some((d) => d.name === parsed.name && d.version === parsed.version)) {
126+
if (
127+
!deps.some((d) =>
128+
d.name === parsed.name && d.version === parsed.version
129+
)
130+
) {
123131
deps.push(parsed);
124132
}
125133
}

src/parsers/gradle-groovy.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ const configurations = [
1616
"annotationProcessor",
1717
"kapt",
1818
"ksp",
19-
"compile", // deprecated but still used
20-
"testCompile", // deprecated but still used
21-
"runtime", // deprecated but still used
19+
"compile", // deprecated but still used
20+
"testCompile", // deprecated but still used
21+
"runtime", // deprecated but still used
2222
];
2323

2424
/**
@@ -32,7 +32,7 @@ function parse(content: string): ParsedDependency[] {
3232
// Handles both single and double quotes
3333
const stringNotationRegex = new RegExp(
3434
`(?:${configPattern})\\s*[("']([a-zA-Z0-9._-]+):([a-zA-Z0-9._-]+):([^'"\\s:]+)[)'"]`,
35-
"g"
35+
"g",
3636
);
3737

3838
let match;
@@ -47,7 +47,7 @@ function parse(content: string): ParsedDependency[] {
4747
// Pattern 2: Map notation - implementation group: 'com.example', name: 'lib', version: '1.0'
4848
const mapNotationRegex = new RegExp(
4949
`(?:${configPattern})\\s+group:\\s*['"]([^'"]+)['"]\\s*,\\s*name:\\s*['"]([^'"]+)['"]\\s*,\\s*version:\\s*['"]([^'"]+)['"]`,
50-
"g"
50+
"g",
5151
);
5252

5353
while ((match = mapNotationRegex.exec(content)) !== null) {

src/parsers/gradle-kotlin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function parse(content: string): ParsedDependency[] {
2828
// Pattern: implementation("group:artifact:version")
2929
const funcNotationRegex = new RegExp(
3030
`(?:${configPattern})\\s*\\(\\s*["']([a-zA-Z0-9._-]+):([a-zA-Z0-9._-]+):([^"'\\s:]+)["']\\s*\\)`,
31-
"g"
31+
"g",
3232
);
3333

3434
let match;

0 commit comments

Comments
 (0)