npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fc-code

v1.0.0

Published

FC程序开发cli工具

Readme

fc-code

FC 程序开发 CLI 工具。全局安装后提供独立命令,例如 fc-uniapp-x、fc-admin-vue3。

npm i -g fc-code

使用

fc-uniapp-x                 # 交互式初始化项目
fc-uniapp-x --force         # 覆盖已有非空目录

fc-uniapp-x i               # 列出可安装模块
fc-uniapp-x i i18n          # 安装 i18n 模块,并按接口执行文件补丁
fc-uniapp-x i i18n -f       # 覆盖已存在的模块文件
fc-uniapp-x uninstall i18n  # 卸载 i18n:还原补丁并删除指定文件/目录

fc-uniapp-x source          # 查看当前安装源
fc-uniapp-x source github   # 切换到 GitHub 地址
fc-uniapp-x source gitee    # 切换回 Gitee 地址

执行 fc-uniapp-x 或 fc-admin-vue3 时会进入交互:

  1. 输入项目名称(只能包含字母、数字、下划线和短横线)
  2. 选择需要安装的模块(↑/↓ 切换,空格选择,回车确认)

确认后会 clone 仓库、将 package.json 的 name 改为项目名,并按所选模块请求接口写入文件、执行安装补丁。完成后提示:

已创建项目:xxx
接下来可以:
  使用 HBuilderX 运行项目    # fc-uniapp-x
  cd xxx                   # fc-admin-vue3
  pnpm i && pnpm dev       # fc-admin-vue3

fc-admin-vue3 的模块安装 / 卸载、切换安装源命令用法相同。

source 的选择会写到本机 ~/.fc-cli.json,之后初始化项目会 clone 当前源对应的仓库。地址在 src/config/kits.ts 的 source.repos 里配置,例如:

source: {
  default: 'gitee',
  repos: {
    gitee: 'https://gitee.com/xxx/fc-uniapp-x.git',
    github: 'https://github.com/xxx/fc-uniapp-x.git',
  },
}

本地测试

在项目根目录执行:

npm i
npm run build
npm link

npm link 会把本地包挂到全局,之后任意目录都能用:

fc-uniapp-x --help
fc-uniapp-x
fc-uniapp-x i
fc-uniapp-x i i18n
fc-uniapp-x uninstall i18n
fc-admin-vue3 --help

不想挂全局时,也可以直接跑入口:

node bin/fc-uniapp-x.js --help
node bin/fc-uniapp-x.js i
node bin/fc-uniapp-x.js i i18n
node bin/fc-admin-vue3.js

改 TypeScript 后要先编译再测。CLI 读的是 dist/,不是 src/。调试时可开监听:

npm run dev

测完取消全局链接:

npm unlink -g fc-code

新建命令

新增类似 fc-uniapp-x、fc-admin-vue3 的全局命令,按下面 3 步操作。三者的命令名必须一致。

1. 注册脚手架

在 src/config/kits.ts 的 kits 数组中增加一项:

{
  name: 'fc-xxx', // 全局命令名
  description: 'XXX 项目脚手架',
  source: {
    default: 'gitee',
    repos: {
      gitee: 'https://gitee.com/xxx/fc-xxx.git',
      github: 'https://github.com/xxx/fc-xxx.git',
    },
    branch: 'main', // 可选
  },
  modules: [],
  nextSteps: (projectName) => [`cd ${projectName}`, 'pnpm i && pnpm dev'],
}

name 就是用户在终端输入的命令。无参数执行该命令时会进入交互:询问项目名称、选择模块,然后 clone 当前安装源对应的仓库。nextSteps 用于初始化完成后的提示。

2. 增加入口文件

复制 bin/fc-uniapp-x.js,改名为新命令,例如 bin/fc-xxx.js。文件内容不用改:

#!/usr/bin/env node
require('../dist/cli').runFromBin(__filename);

CLI 会用文件名识别对应的 kit。

3. 登记到 package.json

在 package.json 的 bin 字段中增加:

{
  "bin": {
    "fc-uniapp-x": "bin/fc-uniapp-x.js",
    "fc-admin-vue3": "bin/fc-admin-vue3.js",
    "fc-xxx": "bin/fc-xxx.js"
  }
}

改完后执行 npm run build。本地可用 npm link 验证新命令。

新增模块

模块挂在某个脚手架下,例如 fc-uniapp-x i i18n。

在对应 kit 的 modules 数组中增加一项:

{
  name: 'fc-uniapp-x',
  description: 'UniApp X 项目脚手架',
  source: {
    default: 'gitee',
    repos: {
      gitee: '',
      github: '',
    },
  },
  modules: [
    {
      name: 'i18n',              // 对应命令:fc-uniapp-x i i18n
      description: '多语言',
      url: 'https://xxx.com/api/modules/i18n',
    },
    {
      name: 'request',           // 对应命令:fc-uniapp-x i request
      description: '网络请求模块',
      url: 'https://xxx.com/api/modules/request',
    },
  ],
  nextSteps: () => ['使用 HBuilderX 运行项目'],
}

只改配置即可,不必改命令注册逻辑。url 是模块接口地址,执行 fc-uniapp-x i <name> 或 fc-uniapp-x uninstall <name> 时会请求该接口。

安装/卸载的文件操作配方放在接口里,由 CLI 在本地执行。 这样新增模块或改行号时,只改接口,不用发版 CLI。

接口推荐返回:

{
  "code": 200,
  "msg": "success",
  "data": {
    "files": [
      {
        "path": "modules/i18n/index.ts",
        "content": "文件中的内容"
      }
    ],
    "install": {
      "patches": [
        {
          "path": "fcuni/index.ts",
          "uncommentLines": [10, 20, 30]
        }
      ]
    },
    "uninstall": {
      "remove": ["modules/i18n", "fcuni/i18n"],
      "patches": [
        {
          "path": "fcuni/index.ts",
          "commentLines": [10, 20, 30]
        }
      ]
    }
  }
}

含义:

  • files:安装时写入的文件
  • install.patches:写入成功后,对已有文件做行级操作。uncommentLines 去掉该行注释 //,commentLines 给该行加上 //
  • uninstall.remove:卸载时删除的文件或目录
  • uninstall.patches:卸载时还原文件。若不填,会按安装补丁自动反向(去掉注释的行再加回去)
  • 行号从 1 开始,对应编辑器中的行号

兼容旧格式:data 仍可以是 [{ path, content }]。此时安装只写文件;卸载会删除这些 path。没有补丁信息。

CLI 会在当前命令行目录(初始化时是项目目录)执行写入、补丁和删除。path 必须是相对路径,不能跳出项目目录。code 必须为 200。

新增子命令

init、i、uninstall 等子命令对所有脚手架共用。若要新增如 update 的子命令:

  1. 在 src/commands/ 下新增文件并导出 registerXxx
  2. 在 src/commands/index.ts 的 commandRegistrars 中追加

新子命令会自动挂到每一个全局命令上。