惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
B
Blog RSS Feed
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
Recent Announcements
Recent Announcements
A
About on SuperTechFans
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
Google DeepMind News
Google DeepMind News
S
Schneier on Security
S
Secure Thoughts
T
The Exploit Database - CXSecurity.com
Martin Fowler
Martin Fowler
P
Proofpoint News Feed
Security Latest
Security Latest
Jina AI
Jina AI
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Recorded Future
Recorded Future
T
Tor Project blog
有赞技术团队
有赞技术团队
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
News | PayPal Newsroom
博客园 - 三生石上(FineUI控件)
MyScale Blog
MyScale Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
Forbes - Security
Forbes - Security
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
NISL@THU
NISL@THU
C
Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Google DeepMind News
Google DeepMind News
Project Zero
Project Zero
IT之家
IT之家
T
Threatpost
Cyberwarzone
Cyberwarzone
O
OpenAI News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
J
Java Code Geeks
P
Proofpoint News Feed
The Last Watchdog
The Last Watchdog
月光博客
月光博客
Latest news
Latest news
MongoDB | Blog
MongoDB | Blog
Apple Machine Learning Research
Apple Machine Learning Research

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
How I Built an Automated JS/TS Repository Analyzer in C#
David Arno · 2026-04-24 · via DEV Community

TL;DR

I built the JavaScript/TypeScript analysis engine for the Silverfish IDP — an Internal Developer Portal that automatically detects packaging tools, identifies component types, and extracts complete dependency graphs from repos. It handles monorepos, multiple lock file formats, and mixed JS/TS codebases—all without making assumptions about repo structure.

The Problem

At Silverfish Software, we're building an IDP that helps individual developers and engineering teams understand their entire codebase. But when you have hundreds of repositories spanning multiple languages, frameworks, and tools, how do you automatically make sense of it all?

For JavaScript and TypeScript repos specifically, the challenge is significant: every repo is different. Some use Yarn, others npm or pnpm. Some have monorepos with nested package.json files. Some mix JavaScript and TypeScript. Some have multiple lock files checked in (a real mess). And some don't have lock files at all.

I needed an analyzer that could handle all these cases automatically, with no manual configuration. No "please tell us which package manager you use" questions. Just point it at a repo and get back structured metadata about components, dependencies, and versions.

Step 1: Detect the Packaging Tool
The naive approach: Check if yarn.lock exists → use Yarn. Check if package-lock.json exists → use npm.

Reality is messier:

// Priority order matters
1. Check packageManager field in package.json ("yarn@4.1.0")
2. Look for lock files (yarn.lock, pnpm-lock.yaml, package-lock.json, bun.lock)
3. Check config files (.yarnrc.yml, pnpm-workspace.yaml)
4. Default to npm

Enter fullscreen mode Exit fullscreen mode

The packageManager field was the key insight—it's set by corepack and is the source of truth. If it says Yarn, it's Yarn, even if npm somehow created a lock file too.

I also had to handle conflicts: I found real repos with both yarn.lock and package-lock.json checked in. My solution? Detect all of them, report the conflict, and parse only the highest-priority one.

public static async Task<PackagingToolDetectionResult> DetectAsync(
    IReadOnlyCollection<string> repoPaths,
    Func<string, Task<string?>> readFileContentAsync)
{
    // 1. Check packageManager field first
    var fromPackageManager = await TryDetectFromPackageManagerFieldAsync(...);
    if (fromPackageManager is not null) return fromPackageManager;

    // 2. Check lock files
    var fromLockFile = TryDetectFromLockFiles(...);
    if (fromLockFile is not null) return ...;

    // 3. Check config files
    var fromConfigFile = TryDetectFromConfigFiles(...);
    if (fromConfigFile is not null) return ...;

    // 4. Default to npm
    return new(PackagingTool.Npm, true);
}

Enter fullscreen mode Exit fullscreen mode

Result: (PackagingTool.Yarn, LockFileNeedsGenerating: false) or similar.

Step 2: Identify Components and Their Type
Each package.json is a component. But what kind? And what does it do?

I classified each one into: Package (published to npm), Library (internal or private), and determined usage: Frontend, Backend, Fullstack, or Unknown.

The key was looking at dependencies:

static readonly HashSet<string> FrontendSignals = new() 
{ 
    "react", "vue", "@angular/core", "svelte", "react-router", "redux", ...
};

static readonly HashSet<string> BackendSignals = new()
{
    "express", "koa", "mongoose", "pg", "apollo-server", "prisma", ...
};

// If a package depends on react + express = fullstack
// If only react = frontend
// If only express = backend

Enter fullscreen mode Exit fullscreen mode

I also extracted language info:

// Pure JS? Check for no TypeScript signals
// TypeScript? Look for typescript pkg + @types/*
// Mixed? Has flow-bin + typescript OR tsconfig.json's allowJs = true

Enter fullscreen mode Exit fullscreen mode

And pulled in version constraints:

// Node version: from engines.node in package.json or .nvmrc file
// TS version: from devDependencies
// ECMAScript target: from tsconfig.json compilerOptions

