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

moka-email

v0.11.26

Published

[![react](https://img.shields.io/badge/react-v16-blue)](https://reactjs.org/) [![lingui](https://img.shields.io/badge/lingui-v1-blue)](https://lingui.js.org/) [![babel](https://img.shields.io/badge/babel-v7-yellow)](https://babeljs.io/) [![express](https:

Downloads

4

Readme

moka-email

react lingui babel express

current version: v0.11.26

可视化文档

master branch的docs目录

Change Log

CHANGELOG

用法

  1. 安装依赖
npm install git+ssh://[email protected]:TryMoka/moka-email#v0.11.26
  1. 跑国际化(首次启动前需要跑国际化)
npm run lingui:extract
npm run lingui:compile
  1. 启动
npm run dev

使用场景I:使用邮件组件在前端展示

邮件组件位于lib/toXXX/目录下,需要按如下方式引入(这样可以确保只打包需要的js)

import CancelInterviewEmail from 'moka-email/lib/toApplication/CancelInterviewEmail';

<CancelInterviewEmail
  application={application}
  hr={hr}
/>

使用场景II:指定使用某个邮件组件(不渲染,例如告诉消息网关要发送哪个邮件)

import { TO_APPLICATION_INTERVIEW_SATISFACTION_EMAIL } from 'moka-email/emails';

sendEmail({ emailKey: TO_APPLICATION_INTERVIEW_SATISFACTION_EMAIL, emailProps });

使用场景III:在后端渲染邮件

import { renderEmail } from 'moka-email/ssr';
import { TO_APPLICATION_INTERVIEW_SATISFACTION_EMAIL } from 'moka-email/emails';

const html = renderEmail({
  emailKey: TO_APPLICATION_INTERVIEW_SATISFACTION_EMAIL,
  locale,
  props,
});

开发相关

如何查看邮件版本?

build之后的emails.js里有version信息,此外渲染出来的邮件的某个table标签里隐藏了一个class name(比如叫moka-email-0.5.7),标记了该邮件的版本。

一些约定

  1. 邮件组件位于lib/toXXXX/目录下,例如toApplication,表示发送给申请候选人的邮件。添加邮件组件时,请务必遵从这个约定。
  2. 邮件组件的名称必须以Email结尾,例如XXXXXEmail.js,非Email结尾的文件将不会被识别为邮件组件。
  3. 所有邮件必须有对应的markdown文档(与组件同名的.md文件)

如何开发

邮件很特殊,只能使用传统的table结构布局,只能使用inline style,此外还有其他诸多限制,不同邮件客户端的支持情况也不一样.一个经验法则是,如果outlook显示没有问题了,那应该就没有问题了(就像兼容IE那样)。有许多邮件html validator,比如这个

common目录下有若干已经定义好的基本组件,禁止在邮件中直接出现div,p,table等tag,请使用common组件.

开发过程中,可以执行npm run dev实时看到邮件组件的渲染样式。

执行npm run test跑UT(如果UT失败,请确认是否正常,如果是正常改动,则可以执行 npm run test -- -u 修复snapshot)

新feature禁止直接向master push,必须走PR。

如何添加国际化的翻译

  1. 执行npm run lingui:extract提取最新的待翻译文本
  2. 找到src/locales/message.csv文件,补充翻译文本
  3. 执行npm run lingui:compile编译翻译文本

如何发布

  1. 执行npm run test确保UT通过

  2. 整理上个版本至今的所有PR,更新CHANGELOG.md

  3. 运行npm run pre-release, 生成pre-release的mr

  4. 再把mr合并进master后, 运行npm run release

改动了邮件内容如何测试

有两种测试邮件的方法,一种是本地发邮件出去看看效果,另一种是发布测试包然后更新pigeon依赖

本地发邮件:

  1. 在项目根目录下新建一个config.mailer.json的json文件,文件内容如下:
{
  "email": "[email protected]",
  "password": "your email password"
}

目前仅支持腾讯企业邮箱

  1. npm run dev然后在每个邮件下方有一个“发送测试邮件”,点击即可发送

具体逻辑是用配置中的账号密码登录,然后向该邮箱发送测试邮件

发布测试包

  1. 执行npm run release-test发布一个测试版本,脚本执行结束后会在屏幕中打印出测试版本的安装路径,记下这个,例如:
测试版本发布完成,可以使用如下方式安装测试依赖
npm install git+ssh://[email protected]:TryMoka/moka-email#v0.11.26
  1. 把测试版本的安装地址告诉pigeon的维护者,让他更新pigeon依赖的moka-email(staging环境的pigeon)

  2. staging环境的pigeon更新完成后,就可以测试了

Roadmap

  1. 去掉邮件中的链接拼接,改为从外部直传(每周少量更改便于回归)
  2. 去掉邮件中依赖的第三方常量(每周少量更改便于回归)
  3. 优化部署脚本,现在脚本不是原子的,中间某个步骤失败会导致部署一半(比如tag打上了,但是没有push上去之类的)