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-deploy

v1.2.9

Published

阿里云函数计算自动部署

Downloads

30

Readme

fc-deploy

阿里云函数计算自动部署

安装

npm i fc-deploy

使用

import { deploy } from "fc-deploy";
/** 一组函数名称 */
const funcs = [
  "chat",
  "msgfile",
  "msgfile_large",
  "recog",
  "group",
  "wemeeting",
] as const;

deploy({
  /** 项目名称 */
  name: "wecom-chat",
  /** 可选:自定义 node_modules 路径(默认 cwd/node_modules) */
  nodeModulesPath: path.resolve(process.cwd(), "node_modules"),
  /** FC客户端设置 */
  fcConfigs: funcs.map((f) => ({
    accessKeyId: process.env.ALIYUN_ACCESS_KEY!,
    accessKeySecret: process.env.ALIYUN_SECRET_ACCESS_KEY!,
    fcEndpoint: "xxxxxxxx.cn-beijing.fc.aliyuncs.com",
    fcRegionId: "cn-beijing",
    fcFunction: f,
    fcService: "服务名称",
  })),
  /** 层设置 */
  layerConfig: {
    layerName: "wecom-chat",
    /** 层描述 */
    layerDescription: "",
    /** 层兼容哪些运行时 */
    compatibleRuntime: ["nodejs20"],
    /** 定义如何获取各个函数的依赖hash */
    getHash: async (params) => {
      const redis = getUpstashRedis("dk");
      const data = await redis.get<string>(`fcd:hash:${params.funcName}`);
      return data || "";
    },
    /** 定义如何设置hash */
    setHash: async (params) => {
      const redis = getUpstashRedis("dk");
      const res = await redis.set(`fcd:hash:${params.funcName}`, params.hash);
      if (res !== "OK") {
        console.error("upstash redis cache error: " + res);
      }
    },
    /** 需要监控哪些依赖变化,可以同时监控多个依赖,任意一个变化了,都会重新创建层 */
    packageJsonLists: [
      path.resolve(process.cwd(), "package.json"),
      path.resolve(
        process.cwd(),
        "node_modules/@myrog/mylib/package.json",
      ),
    ],
  },
  /** oss配置,用来上传层文件。 */
  ossConfig: {
    accessKeyId: process.env.ALIYUN_ACCESS_KEY!,
    accessKeySecret: process.env.ALIYUN_SECRET_ACCESS_KEY!,
    bucket: "your_bucket",
    region: "oss-cn-beijing",
  },
  /** 日志回调 */
  cbLog(msg) {
    console.log(msg);
    const fsClient = getFeishuClient();
    return fsClient.im.message.create({
      params: {
        receive_id_type: "chat_id",
      },
      data: {
        msg_type: "text",
        receive_id: process.env.FEISHU_CHAT_ID!,
        content: JSON.stringify({
          text: msg,
        }),
      },
    });
  },
});

### 依赖哈希规则(触发层重建)

- 会对 `packageJsonLists` 中的所有 `package.json` 文件完整内容做排序、合并并生成哈希,换行符会被规范化以保证跨平台一致性。
- 同时会把当前项目根目录的 `package.json` 版本号一并纳入哈希计算;版本变化也会触发新的层构建。
- 任何一个被监控的 `package.json` 内容或项目版本发生变化,都会视为依赖变更,从而重新创建层。

### 环境变量

#### DEBUG_FCD

设置 `DEBUG_FCD=1` 可以开启详细的调试日志输出,用于排查部署过程中的问题。

```bash
DEBUG_FCD=1 node deploy.js

阿里云凭证(示例代码中使用)

示例代码中使用了以下环境变量来配置阿里云服务:

  • ALIYUN_ACCESS_KEY - 阿里云 AccessKey ID
  • ALIYUN_SECRET_ACCESS_KEY - 阿里云 AccessKey Secret
  • FEISHU_CHAT_ID - 飞书群聊 ID(用于日志回调通知)

这些变量仅在示例代码中使用,实际使用时可根据需要自行配置。