From 0c67de0e60ce23ad8825c2b96d2f3e129566bbbc Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Tue, 1 Dec 2026 22:24:22 +0100 Subject: [PATCH 1/5] PFM-ISSUE-34294 - Add research and design for the runtime-generated .npmrc and DOT_NPMRC cutover Co-Authored-By: Claude Opus 5.5 --- .../design.md | 350 +++++++++++++++++ .../research.md | 356 ++++++++++++++++++ 2 files changed, 706 insertions(+) create mode 100644 specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/design.md create mode 100644 specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/research.md diff --git a/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/design.md b/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/design.md new file mode 100644 index 0000000..fcae149 --- /dev/null +++ b/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/design.md @@ -0,0 +1,350 @@ +--- +date: 2026-12-01 +ticket: PFM-ISSUE-34294 +related: PFM-ISSUE-33675 +topic: "Runtime-generated read .npmrc from JFROG_TOKEN and removal of DOT_NPMRC from master" +status: approved-for-planning +research: ./research.md +--- + +# Runtime-generated `.npmrc` and `DOT_NPMRC` cutover - Design Approach + +## Overview + +Replace the stored whole-`.npmrc` secret `DOT_NPMRC` in the shared FE workflows with a `~/.npmrc` generated at +runtime from the existing per-repo `JFROG_TOKEN` (introduced by PFM-ISSUE-34293). `use-npmrc` is rewritten in place +to generate the file. A short dual-support window lets the FE repos switch over, and then every `DOT_NPMRC` +reference is removed from master. Deleting the repo secrets is left to a separate cleanup ticket. + +## Problem Statement + +Install-time npm auth comes from `DOT_NPMRC`, a per-repo secret holding a complete, hand-maintained `.npmrc` that +`use-npmrc` writes verbatim to `~/.npmrc` ([Research §1](./research.md)). The routing and credentials live in +opaque secret text, they drift between repos, and they cannot be reviewed. Publishing already generates its own +`.npmrc` from `JFROG_*` (34293). PFM-ISSUE-34294 asks to generate the read `.npmrc` the same way and to remove +`DOT_NPMRC`. The removal gate, PFM-ISSUE-34301 (all third-party registries proxied through JFrog, Bryntum lockfile +PRs #476–#480 merged), is met. + +### Requirements +- The install/read `~/.npmrc` is generated at workflow runtime, not stored as a secret. +- Installs and publishes succeed with the generated file. +- No FE workflow on master relies on `DOT_NPMRC`; `DOT_NPMRC` and its `use-npmrc` usage are removed from master. +- Keep the PFM-ISSUE-34453 `replace-registry-host=never` mitigation and the advisory `warn-foreign-registry.sh` step. + +### Constraints +- Default branches follow the reusables and `use-npmrc` at `@master`. Removing a declared secret breaks callers + that still pass it, and adding a required one breaks callers that don't. +- Release branches are self-contained. On 25.2–26.4 they pin `use-npmrc@release/X.Y`, and 23.1–25.1 use + `bduff9/use-npmrc@v1.1`. No release line loads the composite from master, so they keep working for as long as + the `DOT_NPMRC` repo secret exists. +- Credentials are per repo. project-planning-fe must read as `svcusr_cf_projplanning-fe`, the only build identity + in `bryntum-readers`, and that account is also its `JFROG_USER`. +- Live testing happens only on `clone-cplace-fe`, never on real `release/*` branches. Secret changes need the + user's consent. + +## Design Decisions Summary + +1. **One credential, `JFROG_TOKEN`, for read and publish**: the generated `~/.npmrc` authenticates with each + repo's existing per-repo `JFROG_TOKEN`. No separate read secret is introduced. + - In most repos the `DOT_NPMRC` install user is already the `JFROG_USER` account + (`secrets-comparison.md`), and for project-planning-fe this is exactly the Bryntum-entitled identity. + - 33675 AC1 (separate read/publish secrets) and AC3 (read-only jobs without publish credential) are dropped. + This is recorded on the ticket. +2. **Generation in `use-npmrc`, rewritten in place, with a literal token**: the composite keeps its path and name + and gains a `jfrog-token` input. It writes the token literally into `~/.npmrc` (`chmod 600`, never echoed). + - Exposure is the same as today (credentials already sit in `~/.npmrc`), and no per-step env wiring is + needed: every later npm call in the job authenticates, including the `npm view`/`npm search` calls in + `artifacts`/`snapshots`. + - The `replace-registry-host=never` line, the warn step, the bats tests and the comments that name + `use-npmrc` all stay. The inaccurate comments at `:20` and `:44` are corrected. +3. **Minimal file content from the shared proxy constant**: `registry=` and `_authToken` keyed to the + `cplace-npm` virtual, plus `replace-registry-host=never`. There are no scope lines. + - The URL comes from `JFROG_NPM_PROXY` (`tools/scripts/lockfile/lib.sh:20`), the single source of truth + shared with the lockfile checks. No URL secret is used. + - `@fortawesome`, own scopes and Bryntum all resolve through `cplace-npm`, so none of them is handled + specially. +4. **Dual-support window, token wins**: during migration `use-npmrc` takes `jfrog-token` and `dot-npmrc`, both + optional, and the reusables declare `JFROG_TOKEN` and `DOT_NPMRC` as `required: false`. + - Token present: the action generates the file and ignores `DOT_NPMRC`. Only `DOT_NPMRC`: it writes that + verbatim and emits a `::warning::` deprecation. Neither: it fails with `::error::`. This mirrors 34293's + `JfrogCredentials.authMode`. + - Callers that already receive `JFROG_TOKEN` switch at merge: `fe-release-flow` via `secrets: inherit`, and + the mixed publish/delete jobs. The user checks every repo's `JFROG_TOKEN` for `cplace-npm` read access + before the merge. +5. **Removal scope: everything on master in two PRs, secrets deleted elsewhere**: + - PR 1: dual support, templates (pass `JFROG_TOKEN` instead of `DOT_NPMRC`) and the README. Callers then + migrate repo by repo. + - PR 2, once every default-branch caller has migrated: drop the `DOT_NPMRC` declarations from all + reusables, drop the `dot-npmrc` input and fallback from `use-npmrc`, and make `jfrog-token` required. + - Deleting the `DOT_NPMRC` repo secrets is a separate cleanup ticket. It waits for the last release line + through 26.4 to go out of support and for the external direct consumers to migrate. +6. **Validation follows the 34293 process**: the user's pre-merge token check, then a live matrix on + `clone-cplace-fe`, then two reference repos. + - The matrix covers four input cases: token only, `DOT_NPMRC` only, both, neither. It runs install-deps, + licenses, sonar, pr-snapshot, pr-close, cleanup-snapshots and the release flow, and includes a log check + that the token never appears. + - Reference repos: `cplace-remote-filesystem-fe` (34293 pilot) and `cplace-project-planning-fe` (Bryntum + identity), green before the remaining 12 repos. + +This means: +- Nothing about install auth is hidden in secret text anymore: the read registry is committed code, and the only + secret is the token each repo already has. +- Most FE workflows switch to the generated file the moment PR 1 merges. Per-repo work is adding `JFROG_TOKEN` + to the `install-deps`/`licenses`/`sonar` callers and deleting `DOT_NPMRC` lines. +- Repos that haven't migrated show up as deprecation warnings in their run summaries, and a misconfigured repo + fails with an explicit error instead of an anonymous npm 401/404. +- After PR 2, master contains no reference to `DOT_NPMRC`. Release lines keep running unchanged on their own + pinned `use-npmrc` and the still-existing repo secret. +- The cleanup-snapshots `npm view`/`npm search` E404 (D2) is expected to disappear as a side effect. + +Major trade-offs we're accepting: +1. **No least-privilege split between read and publish**: read-only jobs (`fe-install-deps`, `fe-licenses`, + `fe-sonar`) now receive a token that can deploy and delete on `cplace-npm-local`. In exchange we avoid a + second set of secrets to provision and maintain, and avoid a special identity case for project-planning-fe. + 33675 AC1/AC3 are dropped explicitly rather than met. +2. **The token is on disk in `~/.npmrc`**, unlike the dist `.npmrc`'s placeholder style. In exchange there is no + fragile per-step env wiring. Exposure is the same as with today's `DOT_NPMRC`. +3. **Big switch at merge instead of per-repo opt-in**: with the token winning, the release flow and the mixed jobs + switch in all repos at once, and rollback is a master revert. In exchange there are far fewer caller edits. + The risk is moved before the merge through the token check and the clone matrix. +4. **Strict auth scope**: lockfile entries still pointing directly at a non-proxy URL (e.g. `cplace-npm-local/`) + are fetched without auth and fail. In exchange the token goes only to the read registry, and leftovers are + exposed instead of masked. The 34301 audit and the warn step cover this. + +What we're NOT doing (out of scope): +- Deleting `DOT_NPMRC` repo secrets (separate cleanup ticket). +- Backporting to release lines 23.1–26.4. +- Migrating direct `DOT_NPMRC` consumers outside this repo: cplace-e2e (`bduff9/use-npmrc`, no `JFROG_*`), + cplace-fe (visual-regression, xray, Windows PR, devkit-test-template, `deploy_storybook`/`DOT_NPMRC_CONTENT`), + and project-planning-fe (`bryntum-update.yml`, `sonar-scan.yml`). Each is a follow-up. +- A separate read token or read-scoped identity (`JFROG_READ_*`), and the org-level `ENV_CPLACE_ARTIFACTORY_*` pair. +- Adding `~/.npmrc` generation to `fe-snapshot` or `fe-check-upmerge`, which work without it today. +- Removing JFrog secrets from `fe-tag` (decided in 34293), and `dist/` / `.gitignore` test hygiene. +- Minting tokens or setting secrets (done by the user). + +Success criteria: +- On `clone-cplace-fe`, all four input cases behave as specified across the full workflow set, cleanup-snapshots + no longer fails with E404, and no log line contains the token value. +- `cplace-remote-filesystem-fe` and `cplace-project-planning-fe` (including the Bryntum packages) run CI green on + `JFROG_TOKEN` with no `DOT_NPMRC` passed. +- After PR 2, `git grep -i dot_npmrc` on master finds no workflow, template or action reference, and all 14 FE + repos' default-branch CI stays green. + +## Design Decisions - Details + +### Read credential: identity and scoping + +**Chosen Approach:** Reuse each repo's existing per-repo `JFROG_TOKEN` (a JFrog reference token of the +`JFROG_USER` service account) for installs as well as publishing. + +**Rationale:** The secrets comparison shows that in most repos the `DOT_NPMRC` install user already is the +`JFROG_USER` account, so the account behind `JFROG_TOKEN` already reads `cplace-npm`. A separate shared read +token would complicate project-planning-fe, whose Bryntum access is bound to `svcusr_cf_projplanning-fe`, and +that account is its `JFROG_USER`. One token per repo keeps provisioning as it is today. Repos to double-check +during the pre-merge token check: office-reports-fe and workflow-fe (`JFROG_USER` `svcusr_cf_lowcode_jfrog` vs +`.npmrc` user `svcusr_cf_cplace_docu`), and resource-management-fe (opaque token, read identity unknown). + +**Alternatives Considered:** +- **Separate read token (`JFROG_READ_*`), shared identity**: rejected. project-planning-fe would need an + override or a change to the `bryntum-readers` membership, and the provisioning effort doubles. +- **Read-scoped second token of the same service account**: rejected. It would keep 33675 AC3, but doubles + per-repo provisioning for a least-privilege gain the user chose to forgo. +- **Org-level `ENV_CPLACE_ARTIFACTORY_ACTOR/_TOKEN`**: rejected. It collapses identities and its rights are + unknown (as already rejected in 34293). +- **Separate read token, recommended initially**: in the problem framing, reusing `JFROG_TOKEN` was treated as + ruled out by 34293 Decision 7 ("publish tokens may lack read on the virtual"). This was overturned by the + user: the assumption that the publish identity differs from the install identity did not hold for most repos, + and the project-planning-fe identity requirement favours reuse. + +**Implications:** +- 33675 AC1/AC3 must be formally revised on the ticket (by the user, together with the requester). +- Read-only reusables now declare `JFROG_TOKEN`, a publish-capable credential. + +--- + +### Generation mechanism and token handling + +**Chosen Approach:** Rewrite `.github/actions/use-npmrc` in place. It gets a new `jfrog-token` input, and the +token is written literally into `~/.npmrc` with mode `600` and never echoed. + +**Rationale:** Keeping the path keeps every `@master` call site and the warn-step tooling valid. A literal token +matches today's `~/.npmrc` exposure and needs no env propagation. With a `${JFROG_TOKEN}` placeholder, any npm +or npx call in the job without that env var fails with "Failed to replace env in config". + +**Alternatives Considered:** +- **Placeholder `${JFROG_TOKEN}` with per-step `env:`**: rejected because it's fragile. Every npm step in about 8 + workflows would need the env var, and a forgotten line breaks only at runtime. +- **Placeholder plus export via `$GITHUB_ENV`**: rejected. It puts the token into the process env of every later + step, including third-party actions, which is broader exposure than a file in HOME. +- **New composite / TypeScript generator next to `writeNPMRCInDist`**: not pursued. In-place keeps the contract + stable and the shell composite already hosts both behaviours to preserve. + +**Implications:** +- The `artifacts`/`snapshots` composites' `printenv` does not print files, and the token is a masked secret value. +- Comments at `action.yml:20` (prefix misattributed to `JFROG_URL`) and `:44` ("seven workflows") are corrected. + +--- + +### Generated file content and URL source + +**Chosen Approach:** A minimal file containing `registry=` set to the `cplace-npm` virtual, `_authToken` keyed to +that same path, and `replace-registry-host=never`. The URL comes from the committed `JFROG_NPM_PROXY` constant +in `tools/scripts/lockfile/lib.sh`. + +**Rationale:** This matches the 34301 design's target file. The lockfile checks and the install config share +one source of truth, and the token goes only to the read registry. + +**Alternatives Considered:** +- **Auth keyed at `//cplace.jfrog.io/artifactory/api/npm/`**: rejected. It relies on unverified npm parent-path + credential matching, masks leftover non-proxy lockfile entries the audit is meant to remove, and sends the + token to every npm repo on the host. +- **Scope lines (`@fortawesome`, own scopes)**: not needed, because all of them resolve through `cplace-npm`. + +**Implications:** +- The composite must load the constant from `lib.sh` (it already reaches `tools/scripts/lockfile/` through + `$GITHUB_ACTION_PATH`). +- Any repo with lockfile entries outside the proxy prefix fails to install. The warn step and a pre-merge + `npm ci` per identity group catch this early. + +--- + +### Transition: precedence during the dual-support window + +**Chosen Approach:** The token wins. `DOT_NPMRC` is the fallback and emits a deprecation `::warning::`. If +neither is present, the action fails with an explicit `::error::`. Both secrets are declared `required: false` +on the reusables during the window. + +**Rationale:** This is consistent with 34293's `JFROG_TOKEN`/`JFROG_BASE64_TOKEN` handling. It needs the fewest +caller edits, because the release flow (`secrets: inherit`) and the mixed jobs already receive `JFROG_TOKEN`. +Unmigrated repos are visible as warnings. + +**Alternatives Considered:** +- **`DOT_NPMRC` wins while present**: rejected. `fe-release-flow` with `secrets: inherit` could never switch + before the final removal, so the big switch would only move later. There would also be no deprecation signal, + and precedence would be the reverse of 34293. + +**Implications:** +- Mandatory pre-merge check, done by the user: every repo's `JFROG_TOKEN` can read `cplace-npm`. +- Rollback during the window is a master revert, not a per-repo edit. +- `fe-release-flow`'s nested `install-deps` call gains `JFROG_TOKEN` in its explicit secret list. + +--- + +### Removal scope and release-line reach + +**Chosen Approach:** Master only, in two PRs within this ticket. PR 1 adds dual support, templates and README. +PR 2, after all default-branch callers have migrated, removes the `DOT_NPMRC` declarations, the `dot-npmrc` +input and the fallback, and makes `jfrog-token` required. Deleting the repo secrets is a separate cleanup ticket. + +**Rationale:** Release branches pin their own `use-npmrc` (`@release/X.Y` on 25.2–26.4, `bduff9/use-npmrc@v1.1` +on 23.1–25.1) and never load it from master. So master can drop the fallback entirely without affecting them. +Only the repo secret keeps release lines alive. + +**Alternatives Considered:** +- **This ticket only opens the window, and a follow-up closes it (34293 style)**: rejected, because 34294 would + close without removing anything. +- **Backport to release lines and remove everything now**: rejected. It touches 4+ release lines across 14 repos + against the master-only practice, and still can't delete the secrets before the external consumers migrate. + +**Implications:** +- The ticket stays open while 14 repos migrate. PR 2 is gated on every default-branch caller being migrated. +- Residual risk: a consumer's release branch still pointing at `@master` reusables (contrary to the README) + would break at PR 2. A check across the 14 repos before PR 2 covers this. + +--- + +### Validation and reference repositories + +**Chosen Approach:** The user's pre-merge token check, then a live matrix on `clone-cplace-fe` (master +redirected to the feature branch) covering the four input cases across install-deps, licenses, sonar, +pr-snapshot, pr-close, cleanup-snapshots and the release flow, plus a token-leak log check. After that, +`cplace-remote-filesystem-fe` and `cplace-project-planning-fe` serve as reference repos (33675 AC4) before the +remaining 12. + +**Rationale:** Under token-wins precedence the merge itself is the big switch, so every precedence branch and +the D2 path must be proven on the clone first. project-planning-fe covers the identity-sensitive Bryntum case. + +**Alternatives Considered:** +- **Pilot only, no clone matrix**: rejected. A defect would surface across production repos at merge, and the + fallback and error paths would go unproven before they're live. + +**Implications:** +- A `live-test-plan.md` is created during planning, modelled on 34293's. + +--- + +### Side issues from the research + +**Chosen Approach:** +- In scope: correcting the `use-npmrc` comments, the deprecated `fe-release.yml` (still on the live path), and + verifying D2 through the matrix without dedicated code. +- Unchanged: the warn script path, bats tests, `fe-snapshot`, `fe-check-upmerge`. +- Out of scope: `fe-tag` JFrog secrets, `dist/`/`.gitignore`. + +**Rationale:** Keep the change focused on the cutover. Items already decided elsewhere (34293) or unrelated stay +out. + +**Implications:** +- If D2 persists with the new token, it stays with its own ticket. + +## Overall Architecture + +At install time each FE job runs `use-npmrc`, which builds `~/.npmrc` from the committed read registry constant +and the repo's `JFROG_TOKEN`, appends the npm-11 mitigation, and runs the advisory lockfile warning. `npm ci` and +every later npm call in the job authenticate through that file. Publishing and deleting keep using the dist +`.npmrc` generated by the TypeScript tooling from the same `JFROG_TOKEN` passed as step env. So one per-repo +token now drives both files, and no npm configuration is stored as a secret. + +### Key Components +1. **`.github/actions/use-npmrc`**: generates `~/.npmrc` from `jfrog-token`. During the window it falls back to + `dot-npmrc` with a warning. It keeps `replace-registry-host=never` and the warn step. +2. **`JFROG_NPM_PROXY` (`tools/scripts/lockfile/lib.sh`)**: the single committed source of the read registry URL. +3. **Reusables** (`fe-install-deps`, `fe-licenses`, `fe-sonar`, `fe-pr-snapshot`, `fe-pr-close`, + `fe-cleanup-snapshots`, `fe-release`, `fe-release-flow`): pass `JFROG_TOKEN` to `use-npmrc`. They declare + `DOT_NPMRC` as optional during the window and drop it in PR 2. +4. **Templates (`.github/workflow-templates/fe/`) and README**: pass and document `JFROG_TOKEN` in place of + `DOT_NPMRC`. +5. **Dist `.npmrc` writer (`nx-project.ts`)**: unchanged. + +### Data Flow +`JFROG_TOKEN` repo secret → reusable `secrets.JFROG_TOKEN` → `use-npmrc` input → `~/.npmrc` (read, `cplace-npm`) +→ `npm ci` / `npm view` / `npm search`. In parallel: `JFROG_TOKEN` → `artifacts`/`snapshots` step env → +`dist//.npmrc` placeholder → `npm publish` / `dist-tag` / `unpublish` on `cplace-npm-local`. + +### Integration Points +- FE consumer repos' workflow callers (templates, hand-wired `fe-sonar` callers). +- `fe-release-flow` via `secrets: inherit` (no caller edit), and its explicit secret list to `fe-install-deps`. +- JFrog: `cplace-npm` virtual (read), `cplace-npm-local` (publish), the Bryntum remote via `bryntum-readers`. + +## Known Risks + +1. **A repo's `JFROG_TOKEN` identity lacks read on `cplace-npm`** (suspects: office-reports-fe, workflow-fe, + resource-management-fe). Mitigation: the user's pre-merge token check, and fixing the identity or permission + before merge. +2. **Leftover non-proxy lockfile entries fail without auth.** Mitigation: the 34301 audit, the warn step, and an + `npm ci` per identity group during the pre-merge check. +3. **Merge switches many repos at once.** Mitigation: the clone matrix before merge, and a fast master revert as + the rollback. +4. **PR 2 breaks a default-branch caller that still passes `DOT_NPMRC`, or a consumer release branch on + `@master`.** Mitigation: inventory the 14 repos' callers before PR 2 and gate PR 2 on zero remaining + references. +5. **The token is readable by every step in jobs that run `use-npmrc`, including read-only jobs.** Accepted + (trade-off 1). The file is `chmod 600`, and runners are ephemeral. + +## Next Steps + +1. Review this design document. +2. User actions: revise 33675 AC1/AC3 on the ticket, set the target release, and run the token read check. +3. Proceed to implementation planning: `/spec-driven-development:create_plan specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/design.md` + +## References + +- Tickets: [PFM-ISSUE-34294](https://base.cplace.io/pages/chduu2mpiug4855q91t5eerdh/PFM-ISSUE-34294-Use-the-new-secrets-and-remove-the-stored-DOT-NPMRC-secret), + [PFM-ISSUE-33675](https://base.cplace.io/pages/keq1ackt7c8iqg12ifgx9l6pa/PFM-ISSUE-33675-Standardize-JFrog-npm-read-and-publish-authentication-in-frontend-workflows) +- Research: [research.md](./research.md) +- Secrets overview: `C:/cplace-dev/secrets fe repos/secrets-comparison.md` (local, not committed) +- Prior designs: [34293 design](../2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/design.md), + [34293 live-test plan](../2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md), + [34301 design](../2026-11-16_PFM-ISSUE-34301_third-party-npm-registries-jfrog/design.md) +- Similar features: `tools/scripts/artifacts/jfrog-credentials.ts` (precedence/fallback pattern), + `tools/scripts/artifacts/nx-project.ts` `writeNPMRCInDist()` (generated publish `.npmrc`) diff --git a/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/research.md b/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/research.md new file mode 100644 index 0000000..55d9272 --- /dev/null +++ b/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/research.md @@ -0,0 +1,356 @@ +--- +date: 2026-12-01T13:14:08+01:00 +git_commit: 87b8f01daa0c99062b6701e150f1daabb8d5e501 +branch: master +topic: "PFM-ISSUE-34294 + PFM-ISSUE-33675: runtime-generated read .npmrc, separate JFrog read/publish credentials, removal of DOT_NPMRC / use-npmrc" +tags: [research, codebase, dot-npmrc, use-npmrc, jfrog, npmrc, secrets, fe-workflows, workflow-templates, artifacts] +status: complete +last_updated: 2026-12-01 +--- + +# Research: Runtime-generated `.npmrc` and the `DOT_NPMRC` cutover (PFM-ISSUE-34294 + PFM-ISSUE-33675) + +**Date**: 2026-12-01T13:14:08+01:00 +**Git Commit**: 87b8f01daa0c99062b6701e150f1daabb8d5e501 +**Branch**: master + +## Research Question + +For both related issues, PFM-ISSUE-34294 ("Use the new secrets and remove the stored DOT_NPMRC secret") and PFM-ISSUE-33675 ("Standardize JFrog npm read and publish authentication in frontend workflows"): + +- Where is `DOT_NPMRC` / `use-npmrc` used? +- How is `.npmrc` produced today for install (read) and for publish? +- How are the 34293 secrets wired in? +- What does the codebase need so that: + - the read `.npmrc` is generated at runtime, + - read-only jobs cannot reach the publish credential, and + - `DOT_NPMRC` can be removed? + +The scope also includes the unmerged blocker PFM-ISSUE-34301, to judge whether the removal gate is met. + +## PFM Ticket Context + +### PFM-ISSUE-34294 (primary, used for the folder name) +- **Ticket**: [PFM-ISSUE-34294](https://base.cplace.io/pages/chduu2mpiug4855q91t5eerdh/PFM-ISSUE-34294-Use-the-new-secrets-and-remove-the-stored-DOT-NPMRC-secret) +- **Title**: Use the new secrets and remove the stored DOT_NPMRC secret +- **Type**: PFM-ISSUE, groundwork. Priority high. Status 50.working. The impediment attribute says "Blocked". +- **Target Release**: not set +- **Assignee**: Vladimir Arsov +- **Epic**: WP-1963 Modernize FE 2.0 Frontend Workflow Authentication +- **Links**: + - Blocked by PFM-ISSUE-34293. That ticket is merged as `87b8f01` (#191). + - Blocked by PFM-ISSUE-34301. That ticket is in progress. + - Relates to PFM-ISSUE-33675. +- **Suggested Branch**: `improvement/PFM-ISSUE-34294-Use-the-new-secrets-and-remove-the-stored-DOT_NPMRC` (does not exist yet, locally or on origin) +- **Description**: + > ## Description + > Complete the credential cutover: once the new separate user/token secrets are in use, remove the full `.npmrc` that is currently stored as a GitHub Actions secret (`DOT_NPMRC`). + > ## Requirements + > - Generate the read/install `.npmrc` at build time from the new secrets (publishing already regenerates `.npmrc` in `dist`). + > - Remove `DOT_NPMRC` and its `use-npmrc` usage **completely** once covered. + > - Execute as one coordinated cutover with the new-secrets issue (add new secrets → use them → remove `DOT_NPMRC`). + > ## Acceptance Criteria + > - No FE workflow relies on a stored `DOT_NPMRC` secret. + > - Installs and publishes succeed using the build-time-generated `.npmrc`. + > ## Dependencies + > Tightly coupled with (and follows) the new-secrets issue. Gated by the registry work — all third-party registries proxied through JFrog and the registry audit signed off — so removal breaks nothing. Relates to PFM-ISSUE-33675. + +### PFM-ISSUE-33675 (related parent story) +- **Ticket**: [PFM-ISSUE-33675](https://base.cplace.io/pages/keq1ackt7c8iqg12ifgx9l6pa/PFM-ISSUE-33675-Standardize-JFrog-npm-read-and-publish-authentication-in-frontend-workflows) +- **Title**: Standardize JFrog npm read and publish authentication in frontend workflows +- **Type**: PFM-ISSUE, groundwork. Priority high. Status 50.working. Topic JFrog Artifactory. +- **Target Release**: not set +- **Assignee**: Vladimir Arsov. Requested by Christian Kaltenbach. +- **Epic**: WP-1963 +- **Links**: relates to PFM-ISSUE-34293 +- **Suggested Branch**: `improvement/PFM-ISSUE-33675-Standardize-JFrog-npm-read-and-publish-authentication` (does not exist yet) +- **Description**: + > **User Story**: As a developer maintaining a FE 2.0 frontend repository, I want JFrog npm read and publish credentials stored as separate GitHub Actions secrets with the `.npmrc` generated at workflow runtime, so that credential maintenance is straightforward and read-only jobs cannot accidentally use publish credentials. + > + > **Description**: Replace the current pattern of storing a full `.npmrc` in a single GitHub Actions secret. Each JFrog technical user (read and publish) is stored as its own GitHub Actions secret; the `.npmrc` is generated at workflow runtime from those secrets. Read-only jobs do not get access to the publish credential. + > + > **Open Questions (decide at implementation start)**: Read user as GitHub organization-level secret vs repository/environment secret; publish user scoping. Whether additional npm scopes need to be added beyond what the current `.npmrc` covers. + > + > **Acceptance Criteria**: (1) Read and publish JFrog technical users are stored as separate GitHub Actions secrets. (2) The `.npmrc` file is generated at workflow runtime from those secrets. (3) Read-only jobs do not have access to the publish credential. (4) At least one reference frontend repository runs CI on the new pattern. + +## Summary + +1. **34293 added only the publish side. No read credential exists.** + - Commit `87b8f01` added `JFROG_TOKEN`, a JFrog reference token for `JFROG_USER` with deploy, delete and annotate rights on `cplace-npm-local`. It is used as a plain `_authToken` in the generated **dist** `.npmrc`. `JFROG_BASE64_TOKEN` became deprecated. + - There is no `JFROG_READ_*` or similar read secret anywhere in the repo. + - 34294's phrase "the new secrets" therefore has no read-side counterpart yet. 33675 AC1 (separate read **and** publish secrets) is only half done. + - The 34293 design explicitly rejected deriving install auth from `JFROG_USER`/`JFROG_TOKEN`. Two reasons: publish tokens are not guaranteed to have read rights on the `cplace-npm` virtual repo, and it would hand the publish credential to every `npm ci`. +2. **The read/install `.npmrc` has no generator today.** + - `.github/actions/use-npmrc/action.yml:15` writes the `DOT_NPMRC` secret verbatim to `~/.npmrc`. + - It then appends `replace-registry-host=never` (`:31`), the PFM-ISSUE-34453 npm-11 mitigation. + - It then runs `warn-foreign-registry.sh || true` (`:47`). + - Whatever replaces it must keep both of those behaviours. +3. **`DOT_NPMRC` is declared by 8 reusables and passed by 6 templates.** + - `fe-release.yml` (template) passes it via `secrets: inherit`. + - Consumers wire `fe-sonar` by hand. + - Four publish/delete jobs hold **both** credentials in the same job: `fe-pr-snapshot`, `fe-pr-close`, `fe-cleanup-snapshots`, and `fe-release` / the `fe-release-flow` `release` job. + - The separation today is per **step**: `JFROG_*` is passed as `env:` on the `artifacts`/`snapshots` step only. Read access goes through `~/.npmrc`, publish access through `dist//.npmrc`. +4. **The target read `.npmrc` is small.** + - According to the 34301 design, it is `registry=https://cplace.jfrog.io/artifactory/api/npm/cplace-npm/` plus `//cplace.jfrog.io/artifactory/api/npm/cplace-npm/:_authToken=${}`, with no scope lines. + - This holds because the `cplace-npm` virtual includes `cplace-npm-local` and, once 34301 Phase 1 is done, Bryntum. + - The proxy URL already exists as a hard-coded constant in `tools/scripts/lockfile/lib.sh:20` (`JFROG_NPM_PROXY`). It is not `JFROG_URL`, which is the publish target `cplace-npm-local`. +5. **The removal gate (34301) is not yet met.** + - Phase 1 (Bryntum remote in JFrog) is done. + - Phase 2 (the project-planning-fe secret switch, Option B lockfile PRs #476–#480) is paused or pending. + - Phases 3 and 4 (merge, `audit.md`, README policy section, sign-off) are open. + - Residual non-JFrog lockfile entries remain on release branches: primeng `git+ssh`, and cplace-e2e `release/26.1` with npmjs. +6. **Release branches and `@master` coupling are the main compatibility constraint.** + - Templates pin reusables at `@master`, and consumers rewrite that to `@release/X.Y` per branch. + - Removing the `DOT_NPMRC` declaration or `use-npmrc` from master breaks callers that still pass the secret: undeclared secrets are a validation error for explicit callers. + - It also breaks branches that still depend on its contents. + - There is precedent from 34293 and 34282: drop the declaration in master, keep repo secrets until the last dependent release line is out of support. +7. **There are direct `DOT_NPMRC` consumers outside this repo**, which must migrate before the secret can be deleted: + - cplace-e2e: `bduff9/use-npmrc` + - cplace-fe: visual-regression, xray, Windows PR, devkit-test-template, `deploy_storybook` with `DOT_NPMRC_CONTENT` + - project-planning-fe: `bryntum-update.yml` and `sonar-scan.yml` + +## Detailed Findings + +### 1. The `use-npmrc` composite (current read path) +- Single required input `dot-npmrc` (`.github/actions/use-npmrc/action.yml:3-6`). It has no registry, scope or URL input, so all routing lives inside the secret text. +- `echo "$DOT_NPMRC" > ~/.npmrc` (`:15`) overwrites the runner HOME `.npmrc`. +- `echo 'replace-registry-host=never' >> ~/.npmrc` (`:31`). This is the PFM-ISSUE-34453 mitigation: npm 11.3 drops the proxy path prefix when it rewrites npmjs `resolved` URLs. + - The comment at `:20` says "the prefix is the JFROG_URL secret". That is inaccurate. The read prefix comes from the `registry=` line inside `DOT_NPMRC` (the `cplace-npm` virtual), while `JFROG_URL` is the publish target. +- `bash ".../tools/scripts/lockfile/warn-foreign-registry.sh" || true` (`:47`) is advisory only. The comment at `:44` says "all seven workflows"; the real count is eight. +- Callers load it as `collaborationFactory/github-actions/.github/actions/use-npmrc@master`, an external ref. Every caller therefore gets master behaviour regardless of its own ref. + +### 2. Per-workflow credential map (reusables in `.github/workflows/`) + +| Workflow | Job | Credential today | Kind | Notes | +|---|---|---|---|---| +| `fe-install-deps.yml` | install-deps | `DOT_NPMRC` → use-npmrc (`:32-35`), `npm ci` (`:39`) | read | `DOT_NPMRC` is `required: true` (`:10`). use-npmrc runs always. Only `npm ci` is gated on a cache miss. | +| `fe-build.yml` | build | none | read | Uses the node_modules cache. `run-many` runs `npm ci` in the actions repo with no `~/.npmrc`. | +| `fe-e2e.yml` | e2e | `PERCY_TOKEN` (optional) | read | Cache only | +| `fe-code-quality.yml` | code-quality / sonar | `SONAR_CLOUD_TOKEN` (optional) | read | No npm install | +| `fe-sonar.yml` | sonarqube-scan | `DOT_NPMRC` → use-npmrc (`:56-61`), `npm ci` (`:65`) | read | `DOT_NPMRC` required (`:10`). This is the only workflow that gates use-npmrc on a cache miss (`:57`). It has no template; consumers wire it by hand. | +| `fe-licenses.yml` | check-licenses | `DOT_NPMRC` → use-npmrc (`:38-41`), `npm ci` (`:45`) | read | `DOT_NPMRC` required (`:13`) | +| `fe-pr-snapshot.yml` | publish-pr-snapshot | `DOT_NPMRC` → use-npmrc (`:59-62`), `npm ci` (`:66`), then `JFROG_*` env on `artifacts` (`:68-77`) | **publish** | Both credentials in one job | +| `fe-snapshot.yml` | snapshot | `JFROG_*` env on `artifacts` (`:44-53`) | **publish** | No `DOT_NPMRC`. Relies on the install-deps cache. | +| `fe-pr-close.yml` | remove-artifacts | `DOT_NPMRC` → use-npmrc (`:41-44`), `npm ci` (`:48`), `JFROG_*` on `artifacts` with `ONLY_DELETE_ARTIFACTS` (`:50-60`) | **delete** | Both credentials in one job | +| `fe-cleanup-snapshots.yml` | build | `DOT_NPMRC` → use-npmrc (`:39-42`), then `JFROG_*` env on `snapshots` (`:44-50`) | **delete** | `cleanup-snapshots.ts:33,71` runs `npm view` and `npm search` through `~/.npmrc` (`DOT_NPMRC`) | +| `fe-release.yml` (deprecated) | release-version | `DOT_NPMRC` → use-npmrc (`:45-48`), `npm ci \|\| yarn` (`:52`), `JFROG_*` (`:54-61`) | **publish** | Deprecation warning at `:27` | +| `fe-tag.yml` (deprecated) | tag | `JFROG_*` (`:56-65`), `GIT_USER_TOKEN` | bump/tag | No `DOT_NPMRC`. The JFrog secrets are likely unnecessary because bump-only needs no credentials. | +| `fe-check-upmerge.yml` | check-upmerge | none (Slack and git) | read | `upmerge/action.yml:8,10` runs `npm ci` and `npm install -g @cplace/cli` without an `.npmrc` | +| `pr-checks.yml` | lockfile, scripts | none | n/a | `check-lockfile.sh --prefix-only`, shellcheck, bats | +| `fe-release-flow.yml` | guard | none | read | `contents: read` | +| `fe-release-flow.yml` | install-deps | `DOT_NPMRC` passed explicitly (`:78-79`) → fe-install-deps | read | Explicit secret list. A new read secret must be added here. | +| `fe-release-flow.yml` | build, e2e | none / `PERCY_TOKEN` (`:99-100`) | read | | +| `fe-release-flow.yml` | release | `DOT_NPMRC` → use-npmrc (`:134-137`), `npm ci` (`:141`), `JFROG_*` on `artifacts` (`:151-160`), plus a failure-cleanup delete (`:189-198`) | **publish + tag** | `contents: write` (`:112`). The inline job sees every declared secret. | +| `fe-release-flow.yml` | github-release | `github.token` | release | No npm | + +**Declared `workflow_call.secrets`:** +- `DOT_NPMRC` is required in `fe-install-deps`, `fe-licenses`, `fe-sonar`, `fe-pr-snapshot`, `fe-pr-close`, `fe-cleanup-snapshots`, `fe-release` and `fe-release-flow`. +- `JFROG_URL` and `JFROG_USER` are required, and `JFROG_TOKEN` and `JFROG_BASE64_TOKEN` are optional, in `fe-snapshot`, `fe-pr-snapshot`, `fe-pr-close`, `fe-cleanup-snapshots`, `fe-release`, `fe-tag` and `fe-release-flow`. + +### 3. Publish-side `.npmrc` generation (TypeScript, already runtime-generated) +- `tools/scripts/artifacts/jfrog-credentials.ts`: + - Reads `JFROG_URL`, `JFROG_USER`, `JFROG_BASE64_TOKEN` and `JFROG_TOKEN` (`:21-31`), each defaulting to `''`. + - `authMode` (`:34-38`) is TOKEN, LEGACY or NONE, decided by truthiness. Unset optional secrets arrive as `''`. + - `requireForPublishing()` (`:41-52`): LEGACY logs `::warning::`, NONE logs `::error::` and throws. + - `getJfrogUrlNoHttp()` (`:54`) strips `https:`. + - `toJSON()` (`:59`) redacts secrets. + - `TOKEN_PLACEHOLDER = '${JFROG_TOKEN}'` (`:9`) is written literally, and npm expands it from the step env. +- `tools/scripts/artifacts/nx-project.ts:293-324` `writeNPMRCInDist()` writes `dist///.npmrc`: + - TOKEN mode: `:registry=` and `////:_authToken=${JFROG_TOKEN}`. + - LEGACY mode: the four-line `_auth` / `always-auth` / `email` format. + - It has no default `registry=` and no `replace-registry-host`. + - Call sites: `artifacts-handler.ts:170` (build → write → publish) and `nx-project.ts:247` (`deleteArtifact` when the dist path is missing; cleanup and `ONLY_DELETE_ARTIFACTS`). +- `tools/scripts/artifacts/configuration.ts:1-5` `getJfrogUrl()` defaults to `https://cplace.jfrog.io/artifactory/cplace-npm-local`. `JFROG_URL` must end with `/` (README). +- Reads that rely on the **ambient** `~/.npmrc` (that is, `DOT_NPMRC`), not on the dist file: + - `utils.ts:338` (`npm view /`) + - `cleanup-snapshots.ts:31-33` (`npm view`) + - `cleanup-snapshots.ts:69-71` (`npm search`) + - A runtime read `.npmrc` must cover these too. + - 34293's live test T5 already fails here with E404 via `DOT_NPMRC`. This is pre-existing defect D2, failing since 2026-07. +- The `artifacts` and `snapshots` composites run `printenv` first (`artifacts/action.yml:16`, `snapshots/action.yml:6`). Secret values are masked, but derived values are not. Any token written to a file must not be echoed, or must be registered via `::add-mask::`. +- Tests: + - `jfrog-credentials.test.ts` covers modes, empty strings and redaction. + - `nx-project.test.ts:141-152` covers the TOKEN content. + - `artifacts-handler.test.ts:103-104`, `:161-162` and `:198-199` cover npmrc content expectations. +- No reusable function produces an install `.npmrc`. The closest building blocks are `JfrogCredentials` with its placeholder pattern, and `JFROG_NPM_PROXY` in bash (`lib.sh:20`, deliberately hard-coded, documented at `lib.sh:10-19`). +- Untracked `dist/apps/cf-components/{.npmrc,package.json}` is a jest side effect: a LEGACY-format file with empty values, produced by `artifacts-handler*.test.ts` running with an empty env. It is not a build artifact, and `.gitignore` has no `dist` entry. + +### 4. Lockfile tooling (relevant constraints) +- `tools/scripts/lockfile/lib.sh:20`: `JFROG_NPM_PROXY='https://cplace.jfrog.io/artifactory/api/npm/cplace-npm/'`. This is the read proxy. It is hard-coded on purpose and is not `JFROG_URL`. +- `check-lockfile.sh:146-184` asserts a single registry prefix equal to the proxy. +- `normalize-lockfile.sh` rewrites `resolved` URLs onto the proxy, and must not depend on `npm ci`. +- `warn-foreign-registry.sh` references the `replace-registry-host=never` behaviour. It is exercised by bats tests in `pr-checks.yml:57-61`. If the warn step moves out of `use-npmrc`, the comments and tests that name `use-npmrc` must follow. + +### 5. Consumer templates (`.github/workflow-templates/fe/`) +All `uses:` are `@master`. Consumers rewrite them to `@release/X.Y` per branch (README `:48-49`). + +| Template | `DOT_NPMRC` | JFrog | Other | +|---|---|---|---| +| `fe-main.yml` | install-deps (`:27-28`) | snapshot gets `JFROG_TOKEN`/`URL`/`USER` (`:53-56`) | e2e gets `PERCY_TOKEN` | +| `fe-pr.yml` | install-deps (`:27-28`) | n/a | code-quality gets no secrets | +| `fe-pr-snapshot.yml` | yes (`:19-23`) | yes | n/a | +| `fe-pr-close.yml` | yes (`:19-23`) | yes | n/a | +| `fe-cleanup-snapshots.yml` | yes (`:16-20`) | yes | n/a | +| `fe-licenses.yml` | yes (`:24-25`) | n/a | n/a | +| `fe-release.yml` | via `secrets: inherit` (`:32`) | via inherit | `permissions: contents: write` | +| `fe-check-upmerge.yml` | n/a | n/a | Slack and git | + +- README: `:12` describes `use-npmrc` / `dot-npmrc`, `:85-87` lists the required secrets, `:93-109` is the JFrog and npm secrets table (`:101` says `DOT_NPMRC` is "a complete .npmrc … never used for publishing"), and `:103-109` covers the `JFROG_TOKEN` migration and the `@release/26.4`-and-older compatibility split. +- The README has no org-level vs repo-level secret guidance and no "Third-party npm registries" section yet. 34301 Phase 4 plans one. +- `CODEOWNERS` (repo root): `/* @slaven3kopic @alekhya-cplace @senthanal`. Every change needs a Frontend Core approval. + +### 6. Least-privilege constraint ("read-only jobs must not get the publish credential") +- `workflow_call` secrets are workflow-wide. Inside one reusable, isolation is possible only per **job** (via the secrets passed to nested `uses:` jobs) or per **step** (via `env:`). The jobs below cannot be isolated at the workflow level. +- Read-only reusables (`fe-install-deps`, `fe-licenses`, `fe-sonar`) declare only `DOT_NPMRC` today. Swapping it for a read-token secret keeps them free of publish credentials. +- In the mixed publish jobs (`fe-pr-snapshot`, `fe-pr-close`, `fe-cleanup-snapshots`, the `fe-release-flow` `release` job), the publish token is already confined to the `artifacts`/`snapshots` step `env:`. The install step would use the read token. This is step-level isolation inside a job that holds both credentials. +- `fe-release-flow` is called with `secrets: inherit` (34283 Decision 6, accepted trade-off). Its nested `install-deps` job gets only explicitly passed secrets (`:78-79`). The inline `release` job sees all of them. +- `fe-snapshot` has no install step. It relies on the cache and needs no read credential, unless a cache miss requires an install, which it does not do today. + +### 7. Blocker status: PFM-ISSUE-34301 (unmerged spec folder plus test branch) +- Folder: `specs/2026-11-16_PFM-ISSUE-34301_third-party-npm-registries-jfrog/` (untracked). + - research.md is complete, design.md is still `draft`, and plan.md is partially executed. +- **Done**: Phase 1 (2026-11-17). + - JFrog remote `bryntum-remote` (the design says `bryntum-npm-remote`), with includes `@bryntum/**` and `.npm/@bryntum/**`, placed before npmjs in the `cplace-npm` virtual. + - `cplace-npm-org-proxy` excludes Bryntum. + - `svcusr_cf_projplanning-fe` has Deploy/Cache rights and is in `bryntum-readers`. + - `squad_fe` and anonymous access are denied. +- **Paused**: Phase 2. + - An in-place edit of project-planning-fe's live `DOT_NPMRC` produced E403 from npm.bryntum.com and was reverted. + - Decision change on 2026-11-18, Option B: re-resolve the Bryntum lock entries on all supported branches. The PRs are project-planning-fe #476 (master), #477 (26.4), #478 (26.3), #479 (26.2) and #480 (26.1). + - The order is to merge the PRs, then switch the secret. + - design.md has not been updated for Option B. +- **Open**: Phase 3 (merge) and Phase 4 (`audit.md`, the README "Third-party npm registries" section, sign-off by Vladimir Arsov and Philip). Philip has not yet confirmed the `bryntum-readers` members. +- **Test branch** `origin/test/PFM-ISSUE-34301-dot-npmrc-test` (`5d06eca`, based on `3e8a45b`, before 34293): + - It switches only `fe-install-deps.yml` and `fe-sonar.yml` to `DOT_NPMRC_TEST`, paired with project-planning-fe's `test/PFM-ISSUE-34301-bryntum-via-jfrog`. + - Main CI run 44277324607 and Bryntum Update Check 44277343429 succeeded. + - It is throwaway: it predates `JFROG_TOKEN` handling and must not be merged. +- **What 34301 says the generated read `.npmrc` should be** (design "Overall Architecture"): `registry=https://cplace.jfrog.io/artifactory/api/npm/cplace-npm/` plus `//cplace.jfrog.io/artifactory/api/npm/cplace-npm/:_authToken=…`. No scope lines are needed: + - `@fortawesome` is redundant. + - Own scopes (`@cplace-next`, `@cplace-project-planning-fe`) resolve via `cplace-npm`, which includes `cplace-npm-local`. + - Bryntum resolves via the new remote. +- **Identity constraint**: project-planning-fe's read `.npmrc` must authenticate as `svcusr_cf_projplanning-fe`, the only build identity in `bryntum-readers`. It cannot use the shared `squad_fe` that the other repos use. A single org-level read secret therefore cannot serve project-planning-fe unless that identity changes. +- **Residual gate blockers** (release branches only): + - primeng-sass-theme `git+ssh` on cplace-fe and resource-management 26.1–26.3. + - cplace-e2e `release/26.1` with 328 `registry.npmjs.org` entries. It uses `bduff9/use-npmrc`, so it does not get `replace-registry-host=never`, and its replacement must keep a default `registry=` without that line. + - Neither 34301 doc says whether sign-off covers all supported branches or only default branches. + +### 8. Current `DOT_NPMRC` contents across repos (from the 34293/34301 research) +- It is an opaque per-repo whole `.npmrc`. + - Most repos use `_auth` (basic `user:password`). `cplace-e2e` and `resource-management-fe` use `_authToken`. + - All have `registry=…/api/npm/cplace-npm/`. + - Some have redundant scope lines. + - project-planning-fe, plus a dead entry in cplace-fe, have `@bryntum:registry=https://npm.bryntum.com` plus a **personal** Bryntum JWT. +- All current secrets are **per-repo**. There are no org-level `JFROG_*` or `DOT_NPMRC` secrets. + - The org does have `ENV_CPLACE_ARTIFACTORY_ACTOR` / `ENV_CPLACE_ARTIFACTORY_TOKEN`, visible to the 15 repos and used by cplace-fe xray and devkit. + - 34293 rejected that pair for publish because it collapses identities and has unknown rights. +- `JFROG_TOKEN` was set on all FE repos and on `clone-cplace-fe` on 2026-11-24 (34293 live-test-plan §2.1). + - The callers' switch from `JFROG_BASE64_TOKEN` to `JFROG_TOKEN` is rolling out per repo, starting with the pilot `cplace-remote-filesystem-fe`. + +## Code References +- `.github/actions/use-npmrc/action.yml:3-6`: the single `dot-npmrc` input +- `.github/actions/use-npmrc/action.yml:15`: writes the secret verbatim to `~/.npmrc` +- `.github/actions/use-npmrc/action.yml:31`: appends `replace-registry-host=never` (PFM-ISSUE-34453) +- `.github/actions/use-npmrc/action.yml:47`: the advisory `warn-foreign-registry.sh` call +- `.github/actions/artifacts/action.yml:16-21`: `printenv`, `npm ci` in the actions repo, `ts-node main.ts` +- `.github/workflows/fe-install-deps.yml:10,32-35,39`: required `DOT_NPMRC`, then use-npmrc, then `npm ci` +- `.github/workflows/fe-sonar.yml:10,56-61,65`: the cache-gated use-npmrc +- `.github/workflows/fe-licenses.yml:13,38-41,45` +- `.github/workflows/fe-pr-snapshot.yml:19,59-62,66,68-77`: mixed read and publish job +- `.github/workflows/fe-pr-close.yml:19,41-44,48,50-60`: mixed read and delete job +- `.github/workflows/fe-cleanup-snapshots.yml:15,39-42,44-50`: mixed read and delete job +- `.github/workflows/fe-release.yml:15,27,45-48,52,54-61`: deprecated +- `.github/workflows/fe-release-flow.yml:25,78-79,112,134-137,141,151-160,189-198` +- `.github/workflows/fe-snapshot.yml:44-53`: publish, no `DOT_NPMRC` +- `.github/workflows/fe-tag.yml:56-65`: deprecated, JFrog secrets likely unnecessary +- `tools/scripts/artifacts/jfrog-credentials.ts:9,21-31,34-38,41-52,54,59` +- `tools/scripts/artifacts/nx-project.ts:247,293-324,430`: the dist `.npmrc` writer +- `tools/scripts/artifacts/artifacts-handler.ts:130,148-155,170` +- `tools/scripts/artifacts/cleanup-snapshots.ts:14,31-33,69-71,79,102` +- `tools/scripts/artifacts/utils.ts:338`: `npm view` through the ambient `.npmrc` +- `tools/scripts/artifacts/configuration.ts:1-5`: the `JFROG_URL` default (`cplace-npm-local`) +- `tools/scripts/lockfile/lib.sh:10-20`: the hard-coded `JFROG_NPM_PROXY` read proxy +- `tools/scripts/lockfile/check-lockfile.sh:146-184` +- `.github/workflow-templates/fe/*.yml`: consumer callers (see section 5) +- `README.md:12,85-87,93-109`: documentation to update +- `.github/workflows/pr-checks.yml:39-40,57-61`: lockfile check and bats + +## Architecture Insights +- **Two `.npmrc` files with different lifetimes.** + - `~/.npmrc` (read) comes from a secret, today via `use-npmrc`. + - `dist//.npmrc` (publish) is generated in TypeScript from `JFROG_*`. + - npm uses the dist file for `publish`, `dist-tag` and `show` with `cwd` in dist. + - The ticket's "generate the read `.npmrc` at build time" adds generation for the first file only. The second is already done. +- **The placeholder pattern** (`_authToken=${VAR}`, written literally and expanded by npm from the step env) keeps tokens out of files and logs. It is the established pattern to reuse for the read file. The read step would set the read token as step `env:` for `npm ci` / `npm view` / `npm search`. + - Caveat: npm expands `${VAR}` when it reads the config. Every later npm invocation in the job that needs the read registry (for example, `npm view` inside the `artifacts`/`snapshots` steps) must also have that env var set. Otherwise npm fails on an unset variable or sends an empty token. +- **The read URL is a constant, not a secret.** `JFROG_NPM_PROXY` is deliberately hard-coded and committed. A read generator can use the same constant, or share it with `lib.sh`, instead of introducing a `JFROG_READ_URL` secret. +- **Secret-contract changes ripple through `@master`.** Reusables and composites are loaded at `@master` (nested calls and `use-npmrc@master`). + - Removing a declared secret breaks explicit callers that still pass it. + - Adding a required secret breaks callers that don't pass it. + - Precedent from 34293/34282: add new secrets as `required: false`, drop old declarations only when callers are migrated, and keep repo secrets until the last release line using them is out of support. +- **`secrets: inherit` for the release flow** (34283) means release callers need no edits for the secret swap, but least privilege comes only from per-job or per-step wiring inside the reusable. +- **Per-repo secrets and identities** are the norm (34293). project-planning-fe needs its own read identity, `svcusr_cf_projplanning-fe`, for Bryntum. + +## Historical Context (from specs/) +- `specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/design.md`: + - Introduced `JFROG_TOKEN` (optional), kept `JFROG_USER`/`JFROG_URL` required, and deprecated `JFROG_BASE64_TOKEN`. + - Kept per-repo secrets. + - Rejected `JFROG_NPM_*` naming and the org-level `ENV_CPLACE_ARTIFACTORY_*` pair. + - **Explicitly deferred** `DOT_NPMRC`, `use-npmrc` and install auth to 33675 ("What we're NOT doing", Decision 7). + - Rejected deriving install auth from the publish token. +- `specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/plan.md` (Migration Notes): the master-only merge, then the pilot repo, then 13 repos. The cleanup ticket that removes the legacy fallback is "to be created". +- `specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md`: + - Test on `clone-cplace-fe` against `cplace-npm-test`, never on real `release/*`. + - Secret changes need user consent. + - T5 fails because of the pre-existing `DOT_NPMRC` E404 in cleanup (D2). +- `specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/review.md`: open findings 1.1 (test gap for gate paths) and 1.2 (duplicated gate logic). +- `specs/2026-11-16_PFM-ISSUE-34301_third-party-npm-registries-jfrog/{research,design,plan}.md`: + - The generated read `.npmrc` shape. + - The Bryntum remote. + - Option B. + - The direct-consumer inventory. + - Known Risk 4: master removal breaks release branches. + - The replacement for `use-npmrc` must keep `warn-foreign-registry.sh`. +- `specs/2026-10-12_PFM-ISSUE-34283_consolidate-fe-release-workflow/design.md`: + - Decision 6 and "Secrets and permissions contract" (`:228-245`): `secrets: inherit` was chosen so later secret changes, explicitly including the `DOT_NPMRC` removal, need no caller edits. + - `:119`: one install definition for later npmrc changes. +- `specs/2026-10-26_PFM-ISSUE-34282_github-token-scoped-permissions/{research,design}.md`: precedent for retiring a secret. Drop the callee declaration and keep repo secrets until no branch needs them. It also shows the hazard of callers passing undeclared secrets, for example cplace-fe `push_main.yaml` with `GIT_USER_TOKEN`. +- External: `C:/cplace-dev/FE2.0-initiative/PFM-Issues-FE2.0-Build-Integration.md:63-123` (FE-B02). It was not read in this session; the 34301 research references it. + +## Related Research +- `specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/research.md` +- `specs/2026-11-16_PFM-ISSUE-34301_third-party-npm-registries-jfrog/research.md` +- `specs/2026-10-26_PFM-ISSUE-34282_github-token-scoped-permissions/research.md` +- `specs/2026-10-12_PFM-ISSUE-34283_consolidate-fe-release-workflow/research.md` +- `specs/2026-06-05_node24-workflow-migration/research.md`: mentions `DOT_NPMRC` in the Node 24 rollout context + +## Open Questions +1. **Which secret is the read credential?** + - 34294 says "use the new secrets", but 34293 delivered only a publish token. + - Option (a): a new read pair (`JFROG_READ_USER` / `JFROG_READ_TOKEN`, or similar), which satisfies 33675 AC1 and AC3. + - Option (b): reuse `JFROG_TOKEN`. This contradicts 33675 AC3 and the 34293 Decision 7 rationale. + - Naming has to be decided. +2. **Scoping of the read secret** (33675 open question): org-level, repo-level or environment-level. + - An org-level read secret is simplest, but project-planning-fe needs `svcusr_cf_projplanning-fe` for Bryntum. + - Either the org secret is overridden per repo (a repo secret with the same name takes precedence), or the Bryntum readers group gains the shared read identity. + - Should `ENV_CPLACE_ARTIFACTORY_ACTOR/_TOKEN` be reused or replaced? +3. **Scopes** (33675 open question): the 34301 design says no scope lines are needed. This needs confirmation for no-lockfile installs (`upmerge` `npm install -g @cplace/cli`, cplace-fe `pull_request_windows` and `devkit-test-template`) and for the `@fortawesome` line. +4. **Where generation lives**: + - Rewrite `use-npmrc` in place with new inputs, keeping the path stable for `@master` callers. + - Or add a new composite and delete `use-npmrc` later. + - Or generate in TypeScript next to `writeNPMRCInDist`. + - Whichever is chosen must keep `replace-registry-host=never` and the `warn-foreign-registry.sh` step. +5. **Release-branch compatibility.** How long must `use-npmrc` and the `DOT_NPMRC` declaration stay on master (as optional) for `@release/26.x` callers? Is "remove completely" (34294) achievable now, or only after the last supported release line migrates? Who updates the release branches' callers? +6. **Is the 34301 gate met?** + - Phases 2–4 are open, and the Option B PRs #476–#480 are not yet confirmed merged. + - The audit scope (all supported branches vs default branch) is undecided. + - cplace-e2e `release/26.1` (npmjs) and the primeng `git+ssh` entries are unresolved. +7. **Direct consumers outside github-actions** (cplace-e2e, cplace-fe including `deploy_storybook` and `DOT_NPMRC_CONTENT`, project-planning-fe `bryntum-update.yml` / `sonar-scan.yml`): are they in scope for 34294, or tracked separately? The secret can only be deleted per repo after these migrate. +8. **The "coordinated cutover" wording** (34294) vs 34293 Decision 7, which dropped the coordinated cutover. 34293 is merged on its own, so the sequence is now: add the read secret, switch the workflows, then remove `DOT_NPMRC`. +9. **Reference repository** for 33675 AC4: `clone-cplace-fe` (the test clone) or the 34293 pilot `cplace-remote-filesystem-fe`? +10. **Pre-existing D2** (cleanup `npm view`/`npm search` E404 via `DOT_NPMRC`): fix it as part of the new read `.npmrc`, or leave it to its separate ticket? +11. **Housekeeping found along the way**: + - The `use-npmrc` comment at `:20` misattributes the prefix to `JFROG_URL`. + - The comment at `:44` says "seven workflows" instead of eight. + - `fe-tag` passes JFrog secrets it doesn't need. + - Untracked `dist/` is jest output with no `.gitignore` entry. + - The target release is not set on either ticket. From d754f0d07abe88eae37de18970f6a11f0838fb43 Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Thu, 3 Dec 2026 16:03:58 +0100 Subject: [PATCH 2/5] PFM-ISSUE-34294 - Generate ~/.npmrc from JFROG_TOKEN in use-npmrc; DOT_NPMRC becomes a deprecated fallback use-npmrc delegates to write-npmrc.sh: with jfrog-token it writes the cplace-npm virtual as registry plus the token as _authToken; with only dot-npmrc it writes that content with a deprecation warning; with neither it fails before npm ci. fe-install-deps passes both secrets, both optional. pr-checks runs shellcheck and bats over the new script. Co-Authored-By: Claude Opus 5.5 --- .github/actions/use-npmrc/action.yml | 39 +++++------- .github/actions/use-npmrc/write-npmrc.bats | 24 ++++++++ .github/actions/use-npmrc/write-npmrc.sh | 70 ++++++++++++++++++++++ .github/workflows/fe-install-deps.yml | 6 +- .github/workflows/pr-checks.yml | 4 +- 5 files changed, 116 insertions(+), 27 deletions(-) create mode 100644 .github/actions/use-npmrc/write-npmrc.bats create mode 100755 .github/actions/use-npmrc/write-npmrc.sh diff --git a/.github/actions/use-npmrc/action.yml b/.github/actions/use-npmrc/action.yml index 40fa562..9841b90 100644 --- a/.github/actions/use-npmrc/action.yml +++ b/.github/actions/use-npmrc/action.yml @@ -1,47 +1,38 @@ name: 'Use .npmrc' -description: 'Writes the given .npmrc content to ~/.npmrc and warns about lockfile entries outside the cplace npm proxy' +description: 'Writes ~/.npmrc from JFROG_TOKEN (or the deprecated DOT_NPMRC) and warns about lockfile entries outside the cplace npm proxy' inputs: + jfrog-token: + description: 'JFrog token (the JFROG_TOKEN secret); authenticates installs against the cplace-npm virtual' + required: false + default: '' dot-npmrc: - description: 'Content of the .npmrc file' - required: true + description: 'Deprecated: content of a complete .npmrc; used only when jfrog-token is empty' + required: false + default: '' runs: using: 'composite' steps: - name: Write ~/.npmrc shell: bash env: + JFROG_TOKEN: ${{ inputs.jfrog-token }} DOT_NPMRC: ${{ inputs.dot-npmrc }} - run: | - echo "$DOT_NPMRC" > ~/.npmrc - # PFM-ISSUE-34453 mitigation. npm's default `replace-registry-host=npmjs` - # rewrites a lockfile's registry.npmjs.org URLs onto the configured - # registry. npm 10.2.4 does that correctly and the entry resolves through - # the proxy; npm 11.3.0 DROPS that registry's path prefix, producing an - # E404 masked as *** because the prefix is the JFROG_URL secret. Measured - # 2026-08-14 on a runner and locally with the same one-package fixture. - # - # `never` makes npm fetch each `resolved` URL verbatim, which survives - # both versions - at a cost: an entry still on npmjs is then fetched FROM - # npmjs, outside the proxy. This line buys npm-11 compatibility and - # spends proxy routing; normalizing the lockfile buys both. - # - # This is a no-op on a lockfile that already resolves entirely through - # the proxy, so it is safe to leave in place, and it is removable once - # the warning below stops firing anywhere. - echo 'replace-registry-host=never' >> ~/.npmrc + # Generation, precedence and the PFM-ISSUE-34453 mitigation live in the + # script, where bats covers them. + run: bash "$GITHUB_ACTION_PATH/write-npmrc.sh" - name: Warn on lockfile entries outside the cplace npm proxy shell: bash # Advisory only - never fails the build. The warnings are the inventory of - # lockfiles that still need normalizing; when none report, the mitigation - # above can be dropped. + # lockfiles that still need normalizing; when none report, the mitigation in + # write-npmrc.sh can be dropped. # # Invoked as `bash "" || true`, not as a bare path. The script's own # "every precondition is a silent success" contract cannot cover NOT BEING # REACHABLE - a missing exec bit after checkout, a path containing spaces, # or a runner where action_path is a backslashed Windows path. That is an # exit 127 from the shell rather than from the script, and it would fail - # the consumer's job before `npm ci` in all seven workflows using this + # the consumer's job before `npm ci` in every workflow using this # action. `continue-on-error:` is not honoured on composite steps, so # `|| true` is the mechanism that actually works here. run: bash "$GITHUB_ACTION_PATH/../../../tools/scripts/lockfile/warn-foreign-registry.sh" || true diff --git a/.github/actions/use-npmrc/write-npmrc.bats b/.github/actions/use-npmrc/write-npmrc.bats new file mode 100644 index 0000000..b8db404 --- /dev/null +++ b/.github/actions/use-npmrc/write-npmrc.bats @@ -0,0 +1,24 @@ +#!/usr/bin/env bats +# +# Behavioural tests for write-npmrc.sh, the generator behind the use-npmrc +# composite. HOME is redirected so that the tests never touch the real ~/.npmrc. +# +# Run with: bats .github/actions/use-npmrc/ + +setup() { + WRITE="${BATS_TEST_DIRNAME}/write-npmrc.sh" + export HOME="${BATS_TEST_TMPDIR}" + NPMRC="${HOME}/.npmrc" + unset JFROG_TOKEN DOT_NPMRC +} + +@test "writes registry, auth token and mitigation when only JFROG_TOKEN is set" { + export JFROG_TOKEN='test-token' + + run "${WRITE}" + + [ "${status}" -eq 0 ] + [ "$(cat "${NPMRC}")" = "registry=https://cplace.jfrog.io/artifactory/api/npm/cplace-npm/ +//cplace.jfrog.io/artifactory/api/npm/cplace-npm/:_authToken=test-token +replace-registry-host=never" ] +} diff --git a/.github/actions/use-npmrc/write-npmrc.sh b/.github/actions/use-npmrc/write-npmrc.sh new file mode 100755 index 0000000..bfce0f8 --- /dev/null +++ b/.github/actions/use-npmrc/write-npmrc.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +# +# Writes ~/.npmrc for npm installs. Run by the use-npmrc composite. +# +# Inputs (environment only, never arguments, so that they never appear in a +# process listing): JFROG_TOKEN, DOT_NPMRC. An empty value counts as not set, +# because a composite receives an input that was not passed as ''. +# +# JFROG_TOKEN set -> generated file: the cplace-npm virtual as registry and the +# token as its _authToken. DOT_NPMRC, if also set, is +# ignored with a ::notice::. +# only DOT_NPMRC -> DEPRECATED: written verbatim, with a ::warning::. +# neither -> ::error::, exit 1, no file written. +# +# The token is written literally, never printed. See PFM-ISSUE-34294. + +set -euo pipefail + +LIB="$(dirname "${BASH_SOURCE[0]}")/../../../tools/scripts/lockfile/lib.sh" +readonly LIB +# shellcheck source=tools/scripts/lockfile/lib.sh +source "${LIB}" + +main() { + local npmrc="${HOME}/.npmrc" + local token="${JFROG_TOKEN:-}" dot_npmrc="${DOT_NPMRC:-}" + + umask 077 + if [[ -n "${token}" ]]; then + if [[ "${token}" =~ [[:space:]] ]]; then + echo '::error::JFROG_TOKEN contains whitespace; check the repository secret.' + return 1 + fi + printf 'registry=%s\n%s:_authToken=%s\n' \ + "${JFROG_NPM_PROXY}" "${JFROG_NPM_PROXY#https:}" "${token}" >"${npmrc}" + if [[ -n "${dot_npmrc}" ]]; then + echo '::notice::DOT_NPMRC is passed but ignored, because JFROG_TOKEN is set. Remove the DOT_NPMRC line from this caller.' + fi + elif [[ -n "${dot_npmrc}" ]]; then + printf '%s\n' "${dot_npmrc}" >"${npmrc}" + echo '::warning::DOT_NPMRC is deprecated. Pass JFROG_TOKEN instead, see "JFrog and npm secrets" in the github-actions README.' + else + echo '::error::No npm credentials: pass the JFROG_TOKEN secret (see "JFrog and npm secrets" in the github-actions README).' + return 1 + fi + + # PFM-ISSUE-34453 mitigation. npm's default `replace-registry-host=npmjs` + # rewrites a lockfile's registry.npmjs.org URLs onto the configured + # registry. npm 10.2.4 does that correctly and the entry resolves through + # the proxy; npm 11.3.0 DROPS that registry's path prefix (the + # `/artifactory/api/npm/cplace-npm/` part of the `registry=` URL), producing + # an E404. In the generated file that URL is committed, not secret; in the + # DOT_NPMRC fallback it comes from the secret, so the E404 is masked as ***. + # Measured 2026-08-14 on a runner and locally with the same one-package + # fixture. + # + # `never` makes npm fetch each `resolved` URL verbatim, which survives + # both versions - at a cost: an entry still on npmjs is then fetched FROM + # npmjs, outside the proxy. This line buys npm-11 compatibility and + # spends proxy routing; normalizing the lockfile buys both. + # + # This is a no-op on a lockfile that already resolves entirely through + # the proxy, so it is safe to leave in place, and it is removable once + # the lockfile advisory in use-npmrc stops firing anywhere. + echo 'replace-registry-host=never' >>"${npmrc}" + # umask covers a new file only; a pre-existing ~/.npmrc keeps its mode. + chmod 600 "${npmrc}" +} + +main "$@" diff --git a/.github/workflows/fe-install-deps.yml b/.github/workflows/fe-install-deps.yml index 0e31f9e..660c9a4 100644 --- a/.github/workflows/fe-install-deps.yml +++ b/.github/workflows/fe-install-deps.yml @@ -7,8 +7,11 @@ on: type: string required: true secrets: + JFROG_TOKEN: + required: false + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed DOT_NPMRC: - required: true + required: false jobs: install-deps: @@ -32,6 +35,7 @@ jobs: - name: Use .npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install modules diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 5be329c..af4c6d3 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -55,7 +55,7 @@ jobs: sudo apt-get install -y bats shellcheck - name: shellcheck - run: shellcheck tools/scripts/lockfile/*.sh tools/scripts/lockfile/test-helper.bash + run: shellcheck tools/scripts/lockfile/*.sh tools/scripts/lockfile/test-helper.bash .github/actions/use-npmrc/*.sh - name: bats - run: bats tools/scripts/lockfile/ + run: bats tools/scripts/lockfile/ .github/actions/use-npmrc/ From b2feaa26130e506e3839972a3d4892921193eb1c Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Thu, 3 Dec 2026 17:06:53 +0100 Subject: [PATCH 3/5] PFM-ISSUE-34294 - Pass JFROG_TOKEN to use-npmrc in every FE reusable; templates and README drop DOT_NPMRC All eight reusables that run use-npmrc declare JFROG_TOKEN and DOT_NPMRC as optional and pass both; fe-release-flow's nested install-deps gets both. write-npmrc.bats covers every input case, whitespace tokens, overwrite and mode 600. The templates pass JFROG_TOKEN and no DOT_NPMRC; the README documents JFROG_TOKEN as the install credential (read on the cplace-npm virtual), marks DOT_NPMRC deprecated and adds the migration steps. Co-Authored-By: Claude Opus 5.5 --- .github/actions/use-npmrc/write-npmrc.bats | 112 ++++++++++++++++++ .../fe/fe-cleanup-snapshots.yml | 1 - .github/workflow-templates/fe/fe-licenses.yml | 2 +- .github/workflow-templates/fe/fe-main.yml | 2 +- .github/workflow-templates/fe/fe-pr-close.yml | 1 - .../workflow-templates/fe/fe-pr-snapshot.yml | 1 - .github/workflow-templates/fe/fe-pr.yml | 2 +- .github/workflows/fe-cleanup-snapshots.yml | 4 +- .github/workflows/fe-licenses.yml | 6 +- .github/workflows/fe-pr-close.yml | 4 +- .github/workflows/fe-pr-snapshot.yml | 4 +- .github/workflows/fe-release-flow.yml | 5 +- .github/workflows/fe-release.yml | 4 +- .github/workflows/fe-sonar.yml | 8 +- README.md | 38 ++++-- tools/scripts/lockfile/README.md | 3 +- 16 files changed, 169 insertions(+), 28 deletions(-) diff --git a/.github/actions/use-npmrc/write-npmrc.bats b/.github/actions/use-npmrc/write-npmrc.bats index b8db404..b7a0bf0 100644 --- a/.github/actions/use-npmrc/write-npmrc.bats +++ b/.github/actions/use-npmrc/write-npmrc.bats @@ -22,3 +22,115 @@ setup() { //cplace.jfrog.io/artifactory/api/npm/cplace-npm/:_authToken=test-token replace-registry-host=never" ] } + +@test "prints neither the token nor an annotation when only JFROG_TOKEN is set" { + export JFROG_TOKEN='secret-token-value' + + run "${WRITE}" + + [ "${status}" -eq 0 ] + [[ "${output}" != *'secret-token-value'* ]] + [[ "${output}" != *'::'* ]] +} + +@test "makes the written file readable by its owner only" { + [[ "$(uname -s)" != MINGW* && "$(uname -s)" != MSYS* ]] || skip 'NTFS has no Unix file modes' + export JFROG_TOKEN='test-token' + + run "${WRITE}" + + [ "${status}" -eq 0 ] + [ "$(stat -c %a "${NPMRC}")" = '600' ] +} + +@test "uses JFROG_NPM_PROXY from lib.sh as the registry" { + # shellcheck source=tools/scripts/lockfile/lib.sh + source "${BATS_TEST_DIRNAME}/../../../tools/scripts/lockfile/lib.sh" + export JFROG_TOKEN='test-token' + + run "${WRITE}" + + [ "${status}" -eq 0 ] + [ "$(head -n 1 "${NPMRC}")" = "registry=${JFROG_NPM_PROXY}" ] +} + +@test "prefers JFROG_TOKEN over DOT_NPMRC and says so in a notice" { + export JFROG_TOKEN='test-token' + export DOT_NPMRC='registry=https://legacy.example/npm/' + + run "${WRITE}" + + [ "${status}" -eq 0 ] + grep -q '_authToken=test-token' "${NPMRC}" + [[ "$(cat "${NPMRC}")" != *'legacy.example'* ]] + [[ "${output}" == *'::notice::'* ]] + [[ "${output}" != *'::warning::'* ]] +} + +@test "writes DOT_NPMRC verbatim plus the mitigation, with a deprecation warning, when only it is set" { + export DOT_NPMRC='registry=https://legacy.example/npm/ +//legacy.example/npm/:_auth=abc' + + run "${WRITE}" + + [ "${status}" -eq 0 ] + [ "$(cat "${NPMRC}")" = "registry=https://legacy.example/npm/ +//legacy.example/npm/:_auth=abc +replace-registry-host=never" ] + [[ "${output}" == *'::warning::'* ]] + [[ "${output}" == *'DOT_NPMRC is deprecated'* ]] +} + +@test "fails without writing a file when neither secret is set" { + run "${WRITE}" + + [ "${status}" -ne 0 ] + [[ "${output}" == *'::error::'* ]] + [[ "${output}" == *'No npm credentials'* ]] + [ ! -e "${NPMRC}" ] +} + +@test "treats empty strings as not set, as a composite passes an omitted input" { + export JFROG_TOKEN='' DOT_NPMRC='' + + run "${WRITE}" + + [ "${status}" -ne 0 ] + [[ "${output}" == *'::error::'* ]] + [[ "${output}" == *'No npm credentials'* ]] + [ ! -e "${NPMRC}" ] +} + +@test "rejects a token containing a space, without printing it or writing a file" { + export JFROG_TOKEN='secret-part other-part' + + run "${WRITE}" + + [ "${status}" -ne 0 ] + [[ "${output}" == *'::error::'* ]] + [[ "${output}" != *'secret-part'* ]] + [ ! -e "${NPMRC}" ] +} + +@test "rejects a token containing a newline, without printing it or writing a file" { + export JFROG_TOKEN='secret-part +other-part' + + run "${WRITE}" + + [ "${status}" -ne 0 ] + [[ "${output}" == *'::error::'* ]] + [[ "${output}" != *'secret-part'* ]] + [ ! -e "${NPMRC}" ] +} + +@test "replaces an existing ~/.npmrc instead of appending to it" { + printf 'stale=content\n' >"${NPMRC}" + export JFROG_TOKEN='test-token' + + run "${WRITE}" + + [ "${status}" -eq 0 ] + [[ "$(cat "${NPMRC}")" != *'stale=content'* ]] + [ "$(wc -l <"${NPMRC}")" -eq 3 ] +} diff --git a/.github/workflow-templates/fe/fe-cleanup-snapshots.yml b/.github/workflow-templates/fe/fe-cleanup-snapshots.yml index 6426e03..26773ee 100644 --- a/.github/workflow-templates/fe/fe-cleanup-snapshots.yml +++ b/.github/workflow-templates/fe/fe-cleanup-snapshots.yml @@ -17,4 +17,3 @@ jobs: JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} - DOT_NPMRC: ${{ secrets.DOT_NPMRC }} diff --git a/.github/workflow-templates/fe/fe-licenses.yml b/.github/workflow-templates/fe/fe-licenses.yml index aa73fb0..dd30fd5 100644 --- a/.github/workflow-templates/fe/fe-licenses.yml +++ b/.github/workflow-templates/fe/fe-licenses.yml @@ -22,4 +22,4 @@ jobs: FOSS_DIST: dist CUSTOM_LICENSES_JSON: custom-licenses/custom-licenses.json secrets: - DOT_NPMRC: ${{ secrets.DOT_NPMRC }} + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} diff --git a/.github/workflow-templates/fe/fe-main.yml b/.github/workflow-templates/fe/fe-main.yml index 9f5f197..7fda954 100644 --- a/.github/workflow-templates/fe/fe-main.yml +++ b/.github/workflow-templates/fe/fe-main.yml @@ -25,7 +25,7 @@ jobs: with: GHA_REF: '' secrets: - DOT_NPMRC: ${{ secrets.DOT_NPMRC }} + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} # This job is only needed in case you are using Percy e2e-tests: diff --git a/.github/workflow-templates/fe/fe-pr-close.yml b/.github/workflow-templates/fe/fe-pr-close.yml index 343e941..da0682c 100644 --- a/.github/workflow-templates/fe/fe-pr-close.yml +++ b/.github/workflow-templates/fe/fe-pr-close.yml @@ -20,4 +20,3 @@ jobs: JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} - DOT_NPMRC: ${{ secrets.DOT_NPMRC }} diff --git a/.github/workflow-templates/fe/fe-pr-snapshot.yml b/.github/workflow-templates/fe/fe-pr-snapshot.yml index 7354093..2c7051e 100644 --- a/.github/workflow-templates/fe/fe-pr-snapshot.yml +++ b/.github/workflow-templates/fe/fe-pr-snapshot.yml @@ -20,4 +20,3 @@ jobs: JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} - DOT_NPMRC: ${{ secrets.DOT_NPMRC }} diff --git a/.github/workflow-templates/fe/fe-pr.yml b/.github/workflow-templates/fe/fe-pr.yml index d77f0e6..3b2523f 100644 --- a/.github/workflow-templates/fe/fe-pr.yml +++ b/.github/workflow-templates/fe/fe-pr.yml @@ -25,7 +25,7 @@ jobs: with: GHA_REF: ${{ github.event.pull_request.head.ref }} secrets: - DOT_NPMRC: ${{ secrets.DOT_NPMRC }} + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} build: needs: install-deps diff --git a/.github/workflows/fe-cleanup-snapshots.yml b/.github/workflows/fe-cleanup-snapshots.yml index fbdac7b..b613ada 100644 --- a/.github/workflows/fe-cleanup-snapshots.yml +++ b/.github/workflows/fe-cleanup-snapshots.yml @@ -12,8 +12,9 @@ on: required: true JFROG_USER: required: true + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed DOT_NPMRC: - required: true + required: false jobs: build: @@ -39,6 +40,7 @@ jobs: - name: Use .npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Cleanup Snapshot Artifacts diff --git a/.github/workflows/fe-licenses.yml b/.github/workflows/fe-licenses.yml index d2f4b3d..7a6f1c3 100644 --- a/.github/workflows/fe-licenses.yml +++ b/.github/workflows/fe-licenses.yml @@ -10,8 +10,11 @@ on: required: false type: string secrets: + JFROG_TOKEN: + required: false + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed DOT_NPMRC: - required: true + required: false jobs: check-licenses: @@ -38,6 +41,7 @@ jobs: - name: Use .npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install modules diff --git a/.github/workflows/fe-pr-close.yml b/.github/workflows/fe-pr-close.yml index 75e1ccf..fae84ac 100644 --- a/.github/workflows/fe-pr-close.yml +++ b/.github/workflows/fe-pr-close.yml @@ -16,8 +16,9 @@ on: required: true JFROG_USER: required: true + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed DOT_NPMRC: - required: true + required: false jobs: remove-artifacts: @@ -41,6 +42,7 @@ jobs: - name: Use .npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install modules diff --git a/.github/workflows/fe-pr-snapshot.yml b/.github/workflows/fe-pr-snapshot.yml index df2c86c..dde25af 100644 --- a/.github/workflows/fe-pr-snapshot.yml +++ b/.github/workflows/fe-pr-snapshot.yml @@ -16,8 +16,9 @@ on: required: true JFROG_USER: required: true + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed DOT_NPMRC: - required: true + required: false jobs: publish-pr-snapshot: @@ -59,6 +60,7 @@ jobs: - name: Use .npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install modules diff --git a/.github/workflows/fe-release-flow.yml b/.github/workflows/fe-release-flow.yml index e27b370..ff8e3d0 100644 --- a/.github/workflows/fe-release-flow.yml +++ b/.github/workflows/fe-release-flow.yml @@ -22,8 +22,9 @@ on: required: true JFROG_USER: required: true + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed DOT_NPMRC: - required: true + required: false # Unused since PFM-ISSUE-33676 (the git identity is the github-actions bot). Kept optional so # callers that still pass them keep working; removed by the FE migration/cleanup ticket. GIT_USER: @@ -78,6 +79,7 @@ jobs: with: GHA_REF: '' secrets: + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} DOT_NPMRC: ${{ secrets.DOT_NPMRC }} build: @@ -136,6 +138,7 @@ jobs: - name: Use .npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install Modules diff --git a/.github/workflows/fe-release.yml b/.github/workflows/fe-release.yml index 3198cdc..f6536c5 100644 --- a/.github/workflows/fe-release.yml +++ b/.github/workflows/fe-release.yml @@ -12,8 +12,9 @@ on: required: true JFROG_USER: required: true + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed DOT_NPMRC: - required: true + required: false env: NX_BRANCH: ${{ github.event.number }} @@ -45,6 +46,7 @@ jobs: - name: Use .npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install Modules diff --git a/.github/workflows/fe-sonar.yml b/.github/workflows/fe-sonar.yml index 59fe86b..e975b08 100644 --- a/.github/workflows/fe-sonar.yml +++ b/.github/workflows/fe-sonar.yml @@ -7,9 +7,12 @@ on: SONAR_CLOUD_TOKEN: required: true description: "SonarCloud authentication token" + JFROG_TOKEN: + required: false + description: "JFrog token; authenticates npm installs against the cplace-npm virtual" DOT_NPMRC: - required: true - description: "Contents of the .npmrc file for authenticating against private npm registries" + required: false + description: "Deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed" inputs: SONAR_CLOUD_ORG: required: false @@ -58,6 +61,7 @@ jobs: id: use-npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install dependencies diff --git a/README.md b/README.md index 1196644..4a74617 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ JavaScript action runtime since June 2026). the latest majors: checkout v6, cache v5, setup-node v6, upload-artifact v7, download-artifact v8, github-script v9, sonarqube-scan-action v8. - Self-hosted runners must run GitHub Actions Runner **>= 2.327.1**. -- `.npmrc` provisioning uses the in-repo composite `.github/actions/use-npmrc` (input `dot-npmrc`), - referenced per release branch like all internal composites. +- `.npmrc` provisioning uses the in-repo composite `.github/actions/use-npmrc` (input `jfrog-token`; + `dot-npmrc` is deprecated), referenced per release branch like all internal composites. - `.github/dependabot.yml` keeps the SHA pins current on `master` and the active release branches (`release/25.2` through `release/26.2`) via per-branch `target-branch` entries; each branch gets one grouped Action-update PR per week. @@ -82,10 +82,10 @@ run ends green with the warning "FORCE is ignored". ### Required secrets -Passed with `secrets: inherit`: `JFROG_TOKEN`, `JFROG_URL`, `JFROG_USER`, `DOT_NPMRC`, -and optionally `PERCY_TOKEN`. The caller needs `permissions: contents: write`; the flow grants it -only to the `release` and `github-release` jobs. The flow sets the `github-actions[bot]` git -identity itself; `GIT_USER` and `GIT_USER_EMAIL` are still accepted but unused. The upmerge check +Passed with `secrets: inherit`: `JFROG_TOKEN`, `JFROG_URL`, `JFROG_USER`, and optionally +`PERCY_TOKEN`. The caller needs `permissions: contents: write`; the flow grants it only to the +`release` and `github-release` jobs. The flow sets the `github-actions[bot]` git identity itself; +`GIT_USER` and `GIT_USER_EMAIL` are still accepted but unused. The upmerge check (`fe-check-upmerge.yml`) needs only `SLACK_TOKEN_UPMERGE`. The tag is pushed with `GITHUB_TOKEN`; the flow does not use `GIT_USER_TOKEN`. The deprecated @@ -97,13 +97,13 @@ A repo can delete `GIT_USER` and `GIT_USER_EMAIL` once no caller passes them exp #### JFrog and npm secrets (all FE workflows) -| Secret | Content | Used for | -| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -| `JFROG_URL` | URL of the npm repository artifacts are published to (`cplace-npm-local`); must end with `/`, or `npm publish` fails with ENEEDAUTH | `:registry=`, `publishConfig.registry`, `--registry=` and the credential key of the generated dist `.npmrc` | -| `JFROG_USER` | JFrog user that owns `JFROG_TOKEN` | logged as the publishing identity; not used for authentication | -| `JFROG_TOKEN` | JFrog reference token of `JFROG_USER` with deploy, delete and annotate rights on `cplace-npm-local` | publish, unpublish, `npm show` and `dist-tag`: written literally as `_authToken=${JFROG_TOKEN}` into the dist `.npmrc` and expanded by npm at runtime | -| `JFROG_BASE64_TOKEN` | **Deprecated.** `base64(user:secret)` | `_auth` in the dist `.npmrc`, only when `JFROG_TOKEN` is not passed; the run shows a deprecation warning | -| `DOT_NPMRC` | a complete `.npmrc` | installs (`npm ci`), `npm search`/`npm view` in snapshot cleanup, third-party registries; never used for publishing | +| Secret | Content | Used for | +| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `JFROG_URL` | URL of the npm repository artifacts are published to (`cplace-npm-local`); must end with `/`, or `npm publish` fails with ENEEDAUTH | `:registry=`, `publishConfig.registry`, `--registry=` and the credential key of the generated dist `.npmrc` | +| `JFROG_USER` | JFrog user that owns `JFROG_TOKEN` | logged as the publishing identity; not used for authentication | +| `JFROG_TOKEN` | JFrog reference token of `JFROG_USER` with deploy, delete and annotate rights on `cplace-npm-local`, and **read on the `cplace-npm` virtual** (for `cplace-project-planning-fe`, `JFROG_USER` must be in `bryntum-readers`) | publish, unpublish, `npm show` and `dist-tag`: written literally as `_authToken=${JFROG_TOKEN}` into the dist `.npmrc` and expanded by npm at runtime; installs: `use-npmrc` writes it literally as `_authToken` for the `cplace-npm` virtual into `~/.npmrc` (`npm ci`, `npm view`/`npm search` in snapshot cleanup). Read-only workflows (install-deps, licenses, sonar) therefore receive this publish-capable token too | +| `JFROG_BASE64_TOKEN` | **Deprecated.** `base64(user:secret)` | `_auth` in the dist `.npmrc`, only when `JFROG_TOKEN` is not passed; the run shows a deprecation warning | +| `DOT_NPMRC` | **Deprecated.** A complete `.npmrc` | installs, only when `JFROG_TOKEN` is not passed; the run shows a deprecation warning, and a `::notice::` when both are passed; never used for publishing | To migrate a repository: set the `JFROG_TOKEN` secret (and make `JFROG_USER` its owner), then replace the `JFROG_BASE64_TOKEN:` line with `JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}` in every caller that references the @@ -113,6 +113,18 @@ those reusables do not declare `JFROG_TOKEN` and still require `JFROG_BASE64_TOK release branch still passes it. A publishing or deleting run without either secret fails with "No JFrog credentials". +To switch installs to `JFROG_TOKEN` (the token needs read on the `cplace-npm` virtual, see the table): + +- In every caller that references the reusables `@master`, replace the `DOT_NPMRC:` line with + `JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}` in the `fe-install-deps`, `fe-licenses` and `fe-sonar` callers, + and delete it in the others, which already pass `JFROG_TOKEN`. +- Callers that reference `@release/26.4` or older stay unchanged. Keep the `DOT_NPMRC` repository secret while + a release branch still uses it. +- Workflows called with `secrets: inherit` switch without an edit. +- A run with neither secret fails in `use-npmrc` with "No npm credentials". +- The generated `~/.npmrc` authenticates only the cplace npm proxy. Lockfile entries on other JFrog paths are + fetched without credentials and fail, so normalize them first (`tools/scripts/lockfile/README.md`). + ### Tag rulesets The tag is pushed as GitHub Actions (`GITHUB_TOKEN`), after publish and promote. A ruleset that diff --git a/tools/scripts/lockfile/README.md b/tools/scripts/lockfile/README.md index 55c341d..1b0eedf 100644 --- a/tools/scripts/lockfile/README.md +++ b/tools/scripts/lockfile/README.md @@ -53,7 +53,8 @@ replace-registry-host=never This tells npm to fetch each `resolved` URL **verbatim** rather than rewriting its host onto the configured registry. It makes an un-normalized lockfile install on any npm version, so it protects **consumer** repositories too, not just -this one. JFrog URLs stay authenticated by the secret, so it introduces no dependency on anonymous JFrog access. +this one. Entries on the proxy stay authenticated by the token in the generated `~/.npmrc`. JFrog entries outside the +proxy prefix get no credentials. **The rewrite it disables is broken on npm 11, not on npm 10.** Measured 2026-08-14 with a one-package fixture, on a runner and locally: From 3984be22573289005a0d1e52ea33c1e72a269908 Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Fri, 4 Dec 2026 12:01:22 +0100 Subject: [PATCH 4/5] PFM-ISSUE-34294 - Restore the dist .npmrc before promote and delete when a rebuild removed it nx restores a published library from its local cache when a later project depends on it, which replaces its dist directory without the dist .npmrc. promote() and the release flow's failure cleanup then ran against JFROG_URL with only ~/.npmrc. DOT_NPMRC used to cover that by accident; the generated ~/.npmrc authenticates only the cplace-npm read virtual, so both failed with E401 (live test B1 on clone-cplace-fe). Co-Authored-By: Claude Opus 5.5 --- tools/scripts/artifacts/nx-project.test.ts | 60 ++++++++++++++++++++++ tools/scripts/artifacts/nx-project.ts | 21 ++++++++ 2 files changed, 81 insertions(+) diff --git a/tools/scripts/artifacts/nx-project.test.ts b/tools/scripts/artifacts/nx-project.test.ts index f7de6c2..3a911dd 100644 --- a/tools/scripts/artifacts/nx-project.test.ts +++ b/tools/scripts/artifacts/nx-project.test.ts @@ -250,6 +250,34 @@ describe('NxProject.deleteArtifact', () => { expect((execSync as jest.Mock).mock.calls).toHaveLength(1); expect(exit).toHaveBeenCalledWith(1); }); + + test('writes the dist .npmrc before the lookup when a rebuild removed it from an existing dist directory', async () => { + // the release flow's failure cleanup: dist/ exists, but nx replaced the project's directory + jest + .spyOn(fs, 'existsSync') + .mockImplementation((p) => !String(p).endsWith('.npmrc')); + jest.spyOn(fs, 'mkdirSync').mockReturnValue(undefined); + const writeFileSync = jest.spyOn(fs, 'writeFileSync').mockReturnValue(); + process.env.JFROG_URL = + 'https://cplace.jfrog.io/artifactory/cplace-npm-local/'; + process.env.JFROG_USER = 'jfrog_user'; + process.env.JFROG_TOKEN = 'secret_value'; + (execSync as jest.Mock).mockReturnValue( + Buffer.from( + JSON.stringify({ name: '@cplace-next/my-app', versions: [] }) + ) + ); + + await anApp().deleteArtifact(version, new JfrogCredentials()); + + expect(writeFileSync).toHaveBeenCalledWith( + expect.stringContaining('dist/apps/my-app/.npmrc'.replace(/\//g, sep)), + expect.stringContaining(':_authToken=${JFROG_TOKEN}') + ); + expect(writeFileSync.mock.invocationCallOrder[0]).toBeLessThan( + (execSync as jest.Mock).mock.invocationCallOrder[0] + ); + }); }); describe('NxProject release dist-tags', () => { @@ -287,6 +315,38 @@ describe('NxProject release dist-tags', () => { expect(calls[0][1].cwd).toContain('dist/apps/my-app'.replace(/\//g, sep)); }); + test('promote restores the dist .npmrc a rebuild removed, before moving the tag', () => { + (execSync as jest.Mock).mockReturnValue(Buffer.from('')); + const project = aReleaseApp(); + project.npmrcContent = + '@cplace-next:registry=https://cplace.jfrog.io/artifactory/cplace-npm-local/'; + jest.spyOn(fs, 'existsSync').mockReturnValue(false); + jest.spyOn(fs, 'mkdirSync').mockReturnValue(undefined); + const writeFileSync = jest.spyOn(fs, 'writeFileSync').mockReturnValue(); + + project.promote(); + + expect(writeFileSync).toHaveBeenCalledWith( + expect.stringContaining('dist/apps/my-app/.npmrc'.replace(/\//g, sep)), + project.npmrcContent + ); + expect(writeFileSync.mock.invocationCallOrder[0]).toBeLessThan( + (execSync as jest.Mock).mock.invocationCallOrder[0] + ); + }); + + test('promote leaves an existing dist .npmrc alone', () => { + (execSync as jest.Mock).mockReturnValue(Buffer.from('')); + const project = aReleaseApp(); + project.npmrcContent = 'anything'; + jest.spyOn(fs, 'existsSync').mockReturnValue(true); + const writeFileSync = jest.spyOn(fs, 'writeFileSync').mockReturnValue(); + + project.promote(); + + expect(writeFileSync).not.toHaveBeenCalled(); + }); + test('a failed move of release-X.Y fails the run and keeps the staging tag', () => { const exit = jest .spyOn(process, 'exit') diff --git a/tools/scripts/artifacts/nx-project.ts b/tools/scripts/artifacts/nx-project.ts index 6c28079..9272780 100644 --- a/tools/scripts/artifacts/nx-project.ts +++ b/tools/scripts/artifacts/nx-project.ts @@ -256,6 +256,10 @@ export class NxProject { ); console.log(`Generated package.json: ${this.getPrettyPackageJson()}`); } + // The dist directory can exist without its .npmrc (see restoreNpmrcInDist). + if (jfrogCredentials && !fs.existsSync(this.getNpmrcPathInDist())) + this.writeNPMRCInDist(jfrogCredentials, this.scope); + else this.restoreNpmrcInDist(); // Has to run after the dist .npmrc exists, so the lookup is authenticated // against JFrog rather than falling through to an anonymous 404. console.log('Checking if package exists in registry'); @@ -323,6 +327,22 @@ export class NxProject { console.log('wrote .npmrc to: ' + npmrcPathInDist); } + /** + * Puts back the dist .npmrc this project wrote before publishing, if it is gone. + * nx rebuilds a published library from its local cache when a later project + * depends on it, and that replaces the dist directory without the .npmrc. npm + * then sees only ~/.npmrc, which authenticates the cplace-npm read virtual and + * not JFROG_URL (PFM-ISSUE-34294), so every call against JFROG_URL fails with + * E401. + */ + private restoreNpmrcInDist() { + const npmrcPathInDist = this.getNpmrcPathInDist(); + if (!this.npmrcContent || fs.existsSync(npmrcPathInDist)) return; + console.log(`Restoring the dist .npmrc of ${this.name}: a rebuild removed it`); + fs.mkdirSync(path.dirname(npmrcPathInDist), { recursive: true }); + fs.writeFileSync(npmrcPathInDist, this.npmrcContent); + } + public setVersionOrGeneratePackageJsonInDist( version: Version, registry: string @@ -384,6 +404,7 @@ export class NxProject { const scopedPackage = `${this.scope}/${this.name}`; const releaseTag = this.version.getNpmTag(); const options = { cwd: this.getPathToProjectInDist() }; + this.restoreNpmrcInDist(); try { console.log( execSync( From e0b3791946136fd3f1987cfbb8534266d2e3dfbe Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Fri, 4 Dec 2026 17:21:23 +0100 Subject: [PATCH 5/5] PFM-ISSUE-34294 - Add the implementation plan and the live test plan with its report Co-Authored-By: Claude Opus 5.5 --- .../live-test-plan.md | 422 +++++++++++ .../plan.md | 653 ++++++++++++++++++ 2 files changed, 1075 insertions(+) create mode 100644 specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/live-test-plan.md create mode 100644 specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/plan.md diff --git a/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/live-test-plan.md b/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/live-test-plan.md new file mode 100644 index 0000000..04f3582 --- /dev/null +++ b/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/live-test-plan.md @@ -0,0 +1,422 @@ +--- +date: 2026-12-03 +branch: improvement/PFM-ISSUE-34294-Use-the-new-secrets-and-remove-the-stored-DOT_NPMRC +topic: "Live test plan for PFM-ISSUE-34294 - runtime-generated ~/.npmrc from JFROG_TOKEN, DOT_NPMRC deprecated" +tags: [live-test, test-plan, clone-cplace-fe, jfrog, npm, npmrc, use-npmrc] +status: draft +--- + +# Live test plan: PFM-ISSUE-34294 in `clone-cplace-fe` + +This plan validates the PFM-ISSUE-34294 implementation on the test fork `collaborationFactory/clone-cplace-fe`. +Installs read through the `cplace-npm` virtual. Publishes and deletes go only to the JFrog test registry +`cplace-npm-test`, and only touch `@cplace-next/*` versions these runs create. + +**What it proves.** `use-npmrc` writes the right `~/.npmrc` for each of the four input cases (token, both, +`DOT_NPMRC` only, neither), in every reusable that runs it, and every later npm call in the job authenticates +through that file. The token never shows up in a log. + +**What it reuses.** The environment, tools, helper library, per-case procedure, JFrog rule and teardown come from +the 34283 live-test document +[`clone-cplace-fe-live-tests.md`](../2026-10-12_PFM-ISSUE-34283_consolidate-fe-release-workflow/clone-cplace-fe-live-tests.md), +abbreviated **LT** (Parts 1, 2 and 4; "LT 2.2" is its helper library). The 34293 plan +[`live-test-plan.md`](../2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md) is +abbreviated **LT93** (its S4 helpers, its A/L/N rules for the dist `.npmrc`, and its release-flow deviations +D1/D2). This plan lists only the deltas and the cases. + +**Already done.** The Phase 1 smoke ([plan.md](./plan.md), Phase 1 §6) ran on 2026-12-03: run `47136400865` +on `main`, token only, cache miss, `npm ci` added 3302 packages, no annotation, all jobs `success`. Case T1 +repeats it on the final branch. + +--- + +## 1. Expected change + +| ID | Item | Before (master) | Expected with 34294 | +|---|---|---|---| +| C1 | `~/.npmrc`, token passed (with or without `DOT_NPMRC`) | `DOT_NPMRC` verbatim + `replace-registry-host=never` | exactly three lines: `registry=https://cplace.jfrog.io/artifactory/api/npm/cplace-npm/`, `//cplace.jfrog.io/artifactory/api/npm/cplace-npm/:_authToken=`, `replace-registry-host=never`; mode `600` | +| C2 | `~/.npmrc`, only `DOT_NPMRC` | as today | unchanged: verbatim + `replace-registry-host=never` | +| C3 | annotation, both passed | none | one `notice`: `DOT_NPMRC is passed but ignored, because JFROG_TOKEN is set. …` per `use-npmrc` call | +| C4 | annotation, only `DOT_NPMRC` | none | one `warning`: `DOT_NPMRC is deprecated. Pass JFROG_TOKEN instead, …` per `use-npmrc` call | +| C5 | neither passed | the run fails at startup (`DOT_NPMRC` is `required: true`) | the run starts; the `Use .npmrc` step fails with the `error` annotation `No npm credentials: …`; `npm ci` does not run | +| C6 | secret declarations in the eight reusables | `DOT_NPMRC: required: true` | `JFROG_TOKEN` and `DOT_NPMRC` both `required: false`, both passed to every `use-npmrc` call; `fe-release-flow`'s nested `install-deps` gets both | +| C7 | `npm view`/`npm search` in snapshot cleanup | authenticate with `DOT_NPMRC` | authenticate with the generated file (token mode); the D2 E404 (LT93 §6) is expected to disappear | +| C8 | npm error URLs | the `registry=` prefix comes from the secret, so an install error prints `***` | in token mode the URL is committed, so errors print it in clear | + +**What does not change:** the dist `.npmrc` that publishes, unpublishes and moves dist-tags (34293; it still +takes `JFROG_TOKEN` from step env), the advisory lockfile warning step, `fe-snapshot` and `fe-check-upmerge` +(no `use-npmrc`). + +--- + +## 2. Test environment + +### 2.1 State on 2026-12-03 (read-only check) + +| Item | Value | +|---|---| +| Secrets | `DOT_NPMRC`, `GRADLE_PROPERTIES`, `JFROG_BASE64_TOKEN`, `JFROG_TOKEN`, `JFROG_URL`, `JFROG_USER`, `SLACK_TOKEN_UPMERGE`. No `SONAR_CLOUD_TOKEN`, no `GIT_USER*` | +| Branches | `main`, `release/26.4`, `release/26.3`, `fix/PFM-ISSUE-35119-…` (leftover) | +| Version tags | up to `version/26.4.13` | +| Labels | `snapshot` exists | +| `node_modules` caches | `release/26.4`, `release/26.3` (`Linux-modules-6cafb80d…`); `main`'s was deleted for the Phase 1 smoke and re-created by it | +| `main` callers | `push_main.yaml`: `fe-install-deps` `@test/PFM-ISSUE-34294-npmrc` with `JFROG_TOKEN` (Phase 1 smoke), `fe-build` `@test/PFM-ISSUE-34282-github-token`, `fe-snapshot` `@test/PFM-ISSUE-34293-jfrog-token`. `pull_request.yaml`: `fe-install-deps`/`fe-build` `@master` with `DOT_NPMRC`. `pull_request_licenses.yaml` (`paths: package.json, package-lock.json`): `fe-licenses` `@master` with `DOT_NPMRC`. `pull_request_snapshot.yaml`, `pull_request_close.yaml`, `cron_cleanup_snapshots.yaml`: `@test/PFM-ISSUE-34293-jfrog-token` with `JFROG_TOKEN` and `DOT_NPMRC`. `sonar-scan.yml` (dispatch only): `fe-sonar` `@master` with `SONAR_CLOUD_TOKEN` and `DOT_NPMRC`. `fe-release.yml` → `fe-release-flow.yml@test/PFM-ISSUE-34282-github-token`, `secrets: inherit` | +| `release/26.4` callers | `fe-release.yml` → `fe-release-flow.yml@test/PFM-ISSUE-33676-bot-identity` (**another ticket's test branch**), `secrets: inherit`, `RUN_E2E` commented out. Other callers `@release/26.4` | +| Other workflows on PR | `xray-scan.yml` runs on `package.json`/`package-lock.json` changes with `bduff9/use-npmrc` and `DOT_NPMRC`. Out of scope (design "NOT doing"); its result is ignored | + +Recheck the rows before Phase 5 starts; record any change in the report. + +### 2.2 Placeholders (in addition to LT) + +| Name | Value | +|---|---| +| `TEST_BRANCH` | `test/PFM-ISSUE-34294-npmrc` | +| `FB` | `improvement/PFM-ISSUE-34294-Use-the-new-secrets-and-remove-the-stored-DOT_NPMRC` | +| `MB` | `main` | +| `BR` | `release/26.4` | +| `OUT` | `/34294` (results, captures, `lib.sh`) | +| `WT` | `$OUT/wt`, a working copy of the clone (LT 1.4: `core.longpaths`, `core.autocrlf false`) | + +### 2.3 Rules for this series + +- **The input case is chosen by caller edits:** which secret lines the clone's caller passes. Never by + changing or deleting a clone secret. Any secret change is a stop (LT 2.1). +- **Every install case needs a cache miss.** In every reusable `npm ci` runs only when the `node_modules` + cache misses, and `fe-sonar` even skips `use-npmrc` on a hit. Before each install case, list the + `*-modules-*` caches of the refs the case runs on (`MB`, the PR merge ref `refs/pull//merge`, `BR`) and + delete them. **Every cache deletion is a stop:** show the ids and keys, then delete with + `gh api -X DELETE repos/$R/actions/caches/`. Evidence row X1 (§3) proves that the cache missed. A case + whose log shows a cache hit is `inconclusive` and runs again. +- **The release flow (`secrets: inherit`) receives both secrets**, so it always runs the "both" path (B1). +- Every push to `github-actions` is a stop (LT 2.1). Pushes, PRs, labels and dispatches on the clone are allowed. +- One case at a time (LT 2.1, LT 2.3). + +### 2.4 Setup + +**S1: Recreate the test branch** (stop: the delete and the push). The Phase 1 test branch predates Phases 2 +and 3, so P3 fails until it is recreated. +1. Delete the remote `TEST_BRANCH` and recreate it from `origin/$FB`. +2. One commit rewrites every internal `collaborationFactory/github-actions/.github/...@master` ref in + `.github/workflows` and `.github/actions` to `@$TEST_BRANCH` (14 files). `workflow-templates` stay on + `@master`. +3. Run LT P2 and P3 against `TEST_BRANCH`/`FB`. Both must be empty. + +**S2: Point the `main` callers at the test branch, token only.** One commit on `MB`, `.github/workflows` +only, no `package.json`/`package-lock.json`: +- `pull_request.yaml` `install-deps`, `pull_request_licenses.yaml`: `@master` → `@$TEST_BRANCH`; + `DOT_NPMRC:` line → `JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}`. (`fe-build` stays as it is: no `use-npmrc`.) +- `pull_request_snapshot.yaml`, `pull_request_close.yaml`, `cron_cleanup_snapshots.yaml`: + `@test/PFM-ISSUE-34293-jfrog-token` → `@$TEST_BRANCH`; delete the `DOT_NPMRC:` line. +- `sonar-scan.yml`: `@master` → `@$TEST_BRANCH`; `DOT_NPMRC:` line → `JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}`; + add `GITHUB_RUNNER: ubuntu-latest` under `with:`, so the case does not depend on a `medium` runner. +- `push_main.yaml`: `install-deps` is already `@$TEST_BRANCH` with `JFROG_TOKEN`. +- **Before the push** (stop): delete `MB`'s `*-modules-*` cache. The push starts the main CI, which is **T1**. + +**S3: Helpers.** Source LT 2.2 into `$OUT/lib.sh`, plus LT93 S4 `annotations`, plus: + +```bash +# caches : node_modules caches of one ref (id, key) +caches() { gh api "repos/$R/actions/caches?ref=$1&per_page=100" --jq '.actions_caches[] | select(.key | test("-modules-")) | "\(.id)\t\(.key)"'; } +# leak_check : lines that must not appear in any 34294 run +leak_check() { + grep -n '_authToken=' "$1" | grep -v '_authToken=${JFROG_TOKEN}' + grep -nE 'api/npm/cplace-npm/:_authToken|Failed to replace env in config' "$1" +} +# auth_errors +auth_errors() { grep -nE 'E401|E403|E404|ENEEDAUTH|Unable to authenticate' "$1"; } +``` + +**S4: Preflight.** LT P2, P3, P9 (nothing in flight), P10 (tools), plus: + +| ID | Check | Pass | +|---|---|---| +| Q1 | `gh api repos/$R/actions/secrets --jq '.secrets[].name'` | lists `JFROG_TOKEN`, `DOT_NPMRC`, `JFROG_BASE64_TOKEN`, `JFROG_URL`, `JFROG_USER` | +| Q2 | `uses:` and secret lines of the seven callers on `MB` | as after S2 | +| Q3 | `git diff origin/master...origin/$FB --stat -- .github README.md tools` | only the files of [plan.md](./plan.md) Phases 1–3 | + +--- + +## 3. Expected-state rules + +**X: every case that runs `use-npmrc`** + +| Row | Rule | Evidence | +|---|---|---| +| X1 | Install cases: the job log has `Cache not found for input keys` and an `npm ci` that ran (`added N packages`) | job log | +| X2 | The `Write ~/.npmrc` step env shows `JFROG_TOKEN: ***` when a token is passed (empty otherwise) and `DOT_NPMRC: ***` or empty, as the case passes them | job log | +| X3 | `leak_check` is empty: the only `_authToken=` lines are dist `.npmrc` printouts with the literal `${JFROG_TOKEN}`, and no log contains the generated `~/.npmrc` content | all job logs of the run | +| X4 | `auth_errors` is empty, except where a case expects an error | all job logs | +| X5 | The `use-npmrc` annotations are exactly the case's: T none, B one `notice` (C3), L one `warning` (C4), N one `failure` (C5). The lockfile advisory `warning` may appear in any case, and is recorded | `annotations` per job | +| X6 | Every version the run created or deleted is checked by exact path in `cplace-npm-test` (LT 4.2) | AQL | + +**Publish and delete rows:** for the mixed jobs (`fe-pr-snapshot`, `fe-pr-close`, `fe-cleanup-snapshots`, the +release flow), the LT93 §3 A rules apply to the dist `.npmrc` (token mode), or the L rules when the case passes +`JFROG_BASE64_TOKEN` instead (L2). The release rules are LT 3.1 RELEASE(N), with D1 (LT93 §6: no GitHub +release while `RUN_E2E: false`) accepted as pre-existing. + +--- + +## 4. Test cases + +Before each case: `T0`, `snapshot "$OUT//before"`, the cache check and deletion (§2.3). After it: capture, +evaluate, `verdict.md`, ledger, results line (LT 2.3). + +| ID | Input | Flow | Trigger | Proves | +|---|---|---|---|---| +| T1 | token | main CI `fe-install-deps` | the S2 push to `MB` | generated file, `npm ci` against the virtual (re-run of the Phase 1 smoke on the final branch) | +| T2 | token | `fe-licenses` (PR touching `package-lock.json`) | open PR from `test/34294-pr-token` | install + license check | +| T3 | token | `fe-sonar` (`sonar-scan.yml`, dispatch) | `gh workflow run sonar-scan.yml -R $R --ref main` | cache-gated `use-npmrc` path | +| T4 | token | `fe-pr-snapshot`, labelled PR | label `snapshot` on T2's PR | install via `~/.npmrc` and publish via dist `.npmrc` in one job | +| T5 | token | `fe-pr-close` on T4's PR | close T2's PR unmerged | install + unpublish | +| T6 | token | `fe-cleanup-snapshots` (dispatch) | `gh workflow run cron_cleanup_snapshots.yaml -R $R --ref main` | `npm view`/`npm search` without E404 (D2) | +| B1 | both | release flow push on `BR` (inherit) | caller edit on `BR`, then forced dispatch | token wins, `::notice::`, publish + promote + tag | +| B2 | both | main CI `fe-install-deps` with both lines | caller edit pushed to `MB` | `::notice::`, token file | +| L1 | `DOT_NPMRC` only | main CI `fe-install-deps` | caller edit pushed to `MB` | fallback still installs, `::warning::` | +| L2 | `DOT_NPMRC` only | `fe-pr-snapshot` | labelled PR from `test/34294-pr-legacy` with a legacy caller | fallback in the mixed job | +| N1 | neither | main CI `fe-install-deps` | caller edit pushed to `MB` | fails in `Write ~/.npmrc` with `::error::`, before `npm ci` | + +### T1: Main CI, token (re-run of the smoke) + +- **Precondition:** S1–S4 done; `MB`'s cache deleted before the S2 push. +- **Expected:** "Frontend Main CI" `success`. `install-deps` uses `fe-install-deps.yml@refs/heads/$TEST_BRANCH`. + X1–X5 with no `use-npmrc` annotation. The snapshot job has no project affected (workflow-only commit) and + publishes nothing. +- **Compare** with the Phase 1 run `47136400865`. + +### T2: Licenses, token + +- **Setup:** branch `test/34294-pr-token` from `origin/main` plus one commit that adds a trailing newline to + `package-lock.json`. That triggers `pull_request_licenses.yaml` (and `xray-scan.yml`, ignored), and the new + lock hash makes every cache miss without a deletion. +- **Trigger:** `gh pr create -R $R --base main --head test/34294-pr-token --title "34294 T2 token" --body "live test, do not merge"`. +- **Expected:** the licenses run `success`: X1–X5, no `use-npmrc` annotation, and the license check ran on the + installed tree. The PR CI run (`pull_request.yaml` `install-deps`, token) is an extra token observation: X1–X5. + +### T3: Sonar, token + +- **Precondition:** S2 done (the caller passes `JFROG_TOKEN`, `GITHUB_RUNNER: ubuntu-latest`). Delete `MB`'s + cache (stop), because `fe-sonar` runs `use-npmrc` only on a cache miss. +- **Trigger:** `gh workflow run sonar-scan.yml -R $R --ref main`; find the run with `runs_since "$T0"`. +- **Expected:** the run starts. Steps `Use .npmrc` and `Install dependencies` `success`, with X1–X5 and no + `use-npmrc` annotation. +- **Out of scope:** the clone has no `SONAR_CLOUD_TOKEN`, so the scan step is expected to fail. Steps after + `Install dependencies` (format, lint, tests, scan) are not 34294 rows. Cancel the run once + `Install dependencies` has finished, and record the cancel. If GitHub refuses the call at startup because + `SONAR_CLOUD_TOKEN` is empty, record T3 as `skipped`, with that reason, and ask the user for a temporary + secret value (stop). + +### T4: PR snapshot, token + +- **Precondition:** T2's PR open. Delete the caches of `refs/pull//merge` (stop): T2's runs saved one. +- **Trigger:** `gh api repos/$R/issues//labels -f 'labels[]=snapshot'`. +- **Expected:** "Frontend Pull Request Snapshot CI" `success`: X1–X5, no `use-npmrc` annotation; LT93 A1–A6 for + the publish (two-line dist `.npmrc` printout per project, `"authMode":"TOKEN"`); versions + `0.0.0-test-34294-pr-token-` published (record the package list). + +### T5: PR close, token + +- **Precondition:** T4 done. Delete the PR ref's caches again (stop): T4 saved one. +- **Trigger:** `gh pr close -R $R` (unmerged). +- **Expected:** "Frontend Pull Request Close CI" `success`: X1–X5, no `use-npmrc` annotation; every T4 version + unpublished; AQL 0 hits (allow LT 2.3 step 5 metadata delay). +- **Cleanup:** delete the branch `test/34294-pr-token`. + +### T6: Snapshot cleanup, token (D2) + +- **Precondition:** S2 done (the cleanup caller passes only `JFROG_TOKEN`). No cache deletion needed: + `fe-cleanup-snapshots` runs no `npm ci`. +- **Trigger:** `gh workflow run cron_cleanup_snapshots.yaml -R $R --ref main`. +- **Expected:** `success`. X2–X5. The `CleanupSnapshots` search (`npm search`/`npm view`) runs with the generated + file and ends without E404, which is the D2 symptom of 34293's T5 (run `45587848793`). AQL before = after, + unless a snapshot in `cplace-npm-test` is at least 4 months old. +- **If D2 persists:** record `fail` with the failing package and the now-unmasked URL (C8), and keep D2 on its own + ticket (design "Side issues"). +- **Stop** if any `npm unpublish` appears: check its version against the ledger first (LT 4.2). + +### B1: Release flow on `BR`, both + +- **Why `BR` needs a stop:** `BR`'s caller points at `@test/PFM-ISSUE-33676-bot-identity`, another ticket's test + branch. Ask the user before re-pointing it, and restore it after the case. + - Fallback, if the user declines: a forced dispatch of `MB`'s `fe-release.yml` (snapshot path of the release + flow). It proves the same `use-npmrc` path, with no promote and no tag. +- **Setup:** one commit on `BR`: in `fe-release.yml`, the ref → `@$TEST_BRANCH`, and `RUN_E2E: false` active + (the clone cannot run e2e; LT 1.7). Keep `secrets: inherit`. Delete `BR`'s cache before the push (stop). The + push starts a release run with nothing affected: expected NO-RELEASE (LT 3.1). That run is **B1a**: the nested + `install-deps` with X1–X5 and one `notice`. +- **Trigger:** `gh workflow run fe-release.yml -R $R --ref $BR -f force=true`. The `release` job installs again + (its cache was saved by B1a, so the install proof is B1a; the `release` job's `Use .npmrc` still shows the + notice). +- **Expected:** RELEASE(N), with `N` from the before-snapshot (26.4.14 if nothing else released). Every + `use-npmrc` call writes the token file and emits one `notice` (X5). No `warning`. LT93 A1–A6 on the `release` + job. D1 applies: `github-release` is skipped (pre-existing; create the GitHub release by hand only if the user + asks). +- **Restore:** one commit on `BR` back to `@test/PFM-ISSUE-33676-bot-identity` with `RUN_E2E` commented out, + exactly the previous content (NO-RELEASE run, recorded as an extra observation). + +### B2: Main CI, both + +- **Trigger:** delete `MB`'s cache (stop), then push one commit to `MB` that adds + `DOT_NPMRC: ${{ secrets.DOT_NPMRC }}` under `push_main.yaml`'s `install-deps` secrets (next to `JFROG_TOKEN`). +- **Expected:** `success`; X1–X4; exactly one `notice` `DOT_NPMRC is passed but ignored …` on `install-deps`, and + no `warning` from `use-npmrc`. The step env shows both as `***`. + +### L1: Main CI, `DOT_NPMRC` only + +- **Trigger:** delete `MB`'s cache (stop), then push one commit to `MB` that removes the `JFROG_TOKEN:` line from + `push_main.yaml`'s `install-deps` secrets (only `DOT_NPMRC` left). +- **Expected:** `success`; X1–X4; exactly one `warning` `DOT_NPMRC is deprecated …` on `install-deps`, visible in + the run summary. `npm ci` installs through `DOT_NPMRC`. + +### L2: PR snapshot, `DOT_NPMRC` only + +- **Setup:** branch `test/34294-pr-legacy` from `origin/main` plus one commit: + - `package-lock.json`: a trailing newline (cache miss); + - `pull_request_snapshot.yaml`: drop `JFROG_TOKEN:`, keep `DOT_NPMRC:`, and add + `JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }}`, so the publish has a credential (legacy mode). A + `pull_request` run uses the workflow files of the PR's merge ref, so this selects the case for this PR only. +- **Trigger:** open the PR with the label: `gh pr create … --label snapshot`. +- **Expected:** "Frontend Pull Request Snapshot CI" `success`. On the job: one `warning` `DOT_NPMRC is + deprecated …` (`use-npmrc`) and one `warning` `JFROG_BASE64_TOKEN is deprecated …` (artifacts, LT93 L rules); + X1–X4; versions `0.0.0-test-34294-pr-legacy-` published. +- **Cleanup:** close the PR. The close run on `MB`'s token caller unpublishes the versions; check with AQL = 0. + Delete the branch. + +### N1: Main CI, neither + +- **Trigger:** push one commit to `MB` that removes the whole `secrets:` block of `push_main.yaml`'s + `install-deps` job. No cache deletion is needed: in `fe-install-deps`, `use-npmrc` is not cache-gated. +- **Expected:** the run starts: no `Secret … is required` startup failure (C6). `install-deps` `failure` at + `Use .npmrc` with one `failure` annotation `No npm credentials: …`; `Install modules` did not run; `build` and + `snapshot` skipped. X3. +- **Restore:** push the caller back to `JFROG_TOKEN` only (recorded as an extra observation). + +--- + +## 5. The user's pre-merge token check + +Design Known Risk 1: a repo whose `JFROG_TOKEN` cannot read `cplace-npm` breaks at merge, because the token +wins. The user runs this check, locally and with each repo's own token, before the merge. The token never goes +into a file in this repository or into a log. + +- **Read check, per repo:** a `200` from + `curl -s -o /dev/null -w '%{http_code}' -H "Authorization: Bearer $TOKEN" https://cplace.jfrog.io/artifactory/api/npm/cplace-npm/@cplace-next%2fcf-frontend-sdk`. + For project-planning-fe, also a Bryntum package, e.g. `@bryntum%2fgantt`. +- **Install check, per identity group:** in a clean checkout of the group's repository, + `HOME=$(mktemp -d) JFROG_TOKEN=$TOKEN bash /.github/actions/use-npmrc/write-npmrc.sh`, then + `npm ci` with that `HOME`. A pass is a complete install with no E401/E403/E404. + +| Repository | Identity group (`JFROG_USER`) | Flag | Read `cplace-npm` | `npm ci` (group) | Verdict | Note | +|---|---|---|---|---|---|---| +| cplace-2lforge-toolbar-fe | `svcusr_2lforge-all-repo-fe` | | | | | | +| cplace-2lforge-trees-fe | `svcusr_2lforge-all-repo-fe` | | | | | | +| cplace-citizen-ai-fe | `svcusr_cf_cplace_docu` | | | | | | +| cplace-dataciders-portfolio-management-fe | `svcusr_rpt_loomeo_jfrog` | | | | | | +| cplace-fe | `squad_fe` | | | | | | +| cplace-loomeo-fe | `svcusr_rpt_loomeo_jfrog` | | | | | | +| cplace-lowcode-widget-builder-fe | `svcusr_cplace-lowcode-widget-buld-fe` | | | | | | +| cplace-office-reports-fe | `svcusr_cf_lowcode_jfrog` | **check** | | | | install user was `svcusr_cf_cplace_docu` | +| cplace-paw-fe | `squad_fe` | | | | | | +| cplace-project-planning-fe | `svcusr_cf_projplanning-fe` | **check** | | | | Bryntum via `bryntum-readers` | +| cplace-remote-filesystem-fe | `svcusr_cplace-remotfilesys-fe` | | | | | 34293 pilot | +| cplace-resource-management-fe | `squad_fe` | **check** | | | | old token opaque, read identity unknown | +| cplace-time-bounded-values-fe | `squad_fe` | | | | | | +| cplace-workflow-fe | `svcusr_cf_lowcode_jfrog` | **check** | | | | install user was `svcusr_cf_cplace_docu` | + +Identity groups for the install check: one repo each from `squad_fe`, `svcusr_cf_lowcode_jfrog` (both flagged +repos), `svcusr_cf_projplanning-fe`, `svcusr_rpt_loomeo_jfrog`, `svcusr_2lforge-all-repo-fe`, and every +single-repo identity. A `fail` blocks the merge until the identity or permission is fixed, and the fix is noted +in the row. + +--- + +## 6. Pass criteria for the ticket + +| Requirement / success criterion ([design.md](./design.md)) | Shown by | +|---|---| +| The install `~/.npmrc` is generated at runtime from `JFROG_TOKEN` | X1/X2 in T1–T6, B1, B2 | +| Installs and publishes succeed with the generated file | T1–T5 install; T4, B1 publish; T5 unpublish; B1 promote and tag | +| All four input cases behave as specified | T (token), B1/B2 (both, notice), L1/L2 (`DOT_NPMRC` only, warning), N1 (neither, error) | +| Every reusable that runs `use-npmrc` is covered | install-deps T1/B2/L1/N1, licenses T2, sonar T3, pr-snapshot T4/L2, pr-close T5, cleanup-snapshots T6, release flow + nested install-deps B1 | +| Cleanup no longer fails with E404 (D2) | T6 | +| No log line contains the token | X3 in every case | +| No startup failure for callers passing either, both or neither | every case starts; N1 in particular | +| The 34453 mitigation and the advisory step stay | the token file's third line (bats), the warn step in every `use-npmrc` call | +| Every repo's token reads `cplace-npm` | §5, all 14 rows | + +Any failed row stops the series (LT 2.1). Record it, fix it on `FB`, recreate the test branch (S1) and rerun +from the failed case. T1–T5, B1, B2, L1, L2 and N1 must pass. T6 must pass, or D2 is recorded as persisting +(design: then it stays on its own ticket). + +--- + +## 7. Report + +To be filled in Phase 5. One row per case; the verdict is `pass`, `fail` or `skipped`. Run ids are +`clone-cplace-fe` Actions runs (`https://github.com/collaborationFactory/clone-cplace-fe/actions/runs/`). +Captures, evidence and the ledger are in `$OUT` (scratchpad, not kept). + +Executed from 2026-12-03 against `TEST_BRANCH` `3fd97e8`, recreated from `FB` `e48a4b3` (P2, P3 empty; Q1, Q3, +P9, P10 OK). S2 is clone `main` commit `17306aa`. + +**Rebase on 2026-12-04 (before B1).** The first B1a run (47297643979) failed at startup with `Secret GIT_USER is required, but not provided`: `FB` predated `master` `82d5e28` (PFM-ISSUE-33676, #192), which makes `GIT_USER`/`GIT_USER_EMAIL` optional in `fe-release-flow.yml`, and the 33676-adapted clone no longer has those secrets. `FB` was rebased onto `82d5e28` (now `b2feaa2`; conflicts in `fe-release-flow.yml` and `README.md` resolved by keeping 33676's text plus the 34294 change) and `TEST_BRANCH` recreated as `aac8fa4` (P2, P3 empty). T1–T6 stay valid: `82d5e28` touches only the release flow and upmerge, which none of them run. B1 onward runs on `aac8fa4`. + +| Case | Run(s) | Evidence | Annotations | Versions touched in `cplace-npm-test` (state) | Verdict | Note | +|---|---|---|---|---|---|---| +| T1 | 47147767268 | `fe-install-deps.yml@3fd97e8`; `Cache not found` (cache `11520445198` deleted first), `npm ci` added 3302 packages; step env `JFROG_TOKEN: ***`, `DOT_NPMRC:` empty; `leak_check` and `auth_errors` empty | none | none (snapshot: 0 projects) | pass | the S2 push; all 6 jobs `success` | +| T2 | 47151775840 (licenses), 47151775730 (PR CI) | `fe-licenses.yml@3fd97e8`: `Cache not found` (new lock hash), `npm ci` added 3302 packages, `Check Licenses Local` and `Run Diff` `success`; step env `JFROG_TOKEN: ***`, `DOT_NPMRC:` empty. PR CI `install-deps` the same (token, cache miss, 3302 packages). `leak_check` and `auth_errors` empty in both | none | none | pass | PR #6 from `test/34294-pr-token` (trailing newline in `package-lock.json`); `xray-scan` ignored | +| T3 | 47159921084 | `fe-sonar.yml@3fd97e8`; the run started although the clone has no `SONAR_CLOUD_TOKEN`; `Cache not found` (cache `11523718356` deleted first), cache-gated `Use .npmrc` and `Install dependencies` `success`, `npm ci` added 3302 packages; step env `JFROG_TOKEN: ***`, `DOT_NPMRC:` empty; `leak_check` and `auth_errors` empty | only the two cancel annotations | none | pass | cancelled by hand after `Run Formatter Check`, during `Run Linter` (scan out of scope, §4 T3) | +| T4 | 47162290941 | `fe-pr-snapshot.yml@3fd97e8`; `Cache not found` (cache `11524905214` deleted first), `npm ci` added 3302 packages via `~/.npmrc` (step env `JFROG_TOKEN: ***`, `DOT_NPMRC:` empty); then in the same job 27× dist `.npmrc` with `_authToken=${JFROG_TOKEN}` + `Publishing as JFrog user`, `"authMode":"TOKEN"`, 27 `+ @cplace-next/` lines = 27 tarballs (AQL); `leak_check` and `auth_errors` empty | none | `0.0.0-test-34294-pr-token-6` ×27 (to be deleted by T5) | pass | label `snapshot` on PR #6 | +| T5 | 47190908837 | `fe-pr-close.yml@3fd97e8`; install part as specified: `Cache not found` (cache `11528358084` deleted first), `npm ci` added 3302 packages, step env `JFROG_TOKEN: ***`, `DOT_NPMRC:` empty; 27× token dist `.npmrc`, `"authMode":"TOKEN"`, 27× `Deleted artifact from Jfrog`; `leak_check` and `auth_errors` empty. **But AQL still holds 2 of the 27** (`cf-devkit`, `create-cplace-workspace`), unchanged after 4 min, still listed in their npm metadata with `latest-pr-snapshot` → that version | none | `0.0.0-test-34294-pr-token-6`: 25 deleted, 2 left (`cf-devkit`, `create-cplace-workspace`; delete at teardown) | pass | deviation D3, accepted by the user. Run `success`; branch `test/34294-pr-token` deleted | +| T6 | 47194736740 | `fe-cleanup-snapshots.yml@3fd97e8`; step env `JFROG_TOKEN: ***`, `DOT_NPMRC:` empty; the `CleanupSnapshots` search ran through the generated `~/.npmrc` **without E404** (D2 gone): 21 packages searched, 2008 snapshot candidates ≥ 4 months old (from the `cplace-npm` virtual), each checked with `npm show` against `cplace-npm-test` with the token dist `.npmrc` (21 printouts) → 2008× `does not exist in the registry. Skipping deletion`; no `npm unpublish`; `leak_check` and `auth_errors` empty | none | none (AQL 531 before and after) | pass | the cleanup step took 23 min (2008 lookups); see the After-the-Last-Push note in plan.md | +| B1a | 47311498541 | push of an empty commit on `BR` after the caller edit (`f251621`); all reusables `@aac8fa4`; nested `install-deps`: `Cache not found`, `npm ci` added 3302 packages, step env `JFROG_TOKEN: ***`, `DOT_NPMRC: ***`; `release` job: the same env, cache hit; NO-RELEASE (`No projects are affected since version/26.4.13`); `leak_check` and `auth_errors` empty | one `notice` `DOT_NPMRC is passed but ignored …` on `install-deps` and on `release` | none | pass | first attempt 47297643979 failed at startup (rebase note above); observation O1 | +| B1 | 47314723410 | forced dispatch on `BR`; install as in B1a (notice on `install-deps` and `release`); publish phase: 26× token dist `.npmrc`, 26 `+ @cplace-next/…@26.4.14` under `release-26.4-pending`; **promote failed**: first `npm dist-tag add @cplace-next/cf-e2e-testing-sdk@26.4.14 release-26.4 --registry=` → E401; `Unpublish the incomplete release` failed too (`npm show` E401) | notice ×2, failure ×2 | `26.4.14`: 23 tarballs left, `release-26.4-pending` → 26.4.14, `release-26.4` still 26.4.13, no tag | fail | D4; superseded by B1r. The 23 leftover `26.4.14` tarballs were deleted by exact path (user decision), AQL 0 | +| B1r | 47321844455 | forced dispatch on `BR` after the D4 fix (`TEST_BRANCH` `e8519c4`, `BR` cache `11567342837` deleted first); nested `install-deps`: `Cache not found`, 3302 packages, both secrets `***`; `release`: 27 published under `release-26.4-pending` (token dist `.npmrc`), `Restoring the dist .npmrc of cf-e2e-testing-sdk` and `… cf-frontend-sdk` (the two rebuilt libraries), 27× `+release-26.4`, tag `version/26.4.14` pushed, no tag-triggered run; `leak_check` and `auth_errors` empty | one `notice` on `install-deps` and on `release` | `26.4.14` ×27 (kept), `release-26.4` → 26.4.14, no `-pending` left | pass | D1: `github-release` skipped (pre-existing, `RUN_E2E: false`). `BR` caller then restored byte-identically to `d5b628a55` (commit `a3b93b0`) | +| B2 | 47327816634 | `push_main.yaml` `install-deps` with `JFROG_TOKEN` and `DOT_NPMRC` (clone `main` push); `fe-install-deps.yml@e8519c4`; `Cache not found` (no `main` cache left after T3's cancel), `npm ci` added 3302 packages; step env `JFROG_TOKEN: ***`, `DOT_NPMRC: ***`; `leak_check` and `auth_errors` empty; all 6 jobs `success` | exactly one `notice` `DOT_NPMRC is passed but ignored …` on `install-deps`, no `warning` | none (snapshot: 0 projects) | pass | | +| L1 | 47333497217 | `push_main.yaml` `install-deps` with `DOT_NPMRC` only; `fe-install-deps.yml@e8519c4`; `Cache not found` (cache `11571970962` deleted first), `npm ci` added 3302 packages through the verbatim `DOT_NPMRC`; step env `JFROG_TOKEN:` empty, `DOT_NPMRC: ***`; `leak_check` and `auth_errors` empty; all 6 jobs `success` | exactly one `warning` `DOT_NPMRC is deprecated. Pass JFROG_TOKEN instead, …` on `install-deps` | none (snapshot: 0 projects) | pass | | +| L2 | 47337060364 (snapshot), 47340732989 (close) | PR #7 from `test/34294-pr-legacy` (lockfile newline; `pull_request_snapshot.yaml` with `DOT_NPMRC` and `JFROG_BASE64_TOKEN`, no `JFROG_TOKEN`); `fe-pr-snapshot.yml@e8519c4`: `Cache not found`, `npm ci` added 3302 packages through `DOT_NPMRC` (step env `JFROG_TOKEN:` empty, `DOT_NPMRC: ***`), then in the same job `"authMode":"LEGACY"` and 27 published (printout masked by `DOT_NPMRC`, as in LT93 L2); `leak_check` and `auth_errors` empty. Close (token caller on `MB`): 27× token dist `.npmrc`, 27× `Deleted artifact` | snapshot: one `warning` `DOT_NPMRC is deprecated …` and one `warning` `JFROG_BASE64_TOKEN is deprecated …`; close: none | `0.0.0-test-34294-pr-legacy-7`: 25 deleted, 2 left (`cf-devkit`, `create-cplace-workspace`, D3; delete at teardown) | pass | branch deleted | +| N1 | 47341298154 | `push_main.yaml` `install-deps` without a `secrets:` block; the run **started** (no `Secret … is required` startup failure); `install-deps` `failure` at `Use .npmrc`, `Install modules` skipped (no `npm ci` line in any log), `build` and `snapshot` skipped; `leak_check` empty | one `failure` `No npm credentials: pass the JFROG_TOKEN secret …` (plus the generic exit-code annotation) | none | pass | caller restored to `JFROG_TOKEN` only afterwards | + +**Summary:** 12 pass (T1–T6, B1a, B1r, B2, L1, L2, N1), 1 superseded fail (B1, D4, fixed and proven by B1r). T5 and L2 with the accepted test-environment deviation D3. D2 is gone (T6). Every reusable that runs `use-npmrc` ran in token mode with a cache miss, the four input cases behaved as specified, and no log contains the token or the generated `~/.npmrc`. + +Additional observations (all `success`): `BR` caller restore 47326223536 (on `@test/PFM-ISSUE-33676-bot-identity`, NO-RELEASE), `MB` caller restore to token only after N1 47341628063. + +Observations: +- **O1: the notice's advice does not fit `secrets: inherit` callers** (B1a). Its text says "Remove the DOT_NPMRC line from this caller", but an inherit caller has no such line; the notice will appear on every release-flow run in each FE repo until the repository secret `DOT_NPMRC` is deleted (cleanup ticket). Raised with the user at the Phase 5 checkpoint. + +Deviations: +- **D4 (fixed, 34294 regression): promote and failure cleanup lose their credentials once nx rebuilds a published library** (B1; `$OUT/B1/run-47314723410`). After `cf-e2e-testing-sdk` is published, nx restores it from its local cache as a dependency of `cf-frontend-sdk` (`cf-e2e-testing-sdk:build [local cache]`), which rewrites `dist/libs/cf-e2e-testing-sdk/` without the dist `.npmrc` the tool wrote. `promote()` and the cleanup's `packageExists()` run in that directory with `--registry=`, so npm has only `~/.npmrc`. Before 34294 that was `DOT_NPMRC`, which also held credentials for the publish registry and silently covered the gap (34293's T4 promote passed); the generated file authenticates only the `cplace-npm` virtual (design Decision 3), so the request is anonymous → E401. In production every release whose published libraries are rebuilt as dependencies would fail the same way at merge. + **Fix** (user's choice, commit "PFM-ISSUE-34294 - Restore the dist .npmrc before promote and delete when a rebuild removed it"): `NxProject.restoreNpmrcInDist()` rewrites the missing dist `.npmrc` before `promote()`, and `deleteArtifact()` writes it whenever it is missing. Proven by B1r. +- **D3, test environment, accepted by the user on 2026-12-03: the PR-close unpublish leaves `cf-devkit` and `create-cplace-workspace`** (T5; + `$OUT/T5/run-47190908837`). Both are libraries with their own `package.json` that take the dist-missing path + of `NxProject.deleteArtifact`. `setVersionOrGeneratePackageJsonInDist` throws ENOENT reading the not yet + existing dist `package.json`, catches it, and writes the **source** manifest (version `0.0.1`, no + `publishConfig`) to dist. `npm unpublish @cplace-next/

