@edgeone/framework-detect

中文文档
0.2.0发布于 2025/12/29ISCTypeScriptESM + CJS近 30 天下载 1.6万

A framework detection library for web projects

原始使用文档
文档目录10 节
  1. 安装
  2. 使用方法
  3. 本地检测
  4. 远程仓库检测
  5. API
  6. describeFramework(projectRoot: string): Promise<FrameworkIn…
  7. describeFrameworkRemote(body: GitProviderBody, auth?: any):…
  8. 支持的框架
  9. 支持的 Git 平台
  10. 开发

framework-detect

一个用于检测 Web 项目框架的 TypeScript 库,支持本地检测和远程仓库检测。

安装

tnpm install @tencent/framework-detect

使用方法

本地检测

import { describeFramework } from '@tencent/framework-detect';

// 检测项目框架
const frameworkInfo = await describeFramework('./my-project');
console.log(frameworkInfo);

远程仓库检测

支持 GitHub、Gitee、GitLab、Bitbucket 四大平台的远程仓库检测。

GitHub

import { describeFrameworkRemote } from '@tencent/framework-detect';

// 公开仓库(无认证,有速率限制)
const result = await describeFrameworkRemote({
  Provider: "Github",
  Namespace: "vercel",
  RepoName: "next.js",
  RootDir: "examples/blog",
});

// 私有仓库(需要 Token)
const result = await describeFrameworkRemote({
  Provider: "Github",
  Namespace: "your-org",
  RepoName: "your-repo",
}, {
  Token: "ghp_xxxxx", // GitHub Personal Access Token
});

Gitee

const result = await describeFrameworkRemote({
  Provider: "Gitee",
  Namespace: "oschina",
  RepoName: "gitee",
}, {
  Token: "your_gitee_token",
});

GitLab

// 支持 gitlab.com 和自建实例
const result = await describeFrameworkRemote({
  Provider: "Gitlab",
  Namespace: "gitlab-org",
  RepoName: "gitlab",
  Branch: "master",
}, {
  Token: "glpat-xxxxx",
  BaseUrl: "https://gitlab.com", // 自建实例请修改此 URL
});

Bitbucket

// Bitbucket Cloud
const result = await describeFrameworkRemote({
  Provider: "Bitbucket",
  Namespace: "atlassian",
  RepoName: "stash-example-plugin",
  Branch: "master",
}, {
  Token: "your_app_password", // App Password 或 OAuth Token
});

// Bitbucket Data Center(自建)
const result = await describeFrameworkRemote({
  Provider: "Bitbucket",
  Namespace: "PROJECT_KEY",
  RepoName: "repo-slug",
}, {
  Token: "your_personal_access_token",
  BaseUrl: "https://bitbucket.example.com",
});

详细的 Bitbucket 集成指南请查看 BITBUCKET_GUIDE.md

API

describeFramework(projectRoot: string): Promise<FrameworkInfo>

检测指定目录中的 Web 项目框架。

参数:

  • projectRoot (string): 项目根目录路径

返回值:

  • Promise<FrameworkInfo>: 框架信息对象

describeFrameworkRemote(body: GitProviderBody, auth?: any): Promise<FrameworkInfo>

检测远程 Git 仓库中的 Web 项目框架。

参数:

  • body (GitProviderBody): 仓库信息
    • Provider: "Github" | "Gitee" | "Gitlab" | "Bitbucket"
    • Namespace: 用户名/组织名/Workspace ID/Project Key
    • RepoName: 仓库名称
    • RootDir?: 根目录(可选)
    • Branch?: 分支名(可选)
  • auth? (any): 认证信息(可选)
    • GitHub: { Token: "ghp_xxxxx" } 或 Octokit 实例
    • Gitee: { Token: "your_token" }
    • GitLab: { Token: "glpat-xxxxx", BaseUrl?: "https://gitlab.com" }
    • Bitbucket: { Token: "your_token", BaseUrl?: "https://api.bitbucket.org" }

返回值:

  • Promise<FrameworkInfo>: 框架信息对象

返回对象结构:

interface FrameworkInfo {
  Framework: string;    // 框架名称
  BuildCmd: string;     // 构建命令
  InstallCmd: string;   // 安装命令
  OutputDir: string;    // 输出目录
  IconPath?: string;    // 图标路径(可选)
}

支持的框架

  • Next.js
  • Gatsby
  • Remix
  • React Router
  • Astro
  • Hexo
  • Eleventy
  • Docusaurus
  • Solid
  • Vue
  • Angular
  • Svelte
  • React
  • Nuxt
  • Qwik
  • Hono
  • Vite

支持的 Git 平台

平台公开仓库私有仓库自建实例认证方式
GitHub✅✅✅Personal Access Token
Gitee✅✅❌Personal Access Token
GitLab✅✅✅Personal Access Token
Bitbucket✅✅✅OAuth 2.0 / App Password / PAT

开发

# 安装依赖
npm install

# 构建
npm run build

# 运行测试
npm run test

# 测试远程检测
bun testRemote.ts

版本与发布记录

@edgeone/framework-detect 共发布 4 个版本,首次发布于 2025/09/04;过去 12 个月发布了 1 个版本。

版本发布日期距今
0.2.0latest2025/12/2910 个月前
0.1.02025/10/271 年前
0.0.22025/09/171.2 年前
0.0.12025/09/041.2 年前

关于 @edgeone/framework-detect 的常见问题

@edgeone/framework-detect 是什么?

A framework detection library for web projects

如何安装 @edgeone/framework-detect?

在项目目录运行 npm install @edgeone/framework-detect,或使用 pnpm add / yarn add / bun add。

@edgeone/framework-detect 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@edgeone/framework-detect 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@edgeone/framework-detect 可以商用吗?

@edgeone/framework-detect 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@edgeone/framework-detect 的下载量有多少?

根据 npm 官方下载统计,@edgeone/framework-detect 在 2026/10/13 – 2026/11/11 这 30 天内被下载 16,101 次,日均约 537 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@edgeone/framework-detect 还在维护吗?

最新版本 0.2.0 发布于 2025/12/29(10 个月前);至今共发布 4 个版本,其中过去 12 个月发布了 1 个;首次发布于 2025/09/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。