From 8ce921f18ec27dbea8a272136020be2b7b7523fd Mon Sep 17 00:00:00 2001 From: petroved Date: Mon, 16 Nov 2026 21:23:58 +0000 Subject: [PATCH] fix(deps): install render-template from GitHub Packages instead of a git pin Closes #81 Co-authored-by: petroved --- .github/workflows/ci.yml | 6 ++++++ .github/workflows/eslint.yml | 5 +++++ .github/workflows/generate.yml | 4 ++++ .github/workflows/publish.yml | 2 ++ AGENTS.md | 3 +++ README.md | 6 ++++-- package-lock.json | 5 +++-- package.json | 2 +- 8 files changed, 28 insertions(+), 5 deletions(-) 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 bf36d03..4ce94e4 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 7670bd6..b821a7b 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ console.log(formatDiff(diffRenders(before, after))); ## Package ecosystem and Lit -This package builds on `@llazyemail/render-template` (currently pinned via 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. @@ -101,7 +101,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 @@ -194,6 +194,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 db7a4a7..387f8c4 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", "markup-generator": "^4.1.0" }, "bin": { @@ -842,7 +842,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 146f15d..1195452 100644 --- a/package.json +++ b/package.json @@ -157,7 +157,7 @@ "live-reload" ], "dependencies": { - "@llazyemail/render-template": "github:LLazyEmail/render-template#0.3.0", + "@llazyemail/render-template": "^0.3.0", "markup-generator": "^4.1.0" } }