@0.0.0-test-34294-pr-token-6 --force` then prints + `- @cplace-next/

@…` (success) and a warning about the source `package.json` (`cf-devkit@0.0.1 No bin file + found`), but the version stays in `cplace-npm-test`. The other 25 projects (apps without their own + `package.json`) are deleted. The 34293 close runs (45576981303, 45597704246) processed 16 projects that did not + include these two, so history cannot say whether this predates 34294. The only 34294 influence on that step is + `~/.npmrc` (now `registry=` the `cplace-npm` virtual with the token). + User's explanation: without `publishConfig` the unpublish goes to the default registry, the `cplace-npm` + virtual (production), where these test versions never existed, so nothing is deleted there. In production + `JFROG_URL` is the virtual's own deployment target, so the clone's split between `cplace-npm-test` and the + default registry does not exist there. Read-only check: the production packuments of both packages + (`/api/npm/cplace-npm/@cplace-next%2F

`) were last modified at 15:00–15:02Z, before T5 (20:08Z), and contain no + `34294` version. The two leftovers in `cplace-npm-test` go to teardown (exact-path delete, stop). + +--- + +## 8. Teardown + +**Deferred until `FB` is merged** (plan "After the Last Push"). Stop before each step (LT 4.3). Tags, releases and +release tarballs created here stay unless the user decides otherwise; PR-snapshot versions are deleted inside +T5 and L2. + +1. **Callers on `MB`.** After the merge, point every caller from §2.4 S2 back to `@master` with `JFROG_TOKEN` and + no `DOT_NPMRC`. Before the merge this is not possible, because `@master` still requires `DOT_NPMRC`. + `push_main.yaml`'s `fe-build`/`fe-snapshot` refs belong to the 34282/34293 teardowns. +2. **Caller on `BR`.** Restored after B1r (commit `a3b93b0`, byte-identical to `d5b628a55`, `@test/PFM-ISSUE-33676-bot-identity`). Done. +3. **Test branch.** Delete `TEST_BRANCH` in `github-actions` only once no clone caller references it (a + contents grep for `@test/PFM-ISSUE-34294` on `MB` and `BR` is empty). Pushing the deletion is a stop. +4. **Secrets.** Unchanged: the clone keeps `JFROG_TOKEN` and `DOT_NPMRC`. +5. **Throwaway branches.** `test/34294-pr-*` are deleted inside their cases; verify none is left. +6. **D3 leftovers.** Delete by exact path (stop): `@cplace-next/cf-devkit` and `@cplace-next/create-cplace-workspace` at `0.0.0-test-34294-pr-token-6` and `0.0.0-test-34294-pr-legacy-7` (four tarballs; their `latest-pr-snapshot` tags point at them). `26.4.14` (B1r) stays, like the earlier test releases. diff --git a/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/plan.md b/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/plan.md new file mode 100644 index 0000000..9e34381 --- /dev/null +++ b/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/plan.md @@ -0,0 +1,653 @@ +--- +date: 2026-12-03 +ticket: PFM-ISSUE-34294 +related: PFM-ISSUE-33675 +topic: "Runtime-generated read .npmrc from JFROG_TOKEN; DOT_NPMRC made optional and deprecated" +status: approved +design: ./design.md +research: ./research.md +branch: improvement/PFM-ISSUE-34294-Use-the-new-secrets-and-remove-the-stored-DOT_NPMRC +--- + +# Runtime-generated `.npmrc` and `DOT_NPMRC` deprecation Implementation Plan + +## Overview + +`.github/actions/use-npmrc` is rewritten in place so that it generates `~/.npmrc` from the repo's existing +`JFROG_TOKEN`. It no longer writes the stored whole-file secret `DOT_NPMRC`. `DOT_NPMRC` stays as a deprecated +fallback, and every reusable declares both secrets as optional. The templates and the README switch to +`JFROG_TOKEN`. The change is proven on `clone-cplace-fe` before the merge. + +This plan delivers the design's **PR 1 only**. By user decision on 2026-12-03, the design's PR 2 (drop the +`DOT_NPMRC` declarations, the `dot-npmrc` input and the fallback, and make `jfrog-token` required) moves to the +cleanup ticket, together with deleting the repo secrets. This deviates from design Decision 5. See "After the +Last Push". + +## Current State Analysis + +- `.github/actions/use-npmrc/action.yml:3-6` has a single required input, `dot-npmrc`. `:15` writes it verbatim to + `~/.npmrc`, `:31` appends `replace-registry-host=never` (PFM-ISSUE-34453), and `:47` runs the advisory + `warn-foreign-registry.sh || true`. +- Two comments in it are wrong. `:20` claims "the prefix is the JFROG_URL secret". It is actually the `registry=` + line inside `DOT_NPMRC`. `:44` claims "all seven workflows", but there are eight. +- Eight reusables call `use-npmrc@master` with `dot-npmrc: ${{ secrets.DOT_NPMRC }}` and declare `DOT_NPMRC` as + `required: true`: `fe-install-deps`, `fe-licenses`, `fe-sonar`, `fe-pr-snapshot`, `fe-pr-close`, + `fe-cleanup-snapshots`, `fe-release` and `fe-release-flow`. + - `fe-release-flow.yml:79` also passes `DOT_NPMRC` explicitly to its nested `install-deps` job. + - `fe-sonar.yml:57` runs `use-npmrc` only when the node_modules cache misses. +- `JFROG_TOKEN` (34293) is declared `required: false` only in the five publish/delete reusables, and there only + as step `env:` for the `artifacts`/`snapshots` composites. `fe-install-deps`, `fe-licenses` and `fe-sonar` do + not declare it. +- Six templates pass `DOT_NPMRC`, and `fe-release.yml` (template) uses `secrets: inherit`. +- The read proxy URL is the committed constant `JFROG_NPM_PROXY` in `tools/scripts/lockfile/lib.sh:20`. Loading + `lib.sh` has no side effects, and `warn-foreign-registry.sh:41-45` already loads it the same way. +- `pr-checks.yml:58,61` runs shellcheck and bats only over `tools/scripts/lockfile/`. bats is installed locally + (Git Bash); shellcheck is not. + +## Desired End State + +- `use-npmrc` takes two optional inputs, `jfrog-token` and `dot-npmrc`, and delegates to + `.github/actions/use-npmrc/write-npmrc.sh`: + - **Token passed:** `~/.npmrc` is exactly the three lines below. When `DOT_NPMRC` is also passed, the action + emits a `::notice::` that it is ignored and can be removed from the caller. + ``` + registry=https://cplace.jfrog.io/artifactory/api/npm/cplace-npm/ + //cplace.jfrog.io/artifactory/api/npm/cplace-npm/:_authToken= + replace-registry-host=never + ``` + - **Only `DOT_NPMRC` passed:** the content is written verbatim plus `replace-registry-host=never`, with a + `::warning::` deprecation. + - **Neither:** the step fails with `::error::` before any `npm ci`. + - In every success case the file is mode `600`, and the token never appears in the step output. +- All eight reusables declare `JFROG_TOKEN` and `DOT_NPMRC` as `required: false` and pass both to `use-npmrc`. + `fe-release-flow`'s nested `install-deps` job gets both. +- The templates pass `JFROG_TOKEN` and no `DOT_NPMRC`. +- The README documents `JFROG_TOKEN` as the install credential and `DOT_NPMRC` as deprecated. The lockfile README + matches the new auth scope. +- `live-test-plan.md` exists with a filled report, and the user's pre-merge token check is recorded. + +Verify: +- `bats .github/actions/use-npmrc/ tools/scripts/lockfile/` passes. +- `git grep -n 'DOT_NPMRC' -- .github/workflow-templates` is empty. +- The live matrix report shows every case `pass`. + +### Key Discoveries: +- Composite inputs that aren't passed arrive as `''`. "Absent" therefore means empty, the same as 34293's + `JfrogCredentials.authMode` (`tools/scripts/artifacts/jfrog-credentials.ts:34-38`). +- The auth key is the proxy URL without its scheme: `${JFROG_NPM_PROXY#https:}`. This mirrors + `getJfrogUrlNoHttp()` (`jfrog-credentials.ts:54`). +- Bats pattern to follow: `tools/scripts/lockfile/warn-foreign-registry.bats`. It has a `setup()` with paths under + `BATS_TEST_TMPDIR`, uses `run`, and asserts on `status`/`output` with `[[ … == *'::warning'* ]]`. +- Live-test harness: `specs/2026-10-12_PFM-ISSUE-34283_consolidate-fe-release-workflow/clone-cplace-fe-live-tests.md` + (Parts 1, 2 and 4). The model document is `specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md`. +- `npm ci` runs only on a cache miss in every reusable. A live install case proves nothing unless the cache + misses. + +## What We're NOT Doing + +- **Design PR 2** (moved to the cleanup ticket by user decision): + - removing the `DOT_NPMRC` declarations, the `dot-npmrc` input and the fallback; + - making `jfrog-token` required. +- Deleting the `DOT_NPMRC` repo secrets (cleanup ticket). +- A new composite action next to `use-npmrc`. The user chose `use-npmrc` itself as the reusable action. +- Backporting to release lines 23.1–26.4. +- Migrating direct `DOT_NPMRC` consumers outside this repo (cplace-e2e, cplace-fe, project-planning-fe + `bryntum-update.yml`/`sonar-scan.yml`). +- A separate read token, and the org-level `ENV_CPLACE_ARTIFACTORY_*` pair. +- `~/.npmrc` generation in `fe-snapshot` and `fe-check-upmerge`. +- The `fe-tag` JFrog secrets, and `dist/`/`.gitignore` hygiene. +- Dedicated code for D2 (the cleanup-snapshots E404). The live matrix only observes it. +- Minting tokens or setting secrets. The user does that. + +## Implementation Approach + +Phase 1 is the walking skeleton: +- a sample bats test (pattern gate); +- `write-npmrc.sh` with all three paths; +- `use-npmrc` delegating to it; +- `fe-install-deps` wired to the token; +- one live token-only `npm ci` on `clone-cplace-fe` with a forced cache miss. + +That run settles the riskiest assumption early: the clone's `JFROG_TOKEN` authenticates against the `cplace-npm` +virtual through the generated file. + +Phase 2 completes the bats coverage and wires the other seven reusables. Phase 3 updates the templates and both +READMEs. Phases 4 and 5 write and run the live matrix and record the user's pre-merge token check. + +Live runs follow the 34293 model. They use a test branch, `test/PFM-ISSUE-34294-npmrc`: the feature branch plus +one commit that rewrites every `collaborationFactory/github-actions/...@master` ref in `.github/workflows` and +`.github/actions` to `@test/PFM-ISSUE-34294-npmrc`. That commit never lands on the feature branch. + +The input case is chosen by **editing the clone's caller**, that is, by which secret lines it passes. Every push to +github-actions, every secret change and every cache deletion on the clone is a stop for the user's consent. + +--- + +## Phase 1: Walking skeleton — generated `~/.npmrc` for `fe-install-deps`, proven live + +### Overview +Token → `use-npmrc` → `write-npmrc.sh` → `~/.npmrc` → `npm ci`, end to end for the install-deps path. The +pattern of the new bats file is reviewed before more tests are written. + +### Changes Required: + +#### 1. Sample test (pattern gate — stop for review before step 2) +**File**: `.github/actions/use-npmrc/write-npmrc.bats` (new) +**Changes**: Write only this test first. Then call `AskUserQuestion`: "Sample test for write-npmrc.bats written +(pattern: warn-foreign-registry.bats, HOME redirected to BATS_TEST_TMPDIR). Approve the pattern before the +remaining tests are written?" Write no further tests in this file until the user approves. + +```bash +#!/usr/bin/env bats +# +# Behavioural tests for write-npmrc.sh, the generator behind the use-npmrc +# composite. HOME is redirected so that the tests never touch the real ~/.npmrc. +# +# Run with: bats .github/actions/use-npmrc/ + +setup() { + WRITE="${BATS_TEST_DIRNAME}/write-npmrc.sh" + export HOME="${BATS_TEST_TMPDIR}" + NPMRC="${HOME}/.npmrc" + unset JFROG_TOKEN DOT_NPMRC +} + +@test "writes registry, auth token and mitigation when only JFROG_TOKEN is set" { + export JFROG_TOKEN='test-token' + + run "${WRITE}" + + [ "${status}" -eq 0 ] + [ "$(cat "${NPMRC}")" = "registry=https://cplace.jfrog.io/artifactory/api/npm/cplace-npm/ +//cplace.jfrog.io/artifactory/api/npm/cplace-npm/:_authToken=test-token +replace-registry-host=never" ] +} +``` + +#### 2. Generator script +**File**: `.github/actions/use-npmrc/write-npmrc.sh` (new, executable: `git update-index --chmod=+x`) +**Changes**: Takes `JFROG_TOKEN` and `DOT_NPMRC` from the environment, never as arguments, and writes +`${HOME}/.npmrc`. Shape: + +```bash +#!/usr/bin/env bash +# +# Writes ~/.npmrc for npm installs. Run by the use-npmrc composite. +# +# Inputs (environment only, never arguments, so that they never appear in a +# process listing): JFROG_TOKEN, DOT_NPMRC. An empty value counts as not set, +# because a composite receives an input that was not passed as ''. +# +# JFROG_TOKEN set -> generated file: the cplace-npm virtual as registry and the +# token as its _authToken. DOT_NPMRC, if also set, is +# ignored with a ::notice::. +# only DOT_NPMRC -> DEPRECATED: written verbatim, with a ::warning::. +# neither -> ::error::, exit 1, no file written. +# +# The token is written literally, never printed. See PFM-ISSUE-34294. + +set -euo pipefail + +LIB="$(dirname "${BASH_SOURCE[0]}")/../../../tools/scripts/lockfile/lib.sh" +readonly LIB +# shellcheck source=tools/scripts/lockfile/lib.sh +source "${LIB}" + +main() { + local npmrc="${HOME}/.npmrc" + local token="${JFROG_TOKEN:-}" dot_npmrc="${DOT_NPMRC:-}" + + umask 077 + if [[ -n "${token}" ]]; then + if [[ "${token}" =~ [[:space:]] ]]; then + echo '::error::JFROG_TOKEN contains whitespace; check the repository secret.' + return 1 + fi + printf 'registry=%s\n%s:_authToken=%s\n' \ + "${JFROG_NPM_PROXY}" "${JFROG_NPM_PROXY#https:}" "${token}" >"${npmrc}" + if [[ -n "${dot_npmrc}" ]]; then + echo '::notice::DOT_NPMRC is passed but ignored, because JFROG_TOKEN is set. Remove the DOT_NPMRC line from this caller.' + fi + elif [[ -n "${dot_npmrc}" ]]; then + printf '%s\n' "${dot_npmrc}" >"${npmrc}" + echo '::warning::DOT_NPMRC is deprecated. Pass JFROG_TOKEN instead, see "JFrog and npm secrets" in the github-actions README.' + else + echo '::error::No npm credentials: pass the JFROG_TOKEN secret (see "JFrog and npm secrets" in the github-actions README).' + return 1 + fi + + # PFM-ISSUE-34453 mitigation (comment moved from action.yml and corrected) ... + echo 'replace-registry-host=never' >>"${npmrc}" + chmod 600 "${npmrc}" +} + +main "$@" +``` + +The PFM-ISSUE-34453 comment moves from `action.yml:16-30` to this script. Its sentence "masked as *** because the +prefix is the JFROG_URL secret" is corrected: the dropped prefix belongs to the `registry=` URL, the `cplace-npm` +virtual. In the generated file that URL is committed, not secret. In the `DOT_NPMRC` fallback it is masked as +`***`, because it comes from the secret. The `chmod` covers a pre-existing file, which `umask` does not. + +#### 3. Composite +**File**: `.github/actions/use-npmrc/action.yml` +**Changes**: +- `description`: "Writes ~/.npmrc from JFROG_TOKEN (or the deprecated DOT_NPMRC) and warns about lockfile entries + outside the cplace npm proxy". +- The write step delegates to the script. +- The warn step stays unchanged, except that "all seven workflows" in its comment becomes "every workflow using + this action". + +```yaml +inputs: + jfrog-token: + description: 'JFrog token (the JFROG_TOKEN secret); authenticates installs against the cplace-npm virtual' + required: false + default: '' + dot-npmrc: + description: 'Deprecated: content of a complete .npmrc; used only when jfrog-token is empty' + required: false + default: '' +runs: + using: 'composite' + steps: + - name: Write ~/.npmrc + shell: bash + env: + JFROG_TOKEN: ${{ inputs.jfrog-token }} + DOT_NPMRC: ${{ inputs.dot-npmrc }} + run: bash "$GITHUB_ACTION_PATH/write-npmrc.sh" +``` + +#### 4. CI coverage of the new script +**File**: `.github/workflows/pr-checks.yml` +**Changes**: +- `shellcheck tools/scripts/lockfile/*.sh tools/scripts/lockfile/test-helper.bash .github/actions/use-npmrc/*.sh` +- `bats tools/scripts/lockfile/ .github/actions/use-npmrc/` +- The `scripts` job comment stays valid. + +#### 5. `fe-install-deps.yml` wiring +**File**: `.github/workflows/fe-install-deps.yml` + +```yaml + secrets: + JFROG_TOKEN: + required: false + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed + DOT_NPMRC: + required: false +... + - name: Use .npmrc + uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master + with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} + dot-npmrc: ${{ secrets.DOT_NPMRC }} +``` + +#### 6. Live smoke: token-only install on `clone-cplace-fe` +**Repos**: `collaborationFactory/github-actions` (test branch), `collaborationFactory/clone-cplace-fe` +**Changes**: +1. Create `test/PFM-ISSUE-34294-npmrc` from the feature branch, plus the ref-rewrite commit (harness 1.3 + step 5). Run harness preflight P2 and P3. **Stop for user confirmation before every push.** +2. Read-only: confirm that `JFROG_TOKEN` exists on the clone (`gh secret list -R collaborationFactory/clone-cplace-fe`). +3. On a clone branch, point the `fe-install-deps.yml` caller at `@test/PFM-ISSUE-34294-npmrc` and replace its + `DOT_NPMRC:` line with `JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}`. +4. Force a cache miss. **Stop for consent**, then delete the clone's `*-modules-*` caches + (`gh cache delete -R …`). Then push. +5. Capture the run with the harness `capture` helper. +6. If `npm ci` fails with E401/E403 on the virtual: **stop**. The clone's token lacks read on `cplace-npm`, which + is design Known Risk 1, and the user fixes the permission. + +### Success Criteria: + +#### Automated Verification: +- [x] The sample test was approved by the user before any other test in `write-npmrc.bats` was written +- [x] bats passes: `bats .github/actions/use-npmrc/ tools/scripts/lockfile/` +- [x] shellcheck passes: `shellcheck tools/scripts/lockfile/*.sh tools/scripts/lockfile/test-helper.bash .github/actions/use-npmrc/*.sh` (shellcheck installed locally, e.g. `scoop install shellcheck`). Ran shellcheck 0.11.0 (`pip install shellcheck-py`) on LF copies: the Windows working copy is CRLF (autocrlf), which shellcheck rejects with SC1017, and CI checks out LF. +- [x] The script is executable in git: `git ls-files -s .github/actions/use-npmrc/write-npmrc.sh` shows mode `100755` +- [x] `use-npmrc` has no required input: `grep -c 'required: true' .github/actions/use-npmrc/action.yml` is `0` +- [x] `fe-install-deps.yml` declares both secrets optional and passes both: `grep -A1 -E '^ (JFROG_TOKEN|DOT_NPMRC):$' .github/workflows/fe-install-deps.yml` shows `required: false` twice, and `grep -cE 'jfrog-token: \$\{\{ secrets.JFROG_TOKEN \}\}' .github/workflows/fe-install-deps.yml` is `1` +- [x] The feature branch contains no test-branch refs: `git grep -n '@test/' -- .github` is empty +- [x] No whitespace errors: `git diff --check master` is empty +- [x] Live smoke run on `clone-cplace-fe` concluded `success`: + - its install-deps log shows the `Write ~/.npmrc` step without an annotation and an `npm ci` that ran (cache miss); + - it contains no `E401`, `E403`, `E404` or `_authToken=` line. + - Evidence: run [47136400865](https://github.com/collaborationFactory/clone-cplace-fe/actions/runs/47136400865) + on clone `main` (caller edit "TEST PFM-ISSUE-34294 - install-deps on test/PFM-ISSUE-34294-npmrc with + JFROG_TOKEN only"), all 6 jobs `success`. The `main` modules cache was deleted first; the log shows + `Cache not found`, step env `JFROG_TOKEN: ***` / `DOT_NPMRC:` empty, and `npm ci` "added 3302 packages" in + 7 min. Zero `E401|E403|E404|_authToken=` lines. Snapshot: 0 affected projects, nothing published. + The clone's `push_main.yaml` install-deps caller stays on `@test/PFM-ISSUE-34294-npmrc` with `JFROG_TOKEN` + until teardown. +- [x] **HUMAN CHECKPOINT**: Call `AskUserQuestion` now with the question: "Phase 1 complete. Summary: write-npmrc.sh (token / DOT_NPMRC fallback / error), use-npmrc delegating to it, pr-checks covering it, fe-install-deps passing JFROG_TOKEN; token-only npm ci succeeded live on clone-cplace-fe (run ). Please review the changes and reply 'yes' to continue to Phase 2." Do NOT proceed until the user explicitly approves. This checkpoint cannot be skipped or pre-checked. + +#### Manual Verification: +- [x] In the smoke run's annotations there is no `::warning::` or `::notice::` from `use-npmrc`, only possibly the lockfile advisory (check-run annotations API for the install-deps job returned none, so no lockfile advisory either) + +--- + +## Phase 2: Full generator coverage and the remaining seven reusables + +### Overview +Every input case and edge case of the script is pinned by bats. Every other reusable passes `JFROG_TOKEN` and +declares `DOT_NPMRC` as optional. + +### Changes Required: + +#### 1. Remaining bats tests +**File**: `.github/actions/use-npmrc/write-npmrc.bats` +**Changes**: Add the following tests in the approved pattern: +- **Token only:** + - The output contains neither the token value nor an annotation. + - The file mode is `600` (`stat -c %a`). This test is skipped on MINGW/MSYS, where NTFS has no Unix modes. + - The `registry=` value equals `JFROG_NPM_PROXY` sourced from `lib.sh` in the test, so the single source of + truth is pinned. +- **Both set:** + - The file is the token file, and the `DOT_NPMRC` content is absent. + - The output contains `::notice::` and no `::warning::`. +- **Only `DOT_NPMRC`:** the file is the content verbatim followed by `replace-registry-host=never`, and the output + contains `::warning::` and `DOT_NPMRC is deprecated`. +- **Neither, or both empty strings:** the exit status is non-zero, the output contains `::error::` and + `No npm credentials`, and no file is written. +- **Token with whitespace or a newline:** the exit status is non-zero, the output contains `::error::`, no file is + written, and the token is not in the output. +- **Existing `~/.npmrc` with other content:** it is fully replaced, not appended to. + +#### 2. Reusable workflows +**Files**: `.github/workflows/fe-licenses.yml`, `fe-sonar.yml`, `fe-pr-snapshot.yml`, `fe-pr-close.yml`, +`fe-cleanup-snapshots.yml`, `fe-release.yml`, `fe-release-flow.yml` +**Changes**: +- **`fe-licenses`, `fe-sonar`:** add `JFROG_TOKEN: required: false`. + - In `fe-sonar`, add the description "JFrog token; authenticates npm installs against the cplace-npm virtual". + - Change `DOT_NPMRC` to `required: false` with the comment + `# deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed`. In `fe-sonar`, the + description text becomes that wording instead. +- **The five publish/delete reusables:** `JFROG_TOKEN` is already declared. Change `DOT_NPMRC` to + `required: false` with the same comment. +- **Every `use-npmrc` call:** add `jfrog-token: ${{ secrets.JFROG_TOKEN }}` above the existing `dot-npmrc:` line. +- **`fe-release-flow.yml:78-79`:** the nested `install-deps` job passes `JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}` + and `DOT_NPMRC: ${{ secrets.DOT_NPMRC }}`. + +### Success Criteria: + +#### Automated Verification: +- [x] bats passes: `bats .github/actions/use-npmrc/ tools/scripts/lockfile/` (Windows skips only the file-mode test). 85 tests, 0 failures, 1 skip locally; the mode test runs on Linux in the PR's `pr-checks` job. +- [x] Every `use-npmrc` call passes the token: `git grep -c 'use-npmrc@' -- .github/workflows` and `git grep -c 'jfrog-token: \${{ secrets.JFROG_TOKEN }}' -- .github/workflows` give the same count per file (8 files) +- [x] No reusable requires `DOT_NPMRC`: `git grep -n -A1 -E '^ DOT_NPMRC:$' -- .github/workflows | grep 'required: true'` is empty +- [x] Every reusable that declares `DOT_NPMRC` also declares `JFROG_TOKEN`: `for f in $(git grep -l -E '^ DOT_NPMRC:$' -- .github/workflows); do grep -qE '^ JFROG_TOKEN:$' "$f" || echo "MISSING $f"; done` prints nothing +- [x] The nested release-flow install gets the token: `sed -n '/^ install-deps:/,/^ build:/p' .github/workflows/fe-release-flow.yml | grep -c 'JFROG_TOKEN: \${{ secrets.JFROG_TOKEN }}'` is `1` +- [x] No whitespace errors: `git diff --check master` is empty +- [x] **HUMAN CHECKPOINT**: Call `AskUserQuestion` now with the question: "Phase 2 complete. Summary: full bats coverage of write-npmrc.sh (token, both + notice, DOT_NPMRC + warning, neither, whitespace token, overwrite, mode 600); fe-licenses, fe-sonar, fe-pr-snapshot, fe-pr-close, fe-cleanup-snapshots, fe-release, fe-release-flow pass JFROG_TOKEN with DOT_NPMRC optional. Please review the changes and reply 'yes' to continue to Phase 3." Do NOT proceed until the user explicitly approves. This checkpoint cannot be skipped or pre-checked. + +#### Manual Verification: +None. + +--- + +## Phase 3: Templates and documentation + +### Overview +New consumers start on `JFROG_TOKEN`, and the README tells existing consumers how to migrate. + +### Changes Required: + +#### 1. Templates +**Files**: `.github/workflow-templates/fe/` +**Changes**: +- `fe-main.yml`, `fe-pr.yml` (install-deps) and `fe-licenses.yml`: replace `DOT_NPMRC: ${{ secrets.DOT_NPMRC }}` + with `JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}`. +- `fe-pr-snapshot.yml`, `fe-pr-close.yml` and `fe-cleanup-snapshots.yml`: delete the `DOT_NPMRC:` line, because + `JFROG_TOKEN` is already passed. +- `fe-release.yml` (inherit): no change. + +#### 2. README +**File**: `README.md` +**Changes**: +- **`:12`:** "`.npmrc` provisioning uses the in-repo composite `.github/actions/use-npmrc` (input `jfrog-token`; + `dot-npmrc` is deprecated)…" +- **`:85`:** drop `DOT_NPMRC` from the inherit list. +- **`JFROG_TOKEN` row:** + - Content: the token needs **read on the `cplace-npm` virtual** in addition to the deploy/delete/annotate + rights on `cplace-npm-local`. For `cplace-project-planning-fe`, its user must be in `bryntum-readers`. + - Used for: add "installs: `use-npmrc` writes it literally as `_authToken` for the `cplace-npm` virtual into + `~/.npmrc` (`npm ci`, `npm view`/`npm search` in snapshot cleanup)". + - State the trade-off in one sentence: read-only workflows receive this publish-capable token too. +- **`DOT_NPMRC` row:** "**Deprecated.** A complete `.npmrc`. Used only when `JFROG_TOKEN` is not passed; the run + shows a deprecation warning, and a `::notice::` when both are passed." +- **New migration paragraph after the existing one:** + - in every caller of the reusables `@master`, replace `DOT_NPMRC:` with `JFROG_TOKEN:` in the `fe-install-deps`, + `fe-licenses` and `fe-sonar` callers, and delete it in the others; + - callers on `@release/26.4` and older stay unchanged, and the repository secret stays while a release branch + uses it; + - `secrets: inherit` callers switch without an edit; + - a run with neither secret fails with "No npm credentials"; + - install auth covers only the proxy: lockfile entries on other JFrog paths are fetched unauthenticated and + fail, so normalize them first (`tools/scripts/lockfile/README.md`). + +#### 3. Lockfile README +**File**: `tools/scripts/lockfile/README.md` +**Changes**: In "The interim mitigation in `use-npmrc`", replace "JFrog URLs stay authenticated by the secret" +with: "Entries on the proxy stay authenticated by the token in the generated `~/.npmrc`. JFrog entries outside the +proxy prefix get no credentials." The other mentions of `use-npmrc` stay valid. + +### Success Criteria: + +#### Automated Verification: +- [x] No template passes `DOT_NPMRC`: `git grep -n 'DOT_NPMRC' -- .github/workflow-templates` is empty +- [x] Every template that calls `fe-install-deps`, `fe-licenses`, `fe-pr-snapshot`, `fe-pr-close` or `fe-cleanup-snapshots` passes the token: `for f in $(git grep -l -E 'fe-(install-deps|licenses|pr-snapshot|pr-close|cleanup-snapshots)\.yml@' -- .github/workflow-templates); do grep -q 'JFROG_TOKEN: \${{ secrets.JFROG_TOKEN }}' "$f" || echo "MISSING $f"; done` prints nothing +- [x] README marks `DOT_NPMRC` deprecated and names the `cplace-npm` read right: `grep -c 'Deprecated' README.md` increased by 1 compared with `master`, and `grep -q 'cplace-npm` virtual' README.md` +- [x] No whitespace errors: `git diff --check master` is empty +- [x] **HUMAN CHECKPOINT**: Call `AskUserQuestion` now with the question: "Phase 3 complete. Summary: templates pass JFROG_TOKEN and no DOT_NPMRC; README documents JFROG_TOKEN as install credential (cplace-npm read right, trade-off), DOT_NPMRC deprecated, migration steps; lockfile README auth wording updated. Please review the changes and reply 'yes' to continue to Phase 4." Do NOT proceed until the user explicitly approves. This checkpoint cannot be skipped or pre-checked. + +#### Manual Verification: +- [x] The README secrets table renders correctly in the GitHub preview of the branch (confirmed by the user on 2026-12-04) + +--- + +## Phase 4: Write the live test plan + +### Overview +Write the executable live matrix as `live-test-plan.md` in this topic directory, structured like the 34293 one. +Environment, execution model, helpers, the JFrog rule and teardown are taken by reference from the 34283 harness +(Parts 1, 2 and 4) instead of being copied. + +### Changes Required: + +#### 1. `live-test-plan.md` +**File**: `specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/live-test-plan.md` (new) +**Changes**: The document must contain: +- **Expected change:** the three `~/.npmrc` shapes, the notice, warning and error annotations, and that + `npm view`/`npm search` in cleanup now authenticate through the generated file (D2). +- **Environment:** + - a read-only state check of `clone-cplace-fe`: its secrets (`JFROG_TOKEN`, `DOT_NPMRC`), its callers and their + refs, and whether it has an `fe-sonar` caller; + - the test branch `test/PFM-ISSUE-34294-npmrc`, recreated if stale (P3). +- **Scenario selection rules:** + - The input case is chosen by caller edits. + - Every install case needs a cache miss, forced by deleting the `*-modules-*` caches. That is a deletion, so it + is a consent stop. + - The release flow (`secrets: inherit`) receives both secrets, so it runs the "both" path. + - No secret on the clone is deleted. Any secret change is a consent stop. +- **Cases**, each with trigger, expected end state and evidence: + + | ID | Input | Flow | Proves | + |---|---|---|---| + | T1 | token | main CI `fe-install-deps` | generated file, `npm ci` against the virtual (re-run of the Phase 1 smoke on the final branch) | + | T2 | token | `fe-licenses` (PR touching `package.json`) | install + license check | + | T3 | token | `fe-sonar` (existing or temporary caller) | cache-gated `use-npmrc` path | + | T4 | token | `fe-pr-snapshot`, labelled PR | install via `~/.npmrc` and publish via dist `.npmrc` in one job | + | T5 | token | `fe-pr-close` on T4's PR | install + unpublish | + | T6 | token | `fe-cleanup-snapshots` (dispatch) | `npm view`/`npm search` without E404 (D2) | + | B1 | both | release flow push on `BR` (inherit) | token wins, `::notice::`, publish + promote + tag | + | B2 | both | main CI `fe-install-deps` with both lines | `::notice::`, token file | + | L1 | `DOT_NPMRC` only | main CI `fe-install-deps` | fallback still installs, `::warning::` | + | L2 | `DOT_NPMRC` only | `fe-pr-snapshot` | fallback in the mixed job | + | N1 | neither | main CI `fe-install-deps` | fails in `Write ~/.npmrc` with `::error::`, before `npm ci` | + +- **Evidence common to all cases (leak check):** + - the only `_authToken=` lines in any log are the dist `.npmrc` printouts with the literal `${JFROG_TOKEN}`; + - no log contains the generated `~/.npmrc` content; + - no `Failed to replace env in config`; + - every version touched is checked by exact path in `cplace-npm-test` (harness 4.2). +- **The user's pre-merge token check:** a table with one row per FE repo (14). For each repo, record whether its + `JFROG_TOKEN` reads `cplace-npm`, and for each identity group, an `npm ci` with the generated file. Flag + office-reports-fe, workflow-fe, resource-management-fe and project-planning-fe (Bryntum packages). +- **Pass criteria** mapped to the design's success criteria, a **report** section to be filled in Phase 5, and + **teardown** (deferred until after the merge, see "After the Last Push"). + +### Success Criteria: + +#### Automated Verification: +- [x] `live-test-plan.md` lists every case ID: `for id in T1 T2 T3 T4 T5 T6 B1 B2 L1 L2 N1; do grep -q "| $id " specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/live-test-plan.md || echo "MISSING $id"; done` prints nothing +- [x] No whitespace errors: `git diff --check master -- specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/` is empty +- [x] **HUMAN CHECKPOINT**: Call `AskUserQuestion` now with the question: "Phase 4 complete. Summary: live-test-plan.md written with cases T1–T6, B1–B2, L1–L2, N1 on clone-cplace-fe, cache-miss and consent rules, leak check, and the 14-repo pre-merge token-check table. Please review the live test plan and reply 'yes' to continue to Phase 5 (execution)." Do NOT proceed until the user explicitly approves. This checkpoint cannot be skipped or pre-checked. + +#### Manual Verification: +- [x] Every case can be triggered and evaluated from the document and the harness alone (confirmed by the user on 2026-12-04) +- [x] No case writes to `cplace-npm-local`, a real FE repo, or a real `release/*` branch outside the clone (confirmed by the user on 2026-12-04) + +--- + +## Phase 5: Run the live matrix and the pre-merge token check + +### Overview +Run `live-test-plan.md` against the final feature branch through a recreated test branch, and record the results. +Fix any defect on the feature branch, then repeat the affected cases. The user runs the token check across the 14 +repos, and the results are recorded in the same document. + +### Changes Required: + +#### 1. Execution +**Repos**: `collaborationFactory/clone-cplace-fe`, `collaborationFactory/github-actions` (test branch only) +**Changes**: Run the preflight, then the cases in the document's order. Every github-actions push, secret change +and cache or package deletion waits for user confirmation. Capture each run with the harness helpers into the +scratchpad. + +#### 2. Report +**File**: `specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/live-test-plan.md` (report section) +**Changes**: For each case, record: +- the run id and link; +- the verdict; +- the evidence lines; +- the annotations; +- the versions touched in `cplace-npm-test` and their cleanup state; +- any deviation. + +Also record the user's token-check table. + +#### 3. Fix for D4 (found by B1 on 2026-12-04, approach chosen by the user) +**Files**: `tools/scripts/artifacts/nx-project.ts`, `tools/scripts/artifacts/nx-project.test.ts` +**Changes**: nx restores a published library from its local cache when a later project depends on it, which +replaces its dist directory without the dist `.npmrc`. `promote()` and the failure cleanup then ran against +`JFROG_URL` with only `~/.npmrc`. `DOT_NPMRC` used to cover that by accident; the generated file does not (E401). +- New `restoreNpmrcInDist()`: rewrites the dist `.npmrc` from the content written at publish time, if it is missing. +- `promote()` calls it before `npm dist-tag add`. +- `deleteArtifact()` writes the dist `.npmrc` whenever it is missing and credentials are passed (not only when the + whole dist directory is missing), and otherwise restores it. +- Three jest tests: promote restores before moving the tag, promote leaves an existing file alone, and the cleanup + writes the token `.npmrc` before the lookup when the dist directory exists without it. +- Before B1 ran, the feature branch was rebased onto `master` `82d5e28` (PFM-ISSUE-33676), by user decision: + the branch predated it and still required `GIT_USER*`, which the clone no longer has. + +### Success Criteria: + +#### Automated Verification: +- [x] Every case in the report has a run id and a verdict: `grep -cE '^\| (T[1-6]|B[12]|L[12]|N1) .*\| (pass|fail|skipped) ' specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/live-test-plan.md` is at least `11` +- [x] All cases are recorded as `pass`, or a deviation was accepted by the user and is noted in the report (D3 accepted; B1's failure D4 was fixed and B1r passes) +- [x] bats still passes on the final branch: `bats .github/actions/use-npmrc/ tools/scripts/lockfile/` (85 tests, 0 failures, 1 skip: the mode test on Windows) +- [x] The D4 fix is covered: `npx jest tools/scripts/artifacts` passes the three new tests; its only failures are the 8 that also fail on the unchanged tree on Windows (`isE2eAppWithPublicApi` ×2, `getAllNxProjects … public_api.ts` in `utils` and `artifacts-handler-tag`, `NxProject can provide jfrog Url`, `e2e app is not publishable …`) +- [x] The feature branch contains no test-branch refs: `git grep -n '@test/' -- .github` is empty +- [x] **HUMAN CHECKPOINT**: Call `AskUserQuestion` now with the question: "Phase 5 complete. Summary: live matrix on clone-cplace-fe — pass / fail / skipped, D2 ; token check across 14 repos recorded. Please review the report and reply 'yes' to close the plan." Do NOT proceed until the user explicitly approves. This checkpoint cannot be skipped or pre-checked. + +#### Manual Verification: +- [x] Spot-check the B1 and L1 run summaries in the GitHub UI: the notice and the warning read as intended (confirmed by the user on 2026-12-04) +- [x] No leftover test versions remain in `cplace-npm-test` beyond those the report deliberately keeps (`26.4.14` ×27, and the four D3 leftovers listed for teardown) + +--- + +## Testing Strategy + +### Unit Tests: +`write-npmrc.bats` covers: +- the exact token file; +- token precedence over `DOT_NPMRC`, with the notice; +- the verbatim `DOT_NPMRC` fallback, with the warning; +- the error with neither or with empty strings; +- the rejection of a token containing whitespace; +- that the token is never in the output; +- that an existing file is overwritten; +- mode `600`; +- the registry equal to `JFROG_NPM_PROXY`. + +The existing `warn-foreign-registry.bats` stays unchanged and green. + +### Integration Tests: +The live matrix on `clone-cplace-fe` (Phases 1 and 5) covers: +- every reusable that runs `use-npmrc`; +- all four input cases; +- D2; +- the leak check. + +### Manual Testing Steps: +1. Phase 1 smoke: token-only `npm ci` on the clone with a forced cache miss. +2. Phase 5: the T, B, L and N cases from `live-test-plan.md`. +3. The user's token check across the 14 FE repos. + +## After the Last Push + +- **Pre-merge token check (moved here from Phase 5; the user's step, before the merge):** fill the 14-repo table in `live-test-plan.md` §5. Every repo needs a verdict, and none may read `fail` without a recorded fix; a `fail` blocks the merge. Recorded in `live-test-plan.md` §5. +- **Merge-time switch:** at the merge, the release flow and the mixed jobs in all 14 repos switch to the token, + because the token wins. Watch the next pushes on two or three repos' default and release branches for install + errors. Rollback is a master revert. Recorded in PFM-ISSUE-34294. +- **Reference repos (33675 AC4):** first `cplace-remote-filesystem-fe`, then `cplace-project-planning-fe` + (including the Bryntum packages). Each switches its `install-deps`/`licenses`/`sonar` callers to `JFROG_TOKEN` + and deletes the `DOT_NPMRC` lines, then runs CI green with no `::warning::`/`::notice::` from `use-npmrc`. + After that, the remaining 12 repos follow. Recorded in PFM-ISSUE-34294. +- **Clone teardown:** point the clone's callers back to `@master` with `JFROG_TOKEN`, and delete + `test/PFM-ISSUE-34294-npmrc`. Each step is a stop. Also delete the four D3 leftovers in `cplace-npm-test` + (`cf-devkit` and `create-cplace-workspace` at `0.0.0-test-34294-pr-token-6` and `…-pr-legacy-7`) by exact + path. Recorded in `live-test-plan.md`'s teardown. +- **First snapshot cleanup after the merge (from T6):** D2 is gone, so each repo's scheduled + `fe-cleanup-snapshots` now gets past the search and really deletes the snapshots older than 4 months that piled + up while D2 blocked it. On the clone the search alone found 2008 candidates and took 23 min. Watch the first + scheduled run in two or three repos for duration and for what it deletes. Recorded in PFM-ISSUE-34294. +- **Notice wording for `secrets: inherit` callers (O1, from B1a):** the `use-npmrc` notice says "Remove the + DOT_NPMRC line from this caller", but an inherit caller (every repo's release flow) has no such line. It shows on + every release run until the repository secret is deleted. Decide with the user whether to reword it before the + merge. Recorded in PFM-ISSUE-34294. +- **Cleanup ticket** (to be created; it now holds the design's PR 2): + - Entry check: a search of the 14 repos' default branches, and of any release branch calling reusables + `@master`, finds no `DOT_NPMRC` reference. + - Then remove the `DOT_NPMRC` declarations from all reusables, remove the `dot-npmrc` input, the fallback and + the notice from `use-npmrc`, and make `jfrog-token` required. + - Delete the repo secrets only once the last release line through 26.4 is out of support and the direct + consumers (cplace-e2e, cplace-fe, project-planning-fe) have migrated. + - Recorded in the cleanup ticket, linked from PFM-ISSUE-34294. +- **33675 AC1/AC3** are revised on the ticket by the user. If D2 persists, it stays on its own ticket. + +## Performance Considerations + +None. The change writes a three-line file once per job. + +## Migration Notes + +**Rollback:** revert the merge commit on `master`. + +- Repos that still pass `DOT_NPMRC` keep working on the revert. +- A repo that has already replaced `DOT_NPMRC:` with `JFROG_TOKEN:` in its `install-deps`/`licenses`/`sonar` + callers fails after a revert. `DOT_NPMRC` is required again there, and `JFROG_TOKEN` is undeclared. That repo + must revert its caller edit too. During the reference-repo window, only the two reference repos are at risk. + +Release branches are unaffected: they pin `use-npmrc@release/X.Y` or `bduff9/use-npmrc@v1.1`. + +## References + +- Research: [Research Document](./research.md) +- Design: [Design Document](./design.md) +- Tickets: [PFM-ISSUE-34294](https://base.cplace.io/pages/chduu2mpiug4855q91t5eerdh/PFM-ISSUE-34294-Use-the-new-secrets-and-remove-the-stored-DOT-NPMRC-secret), + [PFM-ISSUE-33675](https://base.cplace.io/pages/keq1ackt7c8iqg12ifgx9l6pa/PFM-ISSUE-33675-Standardize-JFrog-npm-read-and-publish-authentication-in-frontend-workflows) +- Similar implementation: `tools/scripts/artifacts/jfrog-credentials.ts:34-52` (precedence, warning, error), + `tools/scripts/lockfile/warn-foreign-registry.sh:41-45` (loading `lib.sh`) +- Test pattern: `tools/scripts/lockfile/warn-foreign-registry.bats` +- Live tests: [34293 live-test plan](../2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md), + [34283 harness](../2026-10-12_PFM-ISSUE-34283_consolidate-fe-release-workflow/clone-cplace-fe-live-tests.md)