
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
universal-code-extractor
Advanced tools
一个智能的多框架代码提取工具,支持 React、Vue 等框架,可以自动分析项目结构,识别组件依赖关系,并提取完整的组件代码及其依赖。
@/、~/ 等常见路径别名# 全局安装
npm install -g universal-code-extractor
# 或者本地安装
npm install universal-code-extractor
git clone https://github.com/yu1596882018/universal-code-extractor.git
cd universal-code-extractor
npm install
# 查看帮助
node src/index.js help
# 列出项目中所有可用组件
node src/index.js list
# 提取指定组件(自动检测框架)
node src/index.js extract 组件名
# 指定框架类型
node src/index.js extract 组件名 --framework react
node src/index.js extract 组件名 --framework vue
# 列出 React 组件
node src/index.js list --framework react --project ./my-react-app
# 提取 React 组件
node src/index.js extract UserProfile --framework react --output ./extracted
# 列出 Vue 组件
node src/index.js list --framework vue --project ./my-vue-app
# 提取 Vue 组件
node src/index.js extract UserCard --framework vue --output ./extracted
# 自动检测并提取
node src/index.js extract MyComponent --project ./my-project
# 仅检测框架类型
node src/index.js detect --project ./my-project
src/
├── index.js # 主入口和命令行接口
├── base-extractor.js # 基础提取器(通用逻辑)
└── adapters/
├── index.js # 适配器注册和工厂
├── base-adapter.js # 适配器基类(接口定义)
├── react-adapter.js # React 适配器
└── vue-adapter.js # Vue 适配器
创建新适配器只需继承 BaseAdapter 并实现必要方法:
const BaseAdapter = require('./base-adapter');
class AngularAdapter extends BaseAdapter {
constructor() {
super();
this.name = 'angular';
this.displayName = 'Angular';
}
getSupportedExtensions() {
return ['.ts', '.component.ts', '.html'];
}
getComponentPatterns(componentName) {
return [
new RegExp(`@Component.*${componentName}`, 'i'),
// ...更多模式
];
}
// 实现其他必要方法...
}
module.exports = AngularAdapter;
然后在 adapters/index.js 中注册:
const adapters = {
react: ReactAdapter,
vue: VueAdapter,
angular: AngularAdapter // 添加新适配器
};
| 选项 | 说明 | 默认值 |
|---|---|---|
--project | 项目路径 | 当前目录 |
--output | 输出路径 | ./extracted |
--framework | 框架类型 | 自动检测 |
| 命令 | 说明 |
|---|---|
list | 列出所有可用组件 |
extract <组件名> | 提取指定组件 |
extract-page <页面名> | 提取指定页面 |
detect | 检测项目框架 |
frameworks | 列出支持的框架 |
help | 显示帮助信息 |
MIT License
欢迎提交 Issue 和 Pull Request 来改进这个工具!
src/adapters/ 下创建新的适配器文件BaseAdapter 并实现所有抽象方法adapters/index.js 中注册适配器祝您使用愉快!🎉
FAQs
通用代码提取工具,支持 React、Vue 等多种框架的组件提取与依赖分析
We found that universal-code-extractor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.