@email-kit/cli 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +117 -17
  2. package/dist/cli.js +1 -1
  3. package/package.json +6 -6
package/README.md CHANGED
@@ -1,25 +1,125 @@
1
- # @email-kit/cli
1
+ # email-kit
2
2
 
3
- The `email-kit` command: set up a project, compile TSX email templates to HTML and plain text,
4
- and check them against email-client, accessibility and copy rules.
3
+ Type-safe email templates for TypeScript backends. Write the emails your app sends in TSX with
4
+ themed, email-safe components. `email-kit compile` turns them into a small typed module your server
5
+ imports, and `email-kit check` checks every one for email clients, dark mode, accessibility and
6
+ copy.
5
7
 
6
- > **1.0.** Stable for transactional email. Not yet: marketing email
7
- > (unsubscribe links, multi-column layouts), testing in real email clients (classic Outlook
8
- > especially), and the preview studio. See [what 1.0
9
- > covers](https://github.com/email-kit/email-kit#status).
8
+ **[Documentation](https://email-kit.dev)** · [Getting started](https://email-kit.dev/guide/getting-started/) · [GitHub](https://github.com/email-kit/email-kit)
9
+
10
+ ## Get started
11
+
12
+ In the project that sends email (in a monorepo, the app's folder), run:
10
13
 
11
14
  ```sh
12
- npx @email-kit/cli init # or: npm create email-kit
13
- npx email-kit compile # templates → a typed module your server imports
14
- npx email-kit check # the checks, for CI (exit 1 on errors)
15
+ npm create email-kit
16
+ ```
17
+
18
+ It detects your package manager, TypeScript setup and framework, installs the packages below, adds
19
+ a config and a welcome template, and compiles once. It asks before changing any file you already
20
+ have; `npm create email-kit -- --yes` accepts every default, as in CI. `npx @email-kit/cli init`
21
+ does the same.
22
+
23
+ Then render the welcome email from your server, with the import `init` prints for your project:
24
+
25
+ ```ts
26
+ import { emails } from "./email-kit"
27
+
28
+ const { subject, html, text } = emails.welcome.render({
29
+ name: "Ada",
30
+ plan: "pro",
31
+ startUrl: "https://example.com/start",
32
+ })
15
33
  ```
16
34
 
17
- | Command | Does |
35
+ email-kit doesn't send email: hand `subject`, `html` and `text` to any provider's API.
36
+
37
+ While you work:
38
+
39
+ ```sh
40
+ npx email-kit compile # after changing a template or message; --watch keeps it running
41
+ npx email-kit check # the checks; exits 1 on errors, for CI
42
+ npx email-kit new <id> # another template, with messages in every locale
43
+ ```
44
+
45
+ The [getting started guide](https://email-kit.dev/guide/getting-started/) goes through it step by
46
+ step, and [your first email](https://email-kit.dev/guide/first-email/) builds one from scratch.
47
+
48
+ ## A template
49
+
50
+ Each template is a folder with `template.tsx` and a `messages.<locale>.json` per language:
51
+
52
+ ```tsx
53
+ import { Button, Heading, Text } from "@email-kit/components"
54
+ import { defineEmail, url } from "@email-kit/core"
55
+ import { z } from "zod"
56
+
57
+ export default defineEmail({
58
+ id: "welcome",
59
+ purpose: "transactional",
60
+ schema: z.object({ name: z.string().min(1), startUrl: z.string().meta(url) }),
61
+ subject: (data, t) => t("subject", { name: data.name }),
62
+ fixtures: { default: { name: "Ada", startUrl: "https://example.com/start" } },
63
+ component: ({ data, t }) => (
64
+ <>
65
+ <Heading>{t("heading", { name: data.name })}</Heading>
66
+ <Text>{t("body")}</Text>
67
+ <Button href={data.startUrl}>{t("cta")}</Button>
68
+ </>
69
+ ),
70
+ })
71
+ ```
72
+
73
+ Templates run when you compile, not when you send: your server imports the generated module, which
74
+ needs only `@email-kit/runtime`.
75
+
76
+ ## The packages
77
+
78
+ They work together and are released together: install the same version of each.
79
+ `npm create email-kit` installs them for you.
80
+
81
+ | Package | What it is | Install as |
82
+ |---|---|---|
83
+ | [`create-email-kit`](https://www.npmjs.com/package/create-email-kit) | `npm create email-kit`: runs `email-kit init` in the folder you're in | not installed |
84
+ | [`@email-kit/cli`](https://www.npmjs.com/package/@email-kit/cli) | The `email-kit` command: `init`, `new`, `compile`, `check` and `tokens` | devDependency |
85
+ | [`@email-kit/core`](https://www.npmjs.com/package/@email-kit/core) | What templates are written with: `defineEmail`, the JSX runtime, `If`/`Each`/`Unless`, field markers (`url`, `secret`, `formatted`), `defineConfig` and `defineCheck` | devDependency |
86
+ | [`@email-kit/components`](https://www.npmjs.com/package/@email-kit/components) | Email-safe components themed from your shadcn CSS or design tokens: `Text`, `Heading`, `Link`, `Button`, `Image`, `Divider`, `Spacer`, `Section`, `List`, `KeyValue`, `Callout`, `OtpCode`, `DataTable`, `LineItems` and `Footer` | devDependency |
87
+ | [`@email-kit/runtime`](https://www.npmjs.com/package/@email-kit/runtime) | Renders the compiled emails. The only one your app needs when it runs | **dependency** |
88
+
89
+ ### The runtime
90
+
91
+ `@email-kit/runtime` has no dependencies and uses only web-standard APIs, so it runs in Node 22+,
92
+ Bun, Deno, Cloudflare Workers, AWS Lambda and Next.js server code. You don't import it yourself:
93
+ the generated module does, and only the entry points your templates use, from about 1.4 KB to 3 KB
94
+ min+gzip:
95
+
96
+ | Entry point | Imported when |
18
97
  |---|---|
19
- | `init` | Adds a config, an `email-kit/` folder and a welcome template to the project it runs in. Asks before each change to an existing file; `--yes` for CI |
20
- | `new <id>` | Adds a template, with messages in every locale |
21
- | `compile` | Writes HTML, text, JSON Schema and a dependency-free module (`--watch`, `--verbose`) |
22
- | `check` | Runs the checks on the compiled emails, renders of every fixture, the sources and the theme (`--json`, `--reporter github`) |
23
- | `tokens` | Prints the theme's colour roles in light and dark with their contrast |
98
+ | `@email-kit/runtime` | always |
99
+ | `@email-kit/runtime/validate` | `validate` is on (the default) |
100
+ | `@email-kit/runtime/plural` | a message has a plural or a select |
101
+ | `@email-kit/runtime/locale` | the project compiles more than one locale |
102
+ | `@email-kit/runtime/context` | the config has sender values passed at send time |
103
+
104
+ Rendering problems throw an `EmailRenderError` with a `code`; see the
105
+ [error reference](https://email-kit.dev/reference/errors/). A module compiled by another version of
106
+ the CLI fails with `incompatible-module` rather than rendering wrong.
107
+
108
+ ## Status
109
+
110
+ **1.0.** Stable for transactional email; breaking changes come only in a major release. Not yet:
111
+ marketing email (unsubscribe links, multi-column layouts), testing in real email clients (classic
112
+ Outlook especially), and the preview studio.
113
+
114
+ ## More
115
+
116
+ - [Guide](https://email-kit.dev/guide/): templates, components, messages and locales, theme and dark
117
+ mode, checks and CI, rendering and sending.
118
+ - Reference: [CLI](https://email-kit.dev/reference/cli/),
119
+ [configuration](https://email-kit.dev/reference/configuration/),
120
+ [checks](https://email-kit.dev/reference/checks/), [errors](https://email-kit.dev/reference/errors/).
121
+ - [Issues](https://github.com/email-kit/email-kit/issues) and
122
+ [changelog](https://github.com/email-kit/email-kit/blob/main/packages/cli/CHANGELOG.md).
24
123
 
25
- Requires Node.js 22.12 or later. MIT licensed; third-party notices in `THIRD_PARTY_NOTICES.md`.
124
+ The CLI requires Node.js 22.12 or later. MIT licensed; the CLI's third-party notices are in its
125
+ `THIRD_PARTY_NOTICES.md`.
package/dist/cli.js CHANGED
@@ -15280,7 +15280,7 @@ function scriptOf(tag) {
15280
15280
  * The email-kit version, from package.json. `--version` prints it, the compiler writes it into
15281
15281
  * generated files and the manifest, and `init` uses it for the dependency ranges it adds.
15282
15282
  */
15283
- const VERSION = "1.0.0";
15283
+ const VERSION = "1.0.1";
15284
15284
  // src/compiler/emit/javascript.ts
15285
15285
  /**
15286
15286
  * Converts the generated module to `index.mjs` and `index.d.mts`, for `module: "mjs"`. oxc, through
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@email-kit/cli",
3
- "version": "1.0.0",
4
- "description": "email-kit CLI: init, compile, check and preview type-safe email templates.",
3
+ "version": "1.0.1",
4
+ "description": "email-kit CLI: set up, compile and check type-safe TSX email templates.",
5
5
  "keywords": [
6
6
  "email",
7
7
  "email-templates",
@@ -9,7 +9,7 @@
9
9
  "compiler",
10
10
  "typescript"
11
11
  ],
12
- "homepage": "https://github.com/email-kit/email-kit#readme",
12
+ "homepage": "https://email-kit.dev",
13
13
  "bugs": "https://github.com/email-kit/email-kit/issues",
14
14
  "repository": {
15
15
  "type": "git",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@clack/prompts": "^1.8.1",
40
- "@email-kit/core": "1.0.0",
40
+ "@email-kit/core": "1.0.1",
41
41
  "cac": "^7.1.0",
42
42
  "culori": "^4.0.2",
43
43
  "domhandler": "^5.0.3",
@@ -47,9 +47,9 @@
47
47
  "rolldown": "1.2.15"
48
48
  },
49
49
  "devDependencies": {
50
- "@email-kit/components": "1.0.0",
50
+ "@email-kit/components": "1.0.1",
51
51
  "@email-kit/dialect": "0.0.0",
52
- "@email-kit/runtime": "1.0.0",
52
+ "@email-kit/runtime": "1.0.1",
53
53
  "@types/culori": "^4.0.1",
54
54
  "@types/node": "22.20.5",
55
55
  "@valibot/to-json-schema": "1.8.0",