@emailens/cli 0.11.0 → 0.13.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/dist/test.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ import { SourceLocation, AuditOptions } from '@emailens/engine';
2
+
3
+ interface LintIssue {
4
+ severity: "error" | "warning" | "info";
5
+ category: string;
6
+ rule: string;
7
+ message: string;
8
+ detail?: string;
9
+ /** Where in the file the issue is. HTML sources only, see `positionsApply`. */
10
+ loc?: SourceLocation;
11
+ /** Every place a CSS property breaks, in document order. */
12
+ locs?: SourceLocation[];
13
+ /** `locs` is capped and does not list every occurrence. */
14
+ locsTruncated?: boolean;
15
+ }
16
+
17
+ interface ExpectEmailOptions {
18
+ /** Fail on warnings too, like `lint --fail-on-warning`. */
19
+ failOnWarning?: boolean;
20
+ /** Checks to skip, the same names as `lint --skip`. */
21
+ skip?: string[];
22
+ framework?: AuditOptions["framework"];
23
+ }
24
+ /**
25
+ * The `lint` check as a test assertion: throws, listing every finding that
26
+ * fails, unless the email passes. Plain throw, so it works in Vitest, Jest and
27
+ * bun:test alike. Reads the project's `.emailensrc` like the CLI, so a test and
28
+ * the CI step cannot disagree about the same email. Returns the findings.
29
+ *
30
+ * expectEmailToPass(await render(<Welcome />));
31
+ */
32
+ declare function expectEmailToPass(html: string, options?: ExpectEmailOptions): LintIssue[];
33
+
34
+ export { type ExpectEmailOptions, type LintIssue, expectEmailToPass };
package/dist/test.js ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ applySeverities,
4
+ flattenToLintIssues,
5
+ loadProjectConfig
6
+ } from "./chunk-KZ7WXQVF.js";
7
+ import "./chunk-7OCVIDC7.js";
8
+
9
+ // src/test.ts
10
+ import { auditEmail } from "@emailens/engine";
11
+ function expectEmailToPass(html, options = {}) {
12
+ const project = loadProjectConfig();
13
+ const skip = options.skip ?? project?.skip ?? [];
14
+ const report = auditEmail(html, {
15
+ framework: options.framework,
16
+ skip,
17
+ positions: true
18
+ });
19
+ const issues = applySeverities(flattenToLintIssues(report, skip), project?.rules);
20
+ const failing = issues.filter(
21
+ (i) => i.severity === "error" || options.failOnWarning && i.severity === "warning"
22
+ );
23
+ if (failing.length > 0) {
24
+ const lines = failing.map(
25
+ (i) => ` ${i.severity.padEnd(7)} ${i.loc ? `${i.loc.line}:${i.loc.column} ` : ""}${i.category} ${i.rule}: ${i.message}`
26
+ );
27
+ throw new Error(`Email fails emailens lint (${failing.length}):
28
+ ${lines.join("\n")}`);
29
+ }
30
+ return issues;
31
+ }
32
+ export {
33
+ expectEmailToPass
34
+ };
35
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/test.ts"],"sourcesContent":["import { auditEmail, type AuditOptions } from \"@emailens/engine\";\r\nimport { flattenToLintIssues, type LintIssue } from \"./commands/lint.js\";\r\nimport { applySeverities, loadProjectConfig } from \"./project-config.js\";\r\n\r\nexport type { LintIssue };\r\n\r\nexport interface ExpectEmailOptions {\r\n /** Fail on warnings too, like `lint --fail-on-warning`. */\r\n failOnWarning?: boolean;\r\n /** Checks to skip, the same names as `lint --skip`. */\r\n skip?: string[];\r\n framework?: AuditOptions[\"framework\"];\r\n}\r\n\r\n/**\r\n * The `lint` check as a test assertion: throws, listing every finding that\r\n * fails, unless the email passes. Plain throw, so it works in Vitest, Jest and\r\n * bun:test alike. Reads the project's `.emailensrc` like the CLI, so a test and\r\n * the CI step cannot disagree about the same email. Returns the findings.\r\n *\r\n * expectEmailToPass(await render(<Welcome />));\r\n */\r\nexport function expectEmailToPass(html: string, options: ExpectEmailOptions = {}): LintIssue[] {\r\n const project = loadProjectConfig();\r\n const skip = options.skip ?? project?.skip ?? [];\r\n const report = auditEmail(html, {\r\n framework: options.framework,\r\n skip: skip as AuditOptions[\"skip\"],\r\n positions: true,\r\n });\r\n const issues = applySeverities(flattenToLintIssues(report, skip), project?.rules);\r\n const failing = issues.filter(\r\n (i) => i.severity === \"error\" || (options.failOnWarning && i.severity === \"warning\"),\r\n );\r\n if (failing.length > 0) {\r\n const lines = failing.map(\r\n (i) => ` ${i.severity.padEnd(7)} ${i.loc ? `${i.loc.line}:${i.loc.column} ` : \"\"}${i.category} ${i.rule}: ${i.message}`,\r\n );\r\n throw new Error(`Email fails emailens lint (${failing.length}):\\n${lines.join(\"\\n\")}`);\r\n }\r\n return issues;\r\n}\r\n"],"mappings":";;;;;;;;;AAAA,SAAS,kBAAqC;AAsBvC,SAAS,kBAAkB,MAAc,UAA8B,CAAC,GAAgB;AAC7F,QAAM,UAAU,kBAAkB;AAClC,QAAM,OAAO,QAAQ,QAAQ,SAAS,QAAQ,CAAC;AAC/C,QAAM,SAAS,WAAW,MAAM;AAAA,IAC9B,WAAW,QAAQ;AAAA,IACnB;AAAA,IACA,WAAW;AAAA,EACb,CAAC;AACD,QAAM,SAAS,gBAAgB,oBAAoB,QAAQ,IAAI,GAAG,SAAS,KAAK;AAChF,QAAM,UAAU,OAAO;AAAA,IACrB,CAAC,MAAM,EAAE,aAAa,WAAY,QAAQ,iBAAiB,EAAE,aAAa;AAAA,EAC5E;AACA,MAAI,QAAQ,SAAS,GAAG;AACtB,UAAM,QAAQ,QAAQ;AAAA,MACpB,CAAC,MAAM,KAAK,EAAE,SAAS,OAAO,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,EAAE,IAAI,IAAI,IAAI,EAAE,IAAI,MAAM,MAAM,EAAE,GAAG,EAAE,QAAQ,IAAI,EAAE,IAAI,KAAK,EAAE,OAAO;AAAA,IACxH;AACA,UAAM,IAAI,MAAM,8BAA8B,QAAQ,MAAM;AAAA,EAAO,MAAM,KAAK,IAAI,CAAC,EAAE;AAAA,EACvF;AACA,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,75 +1,79 @@
1
- {
2
- "name": "@emailens/cli",
3
- "version": "0.11.0",
4
- "description": "CLI tool for email compatibility analysis: lint, preview and export HTML, MJML, Maizzle and React Email rendering across 21 email clients.",
5
- "type": "module",
6
- "bin": {
7
- "emailens": "./dist/index.js"
8
- },
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js"
13
- }
14
- },
15
- "main": "./dist/index.js",
16
- "types": "./dist/index.d.ts",
17
- "files": [
18
- "dist",
19
- "LICENSE"
20
- ],
21
- "scripts": {
22
- "build": "tsup",
23
- "dev": "tsup --watch",
24
- "start": "bun run dist/index.js",
25
- "typecheck": "tsc --noEmit",
26
- "test": "bun test",
27
- "prepublishOnly": "bun run build"
28
- },
29
- "dependencies": {
30
- "@emailens/engine": "^0.17.0",
31
- "citty": "^0.1.6",
32
- "cli-table3": "^0.6.5",
33
- "ora": "^8.2.0",
34
- "picocolors": "^1.1.1"
35
- },
36
- "optionalDependencies": {
37
- "@anthropic-ai/sdk": "^0.52.0",
38
- "playwright-core": "^1.62.1"
39
- },
40
- "devDependencies": {
41
- "@types/bun": "^1.4.0",
42
- "@types/mjml": "^4.7.4",
43
- "@types/node": "^25.9.5",
44
- "bun-types": "^1.4.0",
45
- "tsup": "^8.5.1",
46
- "typescript": "^5.9.3"
47
- },
48
- "keywords": [
49
- "email",
50
- "html-email",
51
- "css",
52
- "compatibility",
53
- "cli",
54
- "gmail",
55
- "outlook",
56
- "apple-mail",
57
- "email-testing",
58
- "dark-mode",
59
- "mjml",
60
- "maizzle",
61
- "react-email"
62
- ],
63
- "license": "MIT",
64
- "repository": {
65
- "type": "git",
66
- "url": "git+https://github.com/emailens/cli.git"
67
- },
68
- "engines": {
69
- "node": ">=18"
70
- },
71
- "homepage": "https://github.com/emailens/cli#readme",
72
- "bugs": {
73
- "url": "https://github.com/emailens/cli/issues"
74
- }
1
+ {
2
+ "name": "@emailens/cli",
3
+ "version": "0.13.0",
4
+ "description": "CLI tool for email compatibility analysis: lint, preview and export HTML, MJML, Maizzle and React Email rendering across 21 email clients.",
5
+ "type": "module",
6
+ "bin": {
7
+ "emailens": "./dist/index.js"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./test": {
15
+ "types": "./dist/test.d.ts",
16
+ "import": "./dist/test.js"
17
+ }
18
+ },
19
+ "main": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "files": [
22
+ "dist",
23
+ "LICENSE"
24
+ ],
25
+ "scripts": {
26
+ "build": "tsup",
27
+ "dev": "tsup --watch",
28
+ "start": "bun run dist/index.js",
29
+ "typecheck": "tsc --noEmit",
30
+ "test": "bun test",
31
+ "prepublishOnly": "bun run build"
32
+ },
33
+ "dependencies": {
34
+ "@emailens/engine": "^0.18.3",
35
+ "citty": "^0.1.6",
36
+ "cli-table3": "^0.6.5",
37
+ "ora": "^8.2.0",
38
+ "picocolors": "^1.1.1"
39
+ },
40
+ "optionalDependencies": {
41
+ "@anthropic-ai/sdk": "^0.52.0",
42
+ "playwright-core": "^1.62.1"
43
+ },
44
+ "devDependencies": {
45
+ "@types/bun": "^1.4.0",
46
+ "@types/mjml": "^4.7.4",
47
+ "@types/node": "^25.9.5",
48
+ "bun-types": "^1.4.0",
49
+ "tsup": "^8.5.1",
50
+ "typescript": "^5.9.3"
51
+ },
52
+ "keywords": [
53
+ "email",
54
+ "html-email",
55
+ "css",
56
+ "compatibility",
57
+ "cli",
58
+ "gmail",
59
+ "outlook",
60
+ "apple-mail",
61
+ "email-testing",
62
+ "dark-mode",
63
+ "mjml",
64
+ "maizzle",
65
+ "react-email"
66
+ ],
67
+ "license": "MIT",
68
+ "repository": {
69
+ "type": "git",
70
+ "url": "git+https://github.com/emailens/cli.git"
71
+ },
72
+ "engines": {
73
+ "node": ">=18"
74
+ },
75
+ "homepage": "https://github.com/emailens/cli#readme",
76
+ "bugs": {
77
+ "url": "https://github.com/emailens/cli/issues"
78
+ }
75
79
  }