email brand hygiene #11
@@ -341,7 +341,7 @@ Cheap catch for future drift, and the **gate** for Tasks 6–9. No test framewor
|
||||
**Interfaces:**
|
||||
- Produces: a script that exits non-zero if any `email/*.html` (excluding `partials/`) is missing a header IMPORT, footer IMPORT, or `<!-- preheader -->` marker. Run after every template conversion.
|
||||
|
||||
- [ ] **Step 1: Write the script**
|
||||
- [x] **Step 1: Write the script**
|
||||
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
@@ -372,12 +372,12 @@ if (failures.length) {
|
||||
console.log(`Email template check passed (${files.length} templates).`);
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Run it — expect failures for every not-yet-converted template, pass for `reset.html`**
|
||||
- [x] **Step 2: Run it — expect failures for every not-yet-converted template, pass for `reset.html`**
|
||||
|
||||
Run: `node scripts/check-emails.js`
|
||||
Expected: FAIL, listing `welcome.html`, `verify-email.html`, `reset_notify.html`, `registration_accepted.html`, `invitation.html`, `banned.html`, `test.html`, `notification.html`, `digest.html` (reset.html absent from the list). This proves the guard discriminates.
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
- [x] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add scripts/check-emails.js
|
||||
|
||||
@@ -60,6 +60,9 @@ them to users on various events (password reset, digest, ban, etc.).
|
||||
comments. Keep that structure — don't refactor into modern CSS.
|
||||
- Don't hardcode user-facing copy; add/replace `[[email:…]]` keys and define
|
||||
them in the language files.
|
||||
- Run `node scripts/check-emails.js` after converting templates. It enforces
|
||||
the shared-partial structure by requiring a header import, footer import,
|
||||
and `<!-- preheader -->` marker in each `email/*.html` file.
|
||||
- Rebuild (`./nodebb build`) and use the ACP test-email button to verify.
|
||||
|
||||
## References
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env node
|
||||
// ponytail: 30-line structural guard, not a render test. Catches drift, not pixels.
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const dir = path.join(__dirname, '..', 'email');
|
||||
const files = fs.readdirSync(dir).filter((f) => f.endsWith('.html'));
|
||||
|
||||
const failures = [];
|
||||
for (const f of files) {
|
||||
const src = fs.readFileSync(path.join(dir, f), 'utf8');
|
||||
const checks = [
|
||||
[/IMPORT emails\/partials\/header\.(html|tpl)/, 'missing header IMPORT'],
|
||||
[/IMPORT emails\/partials\/footer\.(html|tpl)/, 'missing footer IMPORT'],
|
||||
[/<!-- preheader -->/, 'missing preheader marker'],
|
||||
];
|
||||
for (const [re, msg] of checks) {
|
||||
if (!re.test(src)) failures.push(`${f}: ${msg}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (failures.length) {
|
||||
console.error('Email template check FAILED:\n' + failures.join('\n'));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`Email template check passed (${files.length} templates).`);
|
||||
Reference in New Issue
Block a user