diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e105cec..92c5ae3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,8 @@ concurrency: permissions: contents: read + # @llazyemail/render-template is installed from GitHub Packages. + packages: read jobs: check: @@ -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: | diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index 982bf11..2b02a37 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -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: @@ -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 diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 33d007f..7031b25 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -27,6 +27,8 @@ 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 @@ -34,6 +36,8 @@ jobs: 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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 918aca1..5dd385d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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: | diff --git a/AGENTS.md b/AGENTS.md index 6ae9d72..9ba62eb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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 @@ -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. diff --git a/README.md b/README.md index 38d5f48..6cf1cf9 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 @@ -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 diff --git a/package-lock.json b/package-lock.json index 4d97b1f..689b8c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.2.1", "license": "MIT", "dependencies": { - "@llazyemail/render-template": "github:LLazyEmail/render-template#0.3.0" + "@llazyemail/render-template": "^0.3.0" }, "bin": { "template-runtime-display": "dist/cli.js" @@ -841,7 +841,8 @@ }, "node_modules/@llazyemail/render-template": { "version": "0.3.0", - "resolved": "git+ssh://git@github.com/LLazyEmail/render-template.git#ff0702d378646ad921da2b1870425e01df16e7dc", + "resolved": "https://npm.pkg.github.com/download/@llazyemail/render-template/0.3.0/3ecfc0a03172173f4fa47d436208e86b442b16a5", + "integrity": "sha512-y3RGjTf42fGnHE7v/dxOZr1R22gSs1lcOKlAXxfixYnKz0M/rlGU58M4Pny6M+SiPiCZX9CLBI4BzzEtCdxG0g==", "license": "MIT", "engines": { "node": ">=22" diff --git a/package.json b/package.json index fb1a2a3..831e212 100644 --- a/package.json +++ b/package.json @@ -157,6 +157,6 @@ "live-reload" ], "dependencies": { - "@llazyemail/render-template": "github:LLazyEmail/render-template#0.3.0" + "@llazyemail/render-template": "^0.3.0" } }