etherpad-lite/bin
John McLear b57b25a4d7
fix: setup-trusted-publishers.sh works with real npm trust CLI (#7491)
* fix: setup-trusted-publishers.sh works with real npm trust CLI

Two issues found when running the script for the first time after #7490:

1. `npm trust github --file` wants ONLY the workflow filename basename
   (e.g. `test-and-release.yml`), not the full
   `.github/workflows/test-and-release.yml` path. npm errors out with
   "GitHub Actions workflow must be just a file not a path" otherwise.
   Constants updated.

2. `npm trust github` requires 2FA on accounts that have it enabled,
   and there is no way to disable that requirement. Add a `--otp <code>`
   pass-through flag and forward it to every call so a maintainer can
   batch-process multiple packages within a single TOTP window.
   Documented the limitation in the script header.

Also reword the call site so the npm command line is built without
shell-string round-tripping (passing $CMD through `$( $CMD )` was
unrelated to this bug but was bad practice).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: setup-trusted-publishers.sh recognizes 409 as already-configured

When --skip-existing is set, treat HTTP 409 Conflict from
POST /-/package/<name>/trust as 'already configured' so re-runs of
the bulk script don't fail on packages that were configured in a
previous run.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: cover setup-trusted-publishers.sh, harden against set -e, document --otp

Addresses qodo review on #7491:

- Add backend regression test that shims `npm` on PATH and asserts
  `--file` is given the workflow basename (never a path), `--otp` is
  forwarded to every `npm trust github` call when supplied, and the
  loop survives a non-zero exit so `--skip-existing` can absorb 409
  Conflict responses from the registry.
- Wrap the `npm trust github` invocation in `set +e` / `set -e`. The
  `if configure_one` already shields the function from errexit in
  practice, but a future refactor moving the call site out of an `if`
  would silently reintroduce the bug — the explicit shim makes intent
  obvious and survives such refactors.
- Document `--otp` and the 2FA / TOTP-expiry workflow in
  doc/npm-trusted-publishing.md so maintainers don't follow the docs
  and hit EOTP.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 10:56:13 +01:00
..
deb-src cleanup after workspace refactoring (#6174) 2024-02-21 21:50:11 +01:00
nsis cleanup after workspace refactoring (#6174) 2024-02-21 21:50:11 +01:00
plugins feat: migrate npm publish to OIDC trusted publishing (#7401) (#7490) 2026-04-07 17:38:23 +01:00
buildDebian.sh cleanup after workspace refactoring (#6174) 2024-02-21 21:50:11 +01:00
buildForWindows.sh Feat/bundle js (#6511) 2024-07-18 08:51:30 +02:00
checkAllPads.ts Fixed bin scripts. 2024-08-08 21:23:10 +02:00
checkPad.ts Fixed checkPad script not returning 2024-07-12 08:34:53 +02:00
cleanRun.sh cleanup after workspace refactoring (#6174) 2024-02-21 21:50:11 +01:00
commonPlugins.ts Enforce 2-space indentation across codebase (#7426) 2026-04-01 19:48:45 +01:00
convertSettings.json.template cleanup after workspace refactoring (#6174) 2024-02-21 21:50:11 +01:00
createRelease.sh cleanup after workspace refactoring (#6174) 2024-02-21 21:50:11 +01:00
createUserSession.ts chore: migrated settings to esm6 (#7062) 2025-08-04 22:42:50 +02:00
debugRun.sh cleanup after workspace refactoring (#6174) 2024-02-21 21:50:11 +01:00
deleteAllGroupSessions.ts Fixed bin scripts. 2024-08-08 21:23:10 +02:00
deletePad.ts Fixed bin scripts. 2024-08-08 21:23:10 +02:00
extractPadData.ts Fixed bin scripts. 2024-08-08 21:23:10 +02:00
fastRun.sh chore: fixed fastRun.sh script (#7063) 2025-08-05 18:24:19 +02:00
functions.sh cleanup after workspace refactoring (#6174) 2024-02-21 21:50:11 +01:00
generateReleaseNotes.ts chore: fixed generatereleasenotes to respect filename 2025-11-05 22:14:58 +01:00
importSqlFile.ts chore: migrated settings to esm6 (#7062) 2025-08-04 22:42:50 +02:00
installDeps.sh cleanup after workspace refactoring (#6174) 2024-02-21 21:50:11 +01:00
installer.ps1 feat: add one-line installer script (#7466) (#7485) 2026-04-07 17:10:22 +01:00
installer.sh feat: add one-line installer script (#7466) (#7485) 2026-04-07 17:10:22 +01:00
installLocalPlugins.sh Fix installation of local plugins 2025-04-05 15:31:36 +02:00
installOnWindows.bat Feat/oauth2 (#6281): Added oauth to API paths 2024-03-26 17:11:24 +01:00
make_docs.ts Enforce 2-space indentation across codebase (#7426) 2026-04-01 19:48:45 +01:00
migrateDB.ts chore: adapted documentation for migrateDB.ts (#7088) 2025-08-24 20:50:16 +02:00
migrateDirtyDBtoRealDB.ts chore: migrated settings to esm6 (#7062) 2025-08-04 22:42:50 +02:00
package.json build(deps-dev): bump the dev-dependencies group with 4 updates (#7443) 2026-04-03 20:10:05 +01:00
plugins.ts plugins.ts - absence of case = "remove" (#7141) 2025-09-29 19:26:30 +02:00
push-after-release.sh cleanup after workspace refactoring (#6174) 2024-02-21 21:50:11 +01:00
rebuildPad.ts chore: migrated settings to esm6 (#7062) 2025-08-04 22:42:50 +02:00
release.ts chore: git tag without signature 2025-08-02 13:42:37 +02:00
repairPad.ts Fixed bin scripts. 2024-08-08 21:23:10 +02:00
run.sh Feat/bundle js (#6511) 2024-07-18 08:51:30 +02:00
safeRun.sh cleanup after workspace refactoring (#6174) 2024-02-21 21:50:11 +01:00
setup-trusted-publishers.sh fix: setup-trusted-publishers.sh works with real npm trust CLI (#7491) 2026-04-08 10:56:13 +01:00
tsconfig.json Removed deprecated js files. 2024-08-18 19:22:08 +02:00
updatePlugins.sh fix: use pnpm instead of npm in updatePlugins.sh (#7468) 2026-04-06 11:21:21 +01:00