Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
react-dep-analyzer
Advanced tools
這是一個用於分析 React/TypeScript 專案中元件依賴關係和使用情況的工具。它可以幫助你:
npm install react-dep-analyzer
// ESM
import { createAnalyzer } from '@litaichung/react-dep-analyzer';
// CommonJS
const { createAnalyzer } = require('@litaichung/react-dep-analyzer');
// 使用預設配置建立分析器
const analyzer = createAnalyzer();
// 執行分析
analyzer.run();
// 生成 Markdown 報告
analyzer.generateMarkDown();
// 生成依賴樹圖
analyzer.generateDependencyTree();
你可以透過傳入配置物件來自定義分析器的行為:
interface ComponentPathConfig {
path: string; // 元件目錄路徑
importPrefix: string; // import 語句的前綴
}
const analyzer = createAnalyzer({
name: 'Component', // 分析報告的標題名稱
targetPath: 'src/components', // 要分析的元件目錄
pagesPath: 'src/pages', // 頁面檔案目錄
fileExtensions: ['.tsx'], // 要分析的檔案副檔名
componentPaths: [ // 元件搜尋路徑配置
{
path: 'src/components',
importPrefix: '@/components'
},
{
path: 'src/elements',
importPrefix: '@/elements'
}
],
outputDir: 'tools/usageAnalyzer', // 輸出目錄
exportNamePattern: /^[A-Z]/, // 元件名稱匹配模式(預設匹配大寫開頭)
});
工具內建以下預設配置:
const defaultConfig = {
name: 'Component',
targetPath: 'src/components',
pagesPath: 'src/pages',
fileExtensions: ['.tsx'],
componentPaths: [
{
path: 'src/components',
importPrefix: '@/components'
},
{
path: 'src/elements',
importPrefix: '@/elements'
}
],
outputDir: 'tools/usageAnalyzer',
exportNamePattern: /^[A-Z]/,
};
# Component Dependencies and Usage
- Button (src/components/Button.tsx)
Dependencies:
- @/elements/Icon (src/elements/Icon.tsx)
Imports: Icon
Used in pages:
- src/pages/home.tsx
- src/pages/about.tsx
- Card (src/components/Card.tsx)
Dependencies:
- @/components/Button (src/components/Button.tsx)
Imports: Button
Used in pages:
- src/pages/products.tsx
工具會生成一個使用 Mermaid 語法的依賴樹圖,可以直接在支援 Mermaid 的 Markdown 檢視器中顯示(如 GitHub)。
flowchart TD
Button["Button"]
Card["Card"]
Icon["Icon"]
Button --> Icon
Card --> Button
Button --> page_home["home"]
Button --> page_about["about"]
Card --> page_products["products"]
.tsx
檔案的分析,可透過配置擴展支援其他檔案類型MIT
FAQs
分析 React 元件依賴關係和使用情況的工具
The npm package react-dep-analyzer receives a total of 47 weekly downloads. As such, react-dep-analyzer popularity was classified as not popular.
We found that react-dep-analyzer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.