Enter fullscreen mode Exit fullscreen mode

Result: A JsComponent record with all metadata attached—used by Silverfish's dashboard to display component details instantly.

Step 3: Parse Lock Files (The Hard Part)
This was the gnarly part. Four different formats, each with quirks.

Yarn Lock (v1 Classic)
Looks like TOML with nested dependency lists:

"@pkgjs/parseargs@^0.11.0":
  version "0.11.0"
  resolved "https://registry.npmjs.org/..."
  dependencies:
    package-json "^6.0.0"

Enter fullscreen mode Exit fullscreen mode

I wrote a line-by-line parser. The trick: track indentation to know when you're inside a package block vs. dependency list.

npm package-lock.json
Flat JSON structure (v2/v3):

{
  "packages": {
    "node_modules/lodash": {
      "version": "4.17.21",
      "dependencies": { ... }
    }
  }
}

Enter fullscreen mode Exit fullscreen mode

Easier to parse with JsonDocument, but the key names have node_modules/ prefixes that need stripping.

pnpm-lock.yaml
YAML with name@version keys:

packages:
  /lodash/4.17.21:
    version: 4.17.21
    dependencies:
      react: 18.2.0

Enter fullscreen mode Exit fullscreen mode

I treated this as mostly line-based text parsing since I didn't want to add a full YAML dependency. Works for the common cases.

Bun Lock
JSONC format with array-based entries. Least common, so I parse it but mark binary bun.lockb files as unparseable.

Step 4: Resolve Dependencies
Once I had a parsed lock file, I needed to extract:

  • Local dependencies (internal workspace packages like @company/shared)
  • Direct dependencies (what's explicitly in package.json)
  • Transitive dependencies (what your dependencies need)
// Read package.json dependencies
var directRanges = ReadDirectDependencyRanges(packageJsonContent);

// For each direct dep, look it up in the lock file
foreach (var (name, range) in directRanges)
{
    var pkg = Resolve(name, range, parsedLock);
    if (pkg != null)
    {
        // It's resolved to version X.Y.Z
        direct.Add(new ResolvedDependency(pkg.Name, pkg.Version, range));

        // Queue it to traverse its dependencies
        queue.Enqueue(pkg);
    }
}

// Depth-first traversal to collect transitives
while (queue.TryDequeue(out var pkg))
{
    foreach (var (depName, depRange) in pkg.DependencyRanges)
    {
        var dep = Resolve(depName, depRange, parsedLock);
        if (dep != null && !visited.Contains($"{dep.Name}@{dep.Version}"))
        {
            transitive.Add(...);
            queue.Enqueue(dep);
        }
    }
}

Enter fullscreen mode Exit fullscreen mode

Result: Three lists of ResolvedDependency objects with exact versions and requested ranges. The Silverfish dashboard uses this to build the full dependency graph in its UI.

Step 5: Handle Monorepos
Monorepos have multiple package.json files. The key insight: walk up the directory tree to find the root lock file.

static IEnumerable<string> AncestorDirs(string dir)
{
    var current = dir;
    while (true)
    {
        yield return current;
        if (string.IsNullOrEmpty(current)) break;
        current = Path.GetDirectoryName(current);
    }
}

Enter fullscreen mode Exit fullscreen mode

So packages/web/package.json in an entria-style monorepo correctly finds the root yarn.lock instead of failing. Each workspace member gets its own component record in Silverfish.

How Silverfish Uses This
Once the analyzer extracts all this metadata, Silverfish:

  • Maps dependencies visually — showing which components depend on what Flags version mismatches — when different packages pin different versions of the same library
  • Detects tech stacks — knowing which services are frontend, which are backend, which databases they use
  • Tracks upgrades — identifying outdated packages and planning coordinated updates
  • Enables governance — enforcing policies like "no direct jquery dependencies" or "all frontends must use React 18+"

Lessons Learned

  • Format-specific parsing is worth it: I could have given up on Yarn/pnpm/Bun and only parsed npm lock files. But each format's parser is ~100-150 lines and handles real repos that exist in the wild.

  • Conflicts are data, not errors: Instead of failing when I find multiple lock files, I report them. That's valuable information ("why do you have both yarn.lock and package-lock.json?").

  • Monorepos are normal: Walking ancestor directories for lock files + detecting internal workspace packages turned out to be essential, not an edge case.

  • Version constraints matter: Storing both the requested range (^1.2.3) and resolved version (1.2.5) proved useful—you can detect upgradeable deps without breaking changes.

What's Next
The JS/TS analyzer is one piece of Silverfish's language support. I'll building similar analyzers for Python, Go, Java, and other ecosystems. The pattern is the same: detect the package manager, identify components, resolve dependencies, extract versions.

If you're trying to understand complex multi-language codebases at scale, this approach should help. The code is C# 14 with only standard library dependencies—no bloat.

Check out the Silverfish Dashboard to see the analyzer in action, or hit me up if you have questions about the implementation.