@emailens/cli 0.9.0 → 0.11.0
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.
- package/README.md +165 -276
- package/dist/index.js +47 -26
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,276 +1,165 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
<picture>
|
|
4
|
-
<source media="(prefers-color-scheme: dark)" srcset="./docs/wordmark-dark.svg">
|
|
5
|
-
<img src="./docs/wordmark-light.svg" alt="emailens / cli" width="444">
|
|
6
|
-
</picture>
|
|
7
|
-
|
|
8
|
-
**The email rendering linter for terminal and CI**
|
|
9
|
-
|
|
10
|
-
[](https://github.com/emailens/cli/actions/workflows/ci.yml)
|
|
11
|
-
[](https://www.npmjs.com/package/@emailens/cli)
|
|
12
|
-
[](https://github.com/emailens/mcp)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
emailens
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
emailens
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
emailens
|
|
159
|
-
emailens
|
|
160
|
-
emailens
|
|
161
|
-
emailens
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|------|-------|-------------|
|
|
167
|
-
| `--format` | `-f` | Input format: `html`, `jsx`, `mjml`, `maizzle`. `.vue` is `maizzle`. A pasted Vue file with no flag is detected. |
|
|
168
|
-
| `--json` | | Output as JSON |
|
|
169
|
-
| `--fail-on-warning` | | Exit 2 if warnings found |
|
|
170
|
-
| `--skip` | | Comma-separated checks to skip: `spam,links,accessibility,images,compatibility,inboxPreview,size,templateVariables,overflow,visual,darkContrast,mobileContrast,design,vml,styleSurvival,targeting` |
|
|
171
|
-
| `--targeting-policy` | | `progressive` (default), `strict`, or `lenient` |
|
|
172
|
-
| `--max-warnings` | | Fail if more than n warnings |
|
|
173
|
-
|
|
174
|
-
Exit codes:
|
|
175
|
-
|
|
176
|
-
- `0`: clean
|
|
177
|
-
- `1`: errors found
|
|
178
|
-
- `2`: warnings only (with `--fail-on-warning` or `--max-warnings` exceeded)
|
|
179
|
-
|
|
180
|
-
### `emailens inbox wait`
|
|
181
|
-
|
|
182
|
-
The CI step for what your app actually sends. Make your app send a real email
|
|
183
|
-
(sign-up, reset, receipt) to your Emailens test inbox, then wait for it. It
|
|
184
|
-
fails when the email is no longer the one you checked in Emailens, or changed
|
|
185
|
-
since it last arrived: a link moved to staging, an emptied variable, a new
|
|
186
|
-
line, an image gone, a size jump, signing that stopped passing. Codes, tokens
|
|
187
|
-
and tracking ids differ on every send and do not count.
|
|
188
|
-
|
|
189
|
-
```bash
|
|
190
|
-
export EMAILENS_API_KEY=... # app.emailens.dev/dashboard/api
|
|
191
|
-
SINCE=$(date +%s000) # before the send
|
|
192
|
-
npm run send-signup-email # your app sends it
|
|
193
|
-
emailens inbox wait --subject "Welcome" --since "$SINCE"
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
```
|
|
197
|
-
Welcome to Acme from Acme <hi@acme.dev>
|
|
198
|
-
|
|
199
|
-
Your check Same as "Welcome", apart from the links your email service wrapped.
|
|
200
|
-
Since last time Changed since last time: 1 change.
|
|
201
|
-
|
|
202
|
-
✗ 1 link points somewhere else: "finish setup" went to staging.acme.dev.
|
|
203
|
-
|
|
204
|
-
✗ Fail: 1 change
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
Options: `--subject`, `--sender`, `--inbox <id>`, `--since` (ISO time, epoch
|
|
208
|
-
ms, or a duration such as `5m`; default 2 minutes back), `--timeout` (seconds,
|
|
209
|
-
default 60, at most 600), `--fail-on all|check|drift|none` (default `all`),
|
|
210
|
-
`--json`. An email you never checked, and its first arrival, pass and say so.
|
|
211
|
-
|
|
212
|
-
Exit codes: `0` pass, `1` changed, `2` nothing arrived or Emailens could not be
|
|
213
|
-
reached.
|
|
214
|
-
|
|
215
|
-
### `emailens clients`
|
|
216
|
-
|
|
217
|
-
List all 21 supported clients.
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
emailens clients
|
|
221
|
-
emailens clients --json
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
## GitHub Actions
|
|
225
|
-
|
|
226
|
-
Add a PR gate to fail builds when email regressions appear:
|
|
227
|
-
|
|
228
|
-
```yaml
|
|
229
|
-
name: Email lint
|
|
230
|
-
|
|
231
|
-
on:
|
|
232
|
-
pull_request:
|
|
233
|
-
paths:
|
|
234
|
-
- 'emails/**'
|
|
235
|
-
- 'src/emails/**'
|
|
236
|
-
|
|
237
|
-
jobs:
|
|
238
|
-
lint:
|
|
239
|
-
runs-on: ubuntu-latest
|
|
240
|
-
steps:
|
|
241
|
-
- uses: actions/checkout@v4
|
|
242
|
-
- uses: actions/setup-node@v4
|
|
243
|
-
with:
|
|
244
|
-
node-version: 22
|
|
245
|
-
- name: Lint emails
|
|
246
|
-
run: npx -y @emailens/cli lint 'emails/**/*.{html,tsx,mjml}' --fail-on-warning
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
## AI and MCP
|
|
250
|
-
|
|
251
|
-
Prefer AI? Use the [MCP server](https://github.com/emailens/mcp). It gives your coding agent access to the same analysis engine and lets it preview, audit, fix, and diff email templates.
|
|
252
|
-
|
|
253
|
-
```bash
|
|
254
|
-
claude mcp add emailens -- npx -y @emailens/mcp
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
## Why not just use the hosted app?
|
|
258
|
-
|
|
259
|
-
You can. But the open-source tools are what let developers:
|
|
260
|
-
|
|
261
|
-
- validate before a push
|
|
262
|
-
- fail CI before a broken email ships
|
|
263
|
-
- run audits offline
|
|
264
|
-
- keep email QA in their editor and terminal
|
|
265
|
-
- build local automation without signing up for a platform
|
|
266
|
-
|
|
267
|
-
The hosted SaaS adds screenshot previews, shared reports, and team workflows. The OSS tools give you the developer-first layer.
|
|
268
|
-
|
|
269
|
-
## License
|
|
270
|
-
|
|
271
|
-
MIT
|
|
272
|
-
|
|
273
|
-
---
|
|
274
|
-
|
|
275
|
-
If this saved you from an Outlook surprise, [a star](https://github.com/emailens/cli) helps other email developers find it.
|
|
276
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="./docs/wordmark-dark.svg">
|
|
5
|
+
<img src="./docs/wordmark-light.svg" alt="emailens / cli" width="444">
|
|
6
|
+
</picture>
|
|
7
|
+
|
|
8
|
+
**The email rendering linter for terminal and CI**
|
|
9
|
+
|
|
10
|
+
[](https://github.com/emailens/cli/actions/workflows/ci.yml)
|
|
11
|
+
[](https://www.npmjs.com/package/@emailens/cli)
|
|
12
|
+
[](https://github.com/emailens/mcp)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
$ emailens lint emails/welcome.html --fail-on-warning
|
|
18
|
+
emails/welcome.html
|
|
19
|
+
warn 6:17 outlook-windows-legacy display:flex Outlook Classic receives this flex box. The MSO branch needs a table.
|
|
20
|
+
warn 6:30 outlook-windows-legacy,yahoo-mail,yahoo-mail-android+2 gap Outlook Classic does not support "gap".
|
|
21
|
+
warn 6:39 outlook-windows-legacy,outlook-windows-legacy padding Outlook Classic drops this padding. Put it on a table cell, or set mso-padding-alt on one.
|
|
22
|
+
warn inboxPreview preheader-too-short Preheader is only 22 characters, so email clients may backfill with body text (recommended: 30+).
|
|
23
|
+
9 info: safe fallbacks, not problems. --info lists them.
|
|
24
|
+
|
|
25
|
+
1 file | 4 warnings
|
|
26
|
+
|
|
27
|
+
Failed: 4 warnings found (--failOnWarning)
|
|
28
|
+
See it rendered in Gmail, Outlook and Apple Mail, no signup: https://app.emailens.dev/try?utm_source=cli&utm_medium=lint
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
That is a flex row with a rounded button, checked against 21 email clients.
|
|
32
|
+
Each finding has its line:column, and the exit code (here 2) fails the build.
|
|
33
|
+
The rounded corners are among the 9 info findings: Outlook Classic draws them
|
|
34
|
+
square, a safe fallback rather than a problem. The last line appears only when
|
|
35
|
+
the check fails; `--quiet` drops it, and `--json` never has it.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install -g @emailens/cli
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Run
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
emailens lint 'emails/*.html'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Or without installing: `npx @emailens/cli lint email.html`. HTML, React Email
|
|
50
|
+
(`.tsx`/`.jsx`), MJML and Maizzle are detected from the extension and compiled
|
|
51
|
+
first, so the check runs on the HTML that would be sent. No account and no
|
|
52
|
+
network: the analysis runs locally.
|
|
53
|
+
|
|
54
|
+
Exit codes: `0` clean, `1` errors, `2` warnings with `--fail-on-warning`, or
|
|
55
|
+
more than `--max-warnings`.
|
|
56
|
+
|
|
57
|
+
## Why not caniemail, or React Email's own checker?
|
|
58
|
+
|
|
59
|
+
[Can I email](https://www.caniemail.com) is the support table: one feature,
|
|
60
|
+
every client. It does not read your email. This CLI's support data is generated
|
|
61
|
+
from caniemail's (synced 2026-10-27), plus the cells a real-device screenshot
|
|
62
|
+
contradicted, each marked "Observed" with its date. What the CLI adds is the
|
|
63
|
+
reading: it finds the features your file uses, points at the line, scores each
|
|
64
|
+
client, and exits non-zero.
|
|
65
|
+
|
|
66
|
+
[React Email 4](https://resend.com/blog/react-email-4) added a compatibility
|
|
67
|
+
checker, also powered by Can I email, to its preview. Its CLI (`email dev`,
|
|
68
|
+
`build`, `start`, `export`) has no check command and no exit code for CI, per
|
|
69
|
+
[its docs](https://react.email/docs/cli). This CLI reads React Email files as
|
|
70
|
+
well as MJML, Maizzle and plain HTML, and fails the build.
|
|
71
|
+
|
|
72
|
+
Beyond CSS support, `lint` checks what neither covers: spam signals, links,
|
|
73
|
+
accessibility, images, the inbox preview text, size, template variables,
|
|
74
|
+
overflow, dark-mode and mobile contrast, Outlook VML, styles a client drops, and
|
|
75
|
+
client-targeting hacks.
|
|
76
|
+
|
|
77
|
+
## Extras
|
|
78
|
+
|
|
79
|
+
### `lint` options
|
|
80
|
+
|
|
81
|
+
| Flag | Alias | Description |
|
|
82
|
+
|------|-------|-------------|
|
|
83
|
+
| `--format` | `-f` | Input format: `html`, `jsx`, `mjml`, `maizzle`. `.vue` is `maizzle`. A pasted Vue file with no flag is detected. |
|
|
84
|
+
| `--json` | | Output as JSON, one line, every finding including info |
|
|
85
|
+
| `--info` | | List info findings too. By default they are counted, not listed: they are safe fallbacks, not problems |
|
|
86
|
+
| `--fail-on-warning` | | Exit 2 if warnings found |
|
|
87
|
+
| `--max-warnings` | | Fail if more than n warnings |
|
|
88
|
+
| `--quiet` | `-q` | No line about the hosted preview after a failure |
|
|
89
|
+
| `--skip` | | Comma-separated checks to skip: `spam,links,accessibility,images,compatibility,inboxPreview,size,templateVariables,overflow,visual,darkContrast,mobileContrast,design,vml,styleSurvival,targeting` |
|
|
90
|
+
| `--targeting-policy` | | `progressive` (default), `strict`, or `lenient` |
|
|
91
|
+
|
|
92
|
+
A `.emailensrc` in the project, the file the VS Code extension reads, can set
|
|
93
|
+
rule severities and skips; `--skip` on the command line wins.
|
|
94
|
+
|
|
95
|
+
Maizzle HTML needs `@maizzle/framework@5` installed beside the CLI. A `.vue`
|
|
96
|
+
file needs `@maizzle/framework@6`. One install is one major.
|
|
97
|
+
|
|
98
|
+
### Other commands
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
emailens analyze email.html # score per client, findings by client
|
|
102
|
+
emailens analyze email.html --clients gmail-web,outlook-windows --json
|
|
103
|
+
emailens audit email.html # compatibility plus every other check
|
|
104
|
+
emailens preview email.html --dark-mode # transforms, analysis, dark mode simulation
|
|
105
|
+
emailens preview email.html --screenshots --out ./shots # needs BROWSERLESS_URL and playwright-core
|
|
106
|
+
emailens export email.html -o ./report # self-contained HTML report (--json for JSON)
|
|
107
|
+
emailens fix email.html -o fixed.html # AI fix, needs ANTHROPIC_API_KEY (--estimate: tokens only)
|
|
108
|
+
emailens clients # the 21 clients
|
|
109
|
+
cat email.html | emailens analyze - # stdin
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### `emailens inbox wait`
|
|
113
|
+
|
|
114
|
+
The CI step for what your app actually sends. Make your app send a real email
|
|
115
|
+
(sign-up, reset, receipt) to your Emailens test inbox, then wait for it. It
|
|
116
|
+
fails when the email is no longer the one you checked in Emailens, or changed
|
|
117
|
+
since it last arrived: a link moved to staging, an emptied variable, a new
|
|
118
|
+
line, an image gone, a size jump, signing that stopped passing. Codes, tokens
|
|
119
|
+
and tracking ids differ on every send and do not count. It needs an API key.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
export EMAILENS_API_KEY=... # app.emailens.dev/dashboard/api
|
|
123
|
+
SINCE=$(date +%s000) # before the send
|
|
124
|
+
npm run send-signup-email # your app sends it
|
|
125
|
+
emailens inbox wait --subject "Welcome" --since "$SINCE"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Options: `--subject`, `--sender`, `--inbox <id>`, `--since` (ISO time, epoch
|
|
129
|
+
ms, or a duration such as `5m`; default 2 minutes back), `--timeout` (seconds,
|
|
130
|
+
default 60, at most 600), `--fail-on all|check|drift|none` (default `all`),
|
|
131
|
+
`--json`. Exit codes: `0` pass, `1` changed, `2` nothing arrived or Emailens
|
|
132
|
+
could not be reached.
|
|
133
|
+
|
|
134
|
+
### In GitHub Actions
|
|
135
|
+
|
|
136
|
+
```yaml
|
|
137
|
+
- uses: actions/setup-node@v4
|
|
138
|
+
with:
|
|
139
|
+
node-version: 22
|
|
140
|
+
- run: npx -y @emailens/cli lint 'emails/*.html' --fail-on-warning
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`**` globs are not supported: use a single-level wildcard or list the files.
|
|
144
|
+
For scores per client in a pull request comment, use the
|
|
145
|
+
[Action](https://github.com/emailens/action).
|
|
146
|
+
|
|
147
|
+
### Hosted
|
|
148
|
+
|
|
149
|
+
[app.emailens.dev/try](https://app.emailens.dev/try?utm_source=cli&utm_medium=readme)
|
|
150
|
+
renders the email per client: five clients with no account, all 21 with a free
|
|
151
|
+
one. The + Real plans add real-device screenshots: Outlook on Windows and Mac,
|
|
152
|
+
Apple Mail on Mac and iPad, and Gmail, Yahoo and Proton on the web.
|
|
153
|
+
|
|
154
|
+
## Ecosystem
|
|
155
|
+
|
|
156
|
+
| Project | What it is |
|
|
157
|
+
|---|---|
|
|
158
|
+
| [@emailens/engine](https://github.com/emailens/engine) | The analysis engine this CLI runs, as a library |
|
|
159
|
+
| [@emailens/mcp](https://github.com/emailens/mcp) | The same checks for coding agents: `claude mcp add emailens -- npx -y @emailens/mcp` |
|
|
160
|
+
| [emailens/action](https://github.com/emailens/action) | GitHub Action: fails the build, and can comment the scores per client on the pull request |
|
|
161
|
+
| [emailens/vscode](https://github.com/emailens/vscode) | VS Code extension: findings and preview in the editor |
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { EMAIL_CLIENTS } from "@emailens/engine";
|
|
|
12
12
|
// package.json
|
|
13
13
|
var package_default = {
|
|
14
14
|
name: "@emailens/cli",
|
|
15
|
-
version: "0.
|
|
15
|
+
version: "0.11.0",
|
|
16
16
|
description: "CLI tool for email compatibility analysis: lint, preview and export HTML, MJML, Maizzle and React Email rendering across 21 email clients.",
|
|
17
17
|
type: "module",
|
|
18
18
|
bin: {
|
|
@@ -39,7 +39,7 @@ var package_default = {
|
|
|
39
39
|
prepublishOnly: "bun run build"
|
|
40
40
|
},
|
|
41
41
|
dependencies: {
|
|
42
|
-
"@emailens/engine": "^0.
|
|
42
|
+
"@emailens/engine": "^0.17.0",
|
|
43
43
|
citty: "^0.1.6",
|
|
44
44
|
"cli-table3": "^0.6.5",
|
|
45
45
|
ora: "^8.2.0",
|
|
@@ -243,7 +243,7 @@ function formatJsonOutput(opts) {
|
|
|
243
243
|
return output;
|
|
244
244
|
}
|
|
245
245
|
function printJson(opts) {
|
|
246
|
-
console.log(JSON.stringify(formatJsonOutput(opts)
|
|
246
|
+
console.log(JSON.stringify(formatJsonOutput(opts)));
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
// src/output/terminal.ts
|
|
@@ -576,7 +576,7 @@ var clients_default = defineCommand3({
|
|
|
576
576
|
engine: c.engine,
|
|
577
577
|
darkModeSupport: c.darkModeSupport
|
|
578
578
|
}));
|
|
579
|
-
console.log(JSON.stringify(data
|
|
579
|
+
console.log(JSON.stringify(data));
|
|
580
580
|
return;
|
|
581
581
|
}
|
|
582
582
|
console.log();
|
|
@@ -923,7 +923,7 @@ var fix_default = defineCommand5({
|
|
|
923
923
|
spinner?.succeed(`Found ${warnings.length} warnings`);
|
|
924
924
|
if (warnings.length === 0) {
|
|
925
925
|
if (args.json) {
|
|
926
|
-
console.log(JSON.stringify({ message: "No issues found", code: source }
|
|
926
|
+
console.log(JSON.stringify({ message: "No issues found", code: source }));
|
|
927
927
|
} else {
|
|
928
928
|
console.log(pc3.green("\n No compatibility issues found, nothing to fix.\n"));
|
|
929
929
|
}
|
|
@@ -962,7 +962,7 @@ var fix_default = defineCommand5({
|
|
|
962
962
|
const structuralPct = estimate.warningCount > 0 ? Math.round(estimate.structuralCount / estimate.warningCount * 100) : 0;
|
|
963
963
|
if (args.estimate) {
|
|
964
964
|
if (args.json) {
|
|
965
|
-
console.log(JSON.stringify(estimate
|
|
965
|
+
console.log(JSON.stringify(estimate));
|
|
966
966
|
} else {
|
|
967
967
|
console.log(`
|
|
968
968
|
${pc3.bold("Token Estimate")}`);
|
|
@@ -1033,7 +1033,7 @@ var fix_default = defineCommand5({
|
|
|
1033
1033
|
targetedWarnings: result.targetedWarnings,
|
|
1034
1034
|
structuralCount: result.structuralCount,
|
|
1035
1035
|
tokenEstimate: result.tokenEstimate
|
|
1036
|
-
}
|
|
1036
|
+
}));
|
|
1037
1037
|
} else {
|
|
1038
1038
|
console.log("\n" + result.code);
|
|
1039
1039
|
}
|
|
@@ -1114,7 +1114,7 @@ var audit_default = defineCommand6({
|
|
|
1114
1114
|
const report = auditEmail(html, { framework, skip, targetingPolicy });
|
|
1115
1115
|
spinner?.succeed("Audit complete");
|
|
1116
1116
|
if (args.json) {
|
|
1117
|
-
console.log(JSON.stringify(report
|
|
1117
|
+
console.log(JSON.stringify(report));
|
|
1118
1118
|
} else {
|
|
1119
1119
|
if (!skip.includes("compatibility")) {
|
|
1120
1120
|
printScoreTable(report.compatibility.scores, report.compatibility.warnings, { quiet: args.quiet });
|
|
@@ -1326,6 +1326,10 @@ var lint_default = defineCommand7({
|
|
|
1326
1326
|
type: "boolean",
|
|
1327
1327
|
description: "Output as JSON"
|
|
1328
1328
|
},
|
|
1329
|
+
info: {
|
|
1330
|
+
type: "boolean",
|
|
1331
|
+
description: "List info findings too: safe fallbacks, not problems (counted, not listed, by default)"
|
|
1332
|
+
},
|
|
1329
1333
|
failOnWarning: {
|
|
1330
1334
|
type: "boolean",
|
|
1331
1335
|
description: "Exit 2 if warnings found"
|
|
@@ -1338,6 +1342,11 @@ var lint_default = defineCommand7({
|
|
|
1338
1342
|
maxWarnings: {
|
|
1339
1343
|
type: "string",
|
|
1340
1344
|
description: "Fail if more than n warnings"
|
|
1345
|
+
},
|
|
1346
|
+
quiet: {
|
|
1347
|
+
type: "boolean",
|
|
1348
|
+
alias: "q",
|
|
1349
|
+
description: "Suppress decorations: no hosted-preview line after a failure"
|
|
1341
1350
|
}
|
|
1342
1351
|
},
|
|
1343
1352
|
async run({ args }) {
|
|
@@ -1406,23 +1415,28 @@ var lint_default = defineCommand7({
|
|
|
1406
1415
|
totalWarnings += warnings;
|
|
1407
1416
|
}
|
|
1408
1417
|
if (args.json) {
|
|
1409
|
-
console.log(JSON.stringify({ files: results, totalErrors, totalWarnings }
|
|
1418
|
+
console.log(JSON.stringify({ files: results, totalErrors, totalWarnings }));
|
|
1410
1419
|
} else {
|
|
1411
1420
|
for (const result of results) {
|
|
1412
1421
|
console.log(pc5.underline(result.file));
|
|
1413
|
-
|
|
1422
|
+
const shown = args.info ? result.issues : result.issues.filter((i) => i.severity !== "info");
|
|
1423
|
+
const hidden = result.issues.length - shown.length;
|
|
1424
|
+
if (shown.length === 0) {
|
|
1414
1425
|
console.log(` ${pc5.green("pass")} No issues found`);
|
|
1415
1426
|
} else {
|
|
1416
|
-
const width =
|
|
1427
|
+
const width = shown.reduce(
|
|
1417
1428
|
(w, i) => i.loc ? Math.max(w, `${i.loc.line}:${i.loc.column}`.length) : w,
|
|
1418
1429
|
0
|
|
1419
1430
|
);
|
|
1420
|
-
for (const issue of
|
|
1431
|
+
for (const issue of shown) {
|
|
1421
1432
|
const sev = issue.severity === "error" ? pc5.red("error") : issue.severity === "warning" ? pc5.yellow("warn ") : pc5.blue("info ");
|
|
1422
1433
|
const pos = width > 0 ? `${pc5.dim((issue.loc ? `${issue.loc.line}:${issue.loc.column}` : "").padStart(width))} ` : "";
|
|
1423
1434
|
console.log(` ${sev} ${pos}${pc5.dim(issue.category.padEnd(18))} ${pc5.bold(issue.rule.padEnd(22))} ${issue.message}`);
|
|
1424
1435
|
}
|
|
1425
1436
|
}
|
|
1437
|
+
if (hidden > 0) {
|
|
1438
|
+
console.log(pc5.dim(` ${hidden} info: safe fallbacks, not problems. --info lists them.`));
|
|
1439
|
+
}
|
|
1426
1440
|
console.log();
|
|
1427
1441
|
}
|
|
1428
1442
|
const summary = [
|
|
@@ -1433,23 +1447,25 @@ var lint_default = defineCommand7({
|
|
|
1433
1447
|
].filter(Boolean).join(" | ");
|
|
1434
1448
|
console.log(summary);
|
|
1435
1449
|
}
|
|
1450
|
+
let exitCode = 0;
|
|
1451
|
+
let reason = null;
|
|
1436
1452
|
if (totalErrors > 0) {
|
|
1437
|
-
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1453
|
+
exitCode = 1;
|
|
1454
|
+
} else if (args.failOnWarning && totalWarnings > 0) {
|
|
1455
|
+
exitCode = 2;
|
|
1456
|
+
reason = pc5.yellow(`
|
|
1457
|
+
Failed: ${totalWarnings} warning${totalWarnings === 1 ? "" : "s"} found (--failOnWarning)`);
|
|
1458
|
+
} else if (Number.isFinite(maxWarnings) && totalWarnings > maxWarnings) {
|
|
1459
|
+
exitCode = 2;
|
|
1460
|
+
reason = pc5.red(`
|
|
1461
|
+
Exceeded max warnings: ${totalWarnings} > ${maxWarnings}`);
|
|
1445
1462
|
}
|
|
1446
|
-
if (
|
|
1447
|
-
if (
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
}
|
|
1451
|
-
process.exit(2);
|
|
1463
|
+
if (!args.json) {
|
|
1464
|
+
if (reason) console.error(reason);
|
|
1465
|
+
const hint = failureHint(exitCode, { quiet: args.quiet });
|
|
1466
|
+
if (hint) console.log(pc5.dim(hint));
|
|
1452
1467
|
}
|
|
1468
|
+
if (exitCode !== 0) process.exit(exitCode);
|
|
1453
1469
|
} catch (err) {
|
|
1454
1470
|
if (err instanceof CompileError6) {
|
|
1455
1471
|
console.error(pc5.red(`Compilation failed (${err.phase}): ${err.message}`));
|
|
@@ -1460,6 +1476,11 @@ Exceeded max warnings: ${totalWarnings} > ${maxWarnings}`));
|
|
|
1460
1476
|
}
|
|
1461
1477
|
}
|
|
1462
1478
|
});
|
|
1479
|
+
var HOSTED_HINT = "See it rendered in Gmail, Outlook and Apple Mail, no signup: https://app.emailens.dev/try?utm_source=cli&utm_medium=lint";
|
|
1480
|
+
function failureHint(exitCode, options = {}) {
|
|
1481
|
+
if (exitCode === 0 || options.quiet) return null;
|
|
1482
|
+
return HOSTED_HINT;
|
|
1483
|
+
}
|
|
1463
1484
|
async function resolveGlob(pattern) {
|
|
1464
1485
|
if (!pattern.includes("*")) {
|
|
1465
1486
|
return [resolve2(pattern)];
|