Skip to content

Commit 129242f

Browse files
chore(charlie): align next/v3 docs/playbooks with main for Raw, Conditional, tests (#361)
Co-authored-by: CharlieHelps <[email protected]>
1 parent 57cf7bf commit 129242f

File tree

3 files changed

+129
-0
lines changed

3 files changed

+129
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Charlie instructions for jsx-email (next/v3 branch)
2+
3+
Repo‑specific rules that keep Charlie aligned with this codebase and review preferences. Keep diffs small, mirror existing patterns, and don’t widen scope beyond the request.
4+
5+
## Scope
6+
Applies to the entire repository, with extra focus on `packages/jsx-email` and its tests.
7+
8+
## Context
9+
- Monorepo using pnpm + Moon. Most tasks are run with `pnpm moon run <project>:<task>`.
10+
- Task inheritance lives in `.moon/tasks.yml`. Each project can add/override tasks in its own `moon.yml` (for example, `packages/jsx-email/moon.yml`). The root `moon.yml` defines repository tasks and is aliased as the `repo` project.
11+
- TypeScript uses ESM with NodeNext resolution; relative imports in source include the `.js` suffix.
12+
- Tests use Vitest; snapshots live in `.snapshots` next to tests (custom resolver).
13+
- GitHub Actions sets `FORCE_COLOR=1` when running tests; local runs must mirror this to avoid ANSI snapshot diffs.
14+
- Conventional Commits are the norm (e.g., `fix(jsx-email): …`). PRs should use the repository template.
15+
- Conventional Commit scopes map to affected project name(s) under `packages/` (e.g., `(jsx-email)`, `(plugin-inline)`, `(create-jsx-email)`). When multiple projects are affected, list each name in the scope, comma‑separated with no spaces (e.g., `(plugin-inline,plugin-pretty)`). PRs should use the repository template.
16+
- For the ongoing `next/v3` alignment work on `<Raw>` / `<Conditional>` behavior and core correctness (tracked in #348), branch from `origin/next/v3` and open pull requests with `base` set to `next/v3` (not `main`). Mention `#348` in the PR description for traceability.
17+
18+
## Rules
19+
- [R1] Stay on task. Do not add refactors, helpers, or style tweaks outside the explicit ask. Keep diffs minimal.
20+
- [R2] Tests and snapshots:
21+
- Run with `FORCE_COLOR=1` to match CI.
22+
- Never change log/ANSI‑colored snapshots to “de‑colorize” or “stabilize” output. If a log snapshot fails, fix the cause or mirror CI settings; do not rewrite the assertion shape.
23+
- Do not introduce “snapshot normalization” helpers (e.g., projecting only parts of config objects) unless a maintainer requests it.
24+
- Place/update snapshots under `.snapshots` alongside the test file; prefer targeted assertions plus snapshots when behavior changes intentionally.
25+
- [R3] Writing tests for `packages/jsx-email`:
26+
- Prefer importing from package source (e.g., `../src/index.ts`) for new tests to avoid prebuild coupling. If an existing suite imports from `dist`, keep that pattern for that suite.
27+
- Avoid adding `// @ts-ignore` to suppress React imports; tests can rely on the React automatic JSX runtime. Don’t add new ignores.
28+
- Follow NodeNext import style in source files (relative imports include `.js`).
29+
- [R4] Verification commands (run locally before marking a PR Ready for changes that affect code, tests, or tooling config):
30+
- Build artifacts used by tests:
31+
- `pnpm moon run plugin-inline:build plugin-minify:build plugin-pretty:build`
32+
- `pnpm moon run jsx-email:build`
33+
- Lint: `pnpm moon run repo:lint`
34+
- Tests (jsx-email package, mirroring the `next/v3` CI setup): `pnpm moon run jsx-email:test`
35+
- TypeScript (package): `pnpm moon run jsx-email:tsc`
36+
- Do not change tool configs or CI to make checks pass.
37+
- For documentation-only or `.charlie`-only changes that do not affect CI, code, or tests, you may skip these commands, but prefer running at least `pnpm moon run repo:lint` when in doubt.
38+
- [R4.1] Linting (must run before pushing any commits):
39+
- Run repo linting via Moon: `pnpm moon run repo:lint`.
40+
- Do not push if linting reports errors anywhere. Fix them or coordinate a follow‑up if they are unrelated but surfaced by your changes.
41+
- If linting reports warnings in files you modified, resolve those warnings before pushing.
42+
- For quick checks while iterating, you may run ESLint scoped to touched files, but always run the full `repo:lint` before the final push.
43+
- [R5] Git & PRs:
44+
- Branch names (from humans): `{type}/{project}/{short-desc}` — for example, `fix/jsx-email/conditional-endif-slash`. Use the package with the most changes (or the intended target) for `{project}`, and let `{short-desc}` be a descriptive phrase or a short slug.
45+
- Conventional Commits scope = affected project name(s) from `packages/`. Examples: `fix(jsx-email): …`, `refactor(plugin-inline,plugin-pretty): …`. For multiple projects, list names comma-separated with no spaces.
46+
- Commit messages use Conventional Commits; ≤ 72 chars in the subject; no emojis.
47+
- PRs must use the repository template as-is — Charlie is not allowed to remove sections from the template.
48+
- Start as Draft when work is in flux; mark Ready only after local verification passes and the description reflects the actual changes.
49+
- Don’t add novel labels. Assign and request review from the human requester when appropriate.
50+
51+
> Conditional/Raw specifics have been moved to a dedicated playbook. See `.charlie/playbooks/conditional-and-raw.md`.
52+
53+
## References
54+
1. CI workflow (test color): `.github/workflows/test-*.yml` (see `FORCE_COLOR=1` in test steps)
55+
2. Vitest shared config: `shared/vitest.config.ts`
56+
3. Moon tasks inheritance: `.moon/tasks.yml`; per-project tasks: `apps/*/moon.yml`, `packages/*/moon.yml`, `test/*/moon.yml`; repository tasks: `moon.yml` (project `repo`)
57+
4. jsx-email package tasks: `packages/jsx-email/moon.yml`
58+
5. Conventional Commits: https://www.conventionalcommits.org/en/v1.0.0/
59+
6. Conditional/Raw playbook: `.charlie/playbooks/conditional-and-raw.md`
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Conditional + Raw playbook (renderer and tests) — next/v3 branch
2+
3+
Apply this when changing how `<Conditional>` or `<Raw>` render (MSO/expr tokens, wrappers, or how nested Raw is inlined).
4+
5+
This copy lives on the `next/v3` branch. For the ongoing alignment work on `<Raw>` / `<Conditional>` semantics and tests (tracked in #348):
6+
- Branch from `origin/next/v3`.
7+
- Open pull requests with `base` set to `next/v3` (not `main`).
8+
- Mention `#348` in the PR description so reviewers can tie the change back to the alignment effort.
9+
10+
Rules
11+
- Include targeted tests and keep snapshot updates minimal (only intentional markup diffs).
12+
- Do not introduce token “centralization” helpers or adjacency tests unless a maintainer explicitly requests them.
13+
- Import from source for new tests to avoid prebuild coupling: `import { Conditional, Raw, render } from '../src/index.ts'`.
14+
15+
Test guidelines
16+
- Closer/opener integrity
17+
- Assert exactly one opener and closer for MSO: `<!--[if mso]>` and the current closer `<![endif]/-->`.
18+
- Add a small case for the expression path (e.g., `expression="gte mso 16"`) and assert the same closer.
19+
- No‑duplication when nesting Raw
20+
- For `<Conditional mso><Raw …/></Conditional>`, assert the inner payload appears exactly once and not outside the block.
21+
- Use `lastIndexOf` for closer slicing and allow opener at index `>= 0`.
22+
- Snapshots and colorized logs
23+
- Run with `FORCE_COLOR=1` to match CI. Never “de‑colorize” or normalize log snapshots.
24+
25+
Commands (jsx-email)
26+
- Build artifacts some suites rely on: `pnpm moon run plugin-inline:build plugin-minify:build plugin-pretty:build && pnpm moon run jsx-email:build`
27+
- Tests (CI‑aligned for `next/v3`): `pnpm moon run jsx-email:test` (the Moon task sets `FORCE_COLOR=1` like CI)
28+
- TypeScript: `pnpm moon run jsx-email:tsc`
29+
30+
References
31+
- CI workflow (color): `.github/workflows/test-*.yml` (look for `FORCE_COLOR=1`)
32+
- Shared Vitest config: `shared/vitest.config.ts`
33+
- Package tasks: `packages/jsx-email/moon.yml`
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Run jsx-email tests locally exactly like CI (Moon + FORCE_COLOR) — next/v3 branch
2+
3+
## Overview
4+
Run the `packages/jsx-email` test suite locally with the same settings the `next/v3` branch uses in CI so snapshots (including ANSI color) match exactly.
5+
6+
For the ongoing `next/v3` alignment work on `<Raw>` / `<Conditional>` behavior and core correctness (tracked in #348), branch from `origin/next/v3`, open PRs with `base` set to `next/v3` (not `main`), and mention `#348` in the PR description.
7+
8+
## Prerequisites
9+
- Capabilities: GitHub + Devbox write access (local or CI).
10+
- Tools: pnpm, Moon tasks (configured in this repo).
11+
- Context: Some suites import from `dist/esm`, so plugin packages must be built first.
12+
13+
## Steps
14+
1. Install deps and build required artifacts
15+
- `pnpm install`
16+
- `pnpm moon run plugin-inline:build plugin-minify:build plugin-pretty:build`
17+
- `pnpm moon run jsx-email:build`
18+
2. Run tests with color forced (matches CI)
19+
- `pnpm moon run jsx-email:test` <!-- task sets FORCE_COLOR=1 in Moon config on next/v3 -->
20+
3. Optional: update snapshots only for intentional HTML/markup changes (never for log/ANSI deltas)
21+
- `cd packages/jsx-email && pnpm vitest -u --config ../../shared/vitest.config.ts && cd -`
22+
4. TypeScript check (package)
23+
- `pnpm moon run jsx-email:tsc`
24+
25+
## Verify
26+
- Expect: `Test Files 44 passed`, `Tests 187 passed` (numbers may grow over time).
27+
- No snapshot diffs for logs when `FORCE_COLOR=1` is set (the `jsx-email:test` Moon task configures this automatically).
28+
29+
## Rollback
30+
- If you mistakenly updated snapshots for log/ANSI output, reset them:
31+
- `git restore --source=origin/$(git rev-parse --abbrev-ref HEAD) -- "packages/jsx-email/test/**/.snapshots/*.snap" || true`
32+
- Or discard all local changes: `git reset --hard`
33+
34+
## References
35+
- CI workflow (color): `.github/workflows/test-*.yml` (look for `FORCE_COLOR=1`)
36+
- Shared Vitest config: `shared/vitest.config.ts`
37+
- Moon project tasks: `packages/jsx-email/moon.yml`

0 commit comments

Comments
 (0)