Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ concurrency:

permissions:
contents: read
# @llazyemail/render-template is installed from GitHub Packages.
packages: read

jobs:
check:
Expand All @@ -33,9 +35,13 @@ jobs:
with:
node-version: ${{ matrix.node }}
cache: npm
registry-url: https://npm.pkg.github.com
scope: '@llazyemail'

- name: Install
run: npm ci --no-audit --no-fund
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Lint, format, typecheck, build, test
run: |
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read # @llazyemail/render-template comes from GitHub Packages
security-events: write
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
steps:
Expand All @@ -35,9 +36,13 @@ jobs:
with:
node-version: 26
cache: npm
registry-url: https://npm.pkg.github.com
scope: '@llazyemail'

- name: Install
run: npm ci --no-audit --no-fund
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install SARIF formatter
run: npm install --no-save --no-audit --no-fund @microsoft/eslint-formatter-sarif@3.1.0
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ jobs:
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# @llazyemail/render-template is installed from GitHub Packages.
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- uses: LLazyEmail/email-template-workflows@7b1ab4df2fb9391fea155effcef1aaaadf3efead # v3.1.0
with:
working-directory: .
package-manager: npm
registry-url: https://npm.pkg.github.com
registry-scope: '@llazyemail'
command: npm run generate
artifact-directory: generated
artifact-name: generated-html-templates
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:

- name: Install
run: npm ci --no-audit --no-fund
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Lint, format, typecheck, build, test
run: |
Expand Down
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Do not vendor or reimplement the part/compose runtime; use the re-exports from t

## Commands

`@llazyemail/render-template` is installed from GitHub Packages, so `npm install` needs `.npmrc` (copy `.npmrc.example`, never commit it) and `NODE_AUTH_TOKEN` with `read:packages`. Do not switch it back to a `github:` git pin.

```bash
npm install
npm run dev # tsup --watch
Expand Down Expand Up @@ -176,3 +178,4 @@ Use it to render a whole HTML email, to run a batch of templates that share one
- Do not lower coverage thresholds or `noUncheckedIndexedAccess`.
- Docs: extend or annotate outdated guidance; do not delete existing docs content.
- Release: GitHub Release (or manual `publish.yml`) publishes to GitHub Packages under `@llazyemail`.
- Workflows that run `npm ci` (CI, ESLint, Generate, Publish) configure `https://npm.pkg.github.com` for the `@llazyemail` scope and pass `NODE_AUTH_TOKEN: secrets.GITHUB_TOKEN` with `packages: read`. Keep that in any new workflow that installs dependencies.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ console.log(formatDiff(diffRenders(before, after)));
| `@llazyemail/render-template` | `dependencies` | The part/compose runtime. `RenderError`, `RenderOptions`, `RenderJob` and `renderMany` come from it and are re-exported. Installed for every consumer. |
| `markup-generator` | `devDependencies` | Only used by `test/write.test.ts` and `npm run generate` (`scripts/generate.mjs`) to write rendered HTML to disk. Not installed for consumers. |

`@llazyemail/render-template` is currently pinned via the GitHub ref `github:LLazyEmail/render-template#0.3.0` in `package.json`. Prefer a published version from GitHub Packages when one is available and compatible, to reduce install fragility.
This package builds on `@llazyemail/render-template`, installed as the published `^0.3.0` package from GitHub Packages (see `package.json`). It used to be pinned to the git ref `github:LLazyEmail/render-template#0.3.0`, which made npm run render-template's `prepare` (TypeScript build) on every install. The published package ships a prebuilt `dist/`, so nothing is compiled on install.

Parts must return **strings**. Lit `TemplateResult`s are not supported inside parts.

Expand All @@ -108,7 +108,7 @@ Generation/catalog/write logic belongs in `@llazyemail/generate-template`, not h

## Install

Published to GitHub Packages. Copy [`.npmrc.example`](./.npmrc.example) to `.npmrc` in the consuming project. `GITHUB_TOKEN` needs `read:packages`.
Published to GitHub Packages. Copy [`.npmrc.example`](./.npmrc.example) to `.npmrc` in the consuming project and set `NODE_AUTH_TOKEN` to a GitHub token with `read:packages`. The same `@llazyemail` scope line also resolves the `@llazyemail/render-template` dependency, so no extra setup is needed for it.

```bash
npm install @llazyemail/template-runtime-display
Expand Down Expand Up @@ -201,6 +201,8 @@ Subpath exports: `@llazyemail/template-runtime-display/escape`, `/head`, `/body`

## Scripts

Working on this repo needs the same registry setup as consuming it, because `@llazyemail/render-template` comes from GitHub Packages: copy `.npmrc.example` to `.npmrc` (do not commit it) and export `NODE_AUTH_TOKEN` with `read:packages`. In CI, `actions/setup-node` writes that config and the workflows pass `secrets.GITHUB_TOKEN` with `packages: read`.

```bash
npm install
npm run dev # tsup --watch
Expand Down
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,6 @@
"live-reload"
],
"dependencies": {
"@llazyemail/render-template": "github:LLazyEmail/render-template#0.3.0"
"@llazyemail/render-template": "^0.3.0"
}
}
Loading