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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@finclip/applet-builder-ci

v3.0.10

Published

`@finclip/applet-builder-ci` 是一个 Node.js 库,提供了与编译、上传、审核和发布小程序相关的功能。该库的目标是简化小程序开发和部署的流程。

Downloads

33

Readme

使用指南

@finclip/applet-builder-ci 是一个 Node.js 库,提供了与编译、上传、审核和发布小程序相关的功能。该库的目标是简化小程序开发和部署的流程。

安装和使用

首先,确保你的 Node.js 环境已经安装了所需的依赖,包括 @finclip/applet-builder-ci 库。你可以使用以下命令来安装这个库:

npm install @finclip/applet-builder-ci

然后,你可以使用 @finclip/applet-builder-ci 提供的功能。

示例

小程序编译到发布流程

const { Project } = require("@finclip/applet-builder-ci");
(async () => {
  // 项目配置
  const projectConfig = {
    appid: "your_app_id", // 你的小程序AppID
    projectPath: "your_project_path", // 你的小程序项目路径
    output: "output_directory", // 编译结果的输出目录
    userInfo: {
      openAPISecret: "your_api_secret", // 你的OpenAPI密钥
      url: "your_server_url", // 你的服务器URL
    },
  };

  const myProject = new Project(projectConfig);

  // 编译配置
  const buildOptions = {
    zip: true, // 是否输出 zip 包
    obfuscate: true, // 是否做代码混淆
    DSL: {
      // 控制文件后缀名与前缀
      alias: [],
      prefix: "ft", // wx.修改为ft
      wxml: "fxml", // .wxml为.fxml
      wxss: "ftss",
      wxs: "fts",
      finClipConf: "FinClipConf.js",
    },
    modifyCss: {
      // 替换全局样式: modifyCss.md
      builtCss: [],
    },
    exclude: [], //打包时需要忽略的目录与文件 支持glob与正则
    trimText: false, //单行文本内容不换行
    compileSettings: {
      es6: true, // es6转es5
      minify: true, // 上传时自动压缩脚本
      minifyWXSS: true, // 上传时自动压缩样式
      autoPrefixWXSS: true, // 上传时样式自动补全
      sourceMap: true, // 开启 sourceMap
    },
  };
  // 编译小程序
  await myProject.build(buildOptions);
  console.log("小程序编译完成");
  /**
   * 一键发布
   * @param {string} version 版本号
   * @param {string} versionDesc 版本描述 不能为空,否则会造成签名失败
   */
  const response = await myProject.publish("0.0.1", "version_desc");
  console.log("发布成功:", response);
})();

一键发布

一键发布主要做了三个事情:上传代码 -> 提交审核 -> 审核并发布

一般推荐使用上面代码的myProject.publish接口直接发布,如果需要对每个步骤进行分别操作,则可以参考下面的示例:

(async () => {
  const myProject = new Project(projectConfig);
  /**
   * 上传小程序
   * @param {string} version 版本号
   * @param {string} desc 版本描述 不能为空,否则会造成签名失败
   */
  const uploadData = await myProject.upload("0.0.1", "version_desc");
  /**
   * 提交审核
   * @param {string} miniAppCompiledPackageId 小程序编译包ID,由上传接口返回
   * @param {boolean} autoPub 审核通过后是否自动发布
   */
  const submitAuditData = await myProject.submitAudit(uploadData.miniAppCompiledPackageId, true);
  /**
   * 审核并发布
   * @param {string} miniAppAuditId 小程序审核ID,由提交审核接口返回
   * @param {boolean} pass 是否通过
   * @param {string} reason 驳回原因
   */
  await myProject.audit(submitAuditData.miniAppAuditId, pass, reason);
})();

构建 npm

const { packNpm } = require("@finclip/applet-builder-ci");
(async () => {
  /**
   *
   * @param {string} project - 小程序路径
   * @param {Object} options - 编译参数
   * @param {[string]} options.ignores - 指定构建npm需要排除的规则
   * @param {string} options.reporter - 构建回调信息
   * @returns Promise
   */
  // 在有需要的时候构建npm
  await packNpm(project, {
    ignores: ["pack_npm_ignore_list"],
    reporter: (infos) => {
      console.log(infos);
    },
  });
})();

自定义 node_modules 位置的构建 npm

const { packNpmManually } = require("@finclip/applet-builder-ci");
(async () => {
  /**
   *
   * @param {Object} options - 编译参数
   * @param {string} options.packageJsonPath - 希望被构建的node_modules 对应的 package.json 的路径
   * @param {string} options.miniprogramNpmDistDir - 被构建 miniprogram_npm 的输出目标位置
   * @param {[string]} options.ignores - 指定需要排除的规则
   * @returns Promise
   */
  // 在有需要的时候构建npm
  await packNpmManually({
    packageJsonPath: "./lib/package.json",
    miniprogramNpmDistDir: "./miniprogram-project/miniprogram/",
  });
})();