Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-dep-analyzer

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dep-analyzer - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

62

dist/index.js

@@ -161,41 +161,46 @@ // src/index.ts

Object.entries(this.targetUsage).forEach(([componentName, data]) => {
output += `## ${componentName} (${data.file})
output += `## ${componentName}
`;
output += `> File Path: \`${data.file}\`
`;
if (data.dependencies.length > 0) {
const componentDeps = data.dependencies.filter((d) => d.path.includes("/components/"));
const elementDeps = data.dependencies.filter((d) => d.path.includes("/elements/"));
const dependencyGroups = this.componentPaths.reduce((groups, pathConfig) => {
const groupName = pathConfig.path.split("/").pop() || "other";
groups[groupName] = data.dependencies.filter(
(d) => d.path.startsWith(pathConfig.importPrefix)
);
return groups;
}, {});
const otherDeps = data.dependencies.filter(
(d) => !d.path.includes("/components/") && !d.path.includes("/elements/")
(d) => !this.componentPaths.some(
(config) => d.path.startsWith(config.importPrefix)
)
);
if (componentDeps.length > 0) {
output += "### Component Dependencies:\n";
componentDeps.forEach((dep) => {
const importsList = dep.imports.join(", ");
output += `- ${dep.path} (${dep.file})
Object.entries(dependencyGroups).forEach(([groupName, deps]) => {
if (deps.length > 0) {
output += `### ${groupName.charAt(0).toUpperCase() + groupName.slice(1)} Dependencies
`;
output += ` Imports: ${importsList}
deps.forEach((dep) => {
const importsList = dep.imports.join(", ");
output += `> - **${dep.path}**
`;
});
output += "\n";
}
if (elementDeps.length > 0) {
output += "### Element Dependencies:\n";
elementDeps.forEach((dep) => {
const importsList = dep.imports.join(", ");
output += `- ${dep.path} (${dep.file})
output += `> - File: \`${dep.file}\`
`;
output += ` Imports: ${importsList}
output += `> - Imports: \`${importsList}\`
`;
});
output += "\n";
}
});
output += "\n";
}
});
if (otherDeps.length > 0) {
output += "### Other Dependencies:\n";
output += "### Other Dependencies\n";
otherDeps.forEach((dep) => {
const importsList = dep.imports.join(", ");
output += `- ${dep.path} (${dep.file})
output += `> - **${dep.path}**
`;
output += ` Imports: ${importsList}
output += `> - File: \`${dep.file}\`
`;
output += `> - Imports: \`${importsList}\`
`;
});

@@ -206,9 +211,10 @@ output += "\n";

if (data.usedInPages.length > 0) {
output += " Used in pages:\n";
output += "### Used in Pages\n";
data.usedInPages.forEach((page) => {
output += ` - ${page}
output += `> - \`${page}\`
`;
});
output += "\n";
}
output += "\n";
output += "---\n\n";
});

@@ -215,0 +221,0 @@ fs.mkdirSync(path.dirname(finalPath), { recursive: true });

{
"name": "react-dep-analyzer",
"version": "1.0.1",
"version": "1.0.2",
"description": "分析 React 元件依賴關係和使用情況的工具",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -233,38 +233,44 @@ import fs from 'fs';

Object.entries(this.targetUsage).forEach(([componentName, data]) => {
output += `## ${componentName} (${data.file})\n\n`;
output += `## ${componentName}\n`;
output += `> File Path: \`${data.file}\`\n\n`;
if (data.dependencies.length > 0) {
// 根據路徑模式分組依賴
const componentDeps = data.dependencies.filter(d => d.path.includes('/components/'));
const elementDeps = data.dependencies.filter(d => d.path.includes('/elements/'));
// 根據 componentPaths 配置來分組依賴
const dependencyGroups = this.componentPaths.reduce((groups, pathConfig) => {
const groupName = pathConfig.path.split('/').pop() || 'other';
groups[groupName] = data.dependencies.filter(d =>
d.path.startsWith(pathConfig.importPrefix)
);
return groups;
}, {} as Record<string, DependencyInfo[]>);
// 其他未匹配的依賴
const otherDeps = data.dependencies.filter(d =>
!d.path.includes('/components/') && !d.path.includes('/elements/')
!this.componentPaths.some(config =>
d.path.startsWith(config.importPrefix)
)
);
if (componentDeps.length > 0) {
output += '### Component Dependencies:\n';
componentDeps.forEach((dep) => {
const importsList = dep.imports.join(', ');
output += `- ${dep.path} (${dep.file})\n`;
output += ` Imports: ${importsList}\n`;
});
output += '\n';
}
// 輸出每個分組的依賴
Object.entries(dependencyGroups).forEach(([groupName, deps]) => {
if (deps.length > 0) {
output += `### ${groupName.charAt(0).toUpperCase() + groupName.slice(1)} Dependencies\n`;
deps.forEach((dep) => {
const importsList = dep.imports.join(', ');
output += `> - **${dep.path}**\n`;
output += `> - File: \`${dep.file}\`\n`;
output += `> - Imports: \`${importsList}\`\n`;
});
output += '\n';
}
});
if (elementDeps.length > 0) {
output += '### Element Dependencies:\n';
elementDeps.forEach((dep) => {
const importsList = dep.imports.join(', ');
output += `- ${dep.path} (${dep.file})\n`;
output += ` Imports: ${importsList}\n`;
});
output += '\n';
}
// 輸出其他依賴
if (otherDeps.length > 0) {
output += '### Other Dependencies:\n';
output += '### Other Dependencies\n';
otherDeps.forEach((dep) => {
const importsList = dep.imports.join(', ');
output += `- ${dep.path} (${dep.file})\n`;
output += ` Imports: ${importsList}\n`;
output += `> - **${dep.path}**\n`;
output += `> - File: \`${dep.file}\`\n`;
output += `> - Imports: \`${importsList}\`\n`;
});

@@ -276,8 +282,10 @@ output += '\n';

if (data.usedInPages.length > 0) {
output += ' Used in pages:\n';
output += '### Used in Pages\n';
data.usedInPages.forEach((page: string) => {
output += ` - ${page}\n`;
output += `> - \`${page}\`\n`;
});
output += '\n';
}
output += '\n';
output += '---\n\n';
});

@@ -284,0 +292,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc