Repository navigation
chore: migrate UI Extensions Core to the todoist scope - #381
Conversation
doistbot
left a comment
There was a problem hiding this comment.
This PR reworks the release pipeline for the @todoist/ui-extensions-core scope: tag-triggered publishing is replaced by a main-only pack workflow plus a protected publisher that validates run provenance, main ancestry, artifact digests, and cross-registry state before any write, with strict npm/GitHub credential isolation and a documented lockfile pending the real @todoist/* config packages before merge.
Few things worth tightening:
- The tamper/path-traversal guards in
inspectanddownloadOriginal(tar/zip entry allowlists, required dist files, digest checks) aren't exported or covered by tests — consider extracting them into pure, testable functions with rejection cases. - The mirror-selection tests only cover failure paths; add a successful
githubcase asserting the GitHub npmrc auth line, token injection, and publish invocation while the npm-facing credentials stay isolated.
I also included a few optional follow-up notes in the details below.
Optional follow-up notes (6)
scripts/release-policy.mjs:43: The registry names
['npmjs', 'github']are hardcoded here whilescripts/release.mjsdefines the same set inregistries(andcore-deploy.ymlrepeats thedestinationchoices). If a mirror is added or renamed,preflightBothcan skip it or fail with a stale name. Keep one source of truth, e.g. exportregistriesfromrelease-policy.mjs, iterateObject.keys(registries)here, and import that map inrelease.mjs.scripts/release.mjs:246: The
sha512-${digest(tarball, 'sha512', 'base64')}construction duplicates the integrity formula already computed ininspect()(line 73). Extract a smallintegrityOf(bytes)helper next todigest()and use it in both places so the two paths can't drift apart.scripts/release.mjs:223:
pkg.repositoryis dereferenced without a guard. The GitHub Packages metadata endpoint can returnrepository: nullwhen the package is not linked to a repository, so this line fails with an opaqueTypeError: Cannot read properties of null (reading 'full_name')instead of the actionable fail-fast messages used elsewhere in this boundary. Assert the field exists first (e.g.,assert.ok(pkg.repository, 'GitHub package repository linkage missing; ask package administrator')) so operators get a clear recovery instruction.scripts/release.mjs:109: The workflow filename is duplicated:
workflowPathis already imported as.github/workflows/core-pack.yml, but this API call hardcodesactions/workflows/core-pack.yml. If the workflow file is renamed, the imported constant andmetadata.workflowupdate while this lookup silently breaks. Derive the API path fromworkflowPath(e.g.,workflowPath.replace('.github/', 'actions/')) or define a second constant so the filename lives in one place.scripts/release.mjs:263: In non-interactive (CI) mode this first
preflight()is redundant: no state changes between it and the recheck at line 296 (no login runs, only temp npmrc files are written), so both registries are fetched and both tarballs downloaded twice back-to-back for the same result. The pre-login preflight only adds value in interactive mode, where it fails fast before the user completes 2FA. Considerif (interactive) await preflight().scripts/release-policy.mjs:44: The npmjs and github inspections are independent; running them sequentially doubles the worst-case wall time (each has a 30s timeout, and each includes a tarball download).
Promise.allover the registry list with results assigned by key keeps the same deterministiccopiesshape, andpreflightBothstill guarantees both reads finish before any write.
| import test from 'node:test' | ||
|
|
||
| import { preflightBoth, validateSourceRun, validateTag } from './release-policy.mjs' | ||
| import { publish, readTarball } from './release.mjs' |
There was a problem hiding this comment.
The suite never exercises
inspect or downloadOriginal. Those functions enforce the tamper/path-traversal boundaries: tar entry allowlist and duplicate detection, required dist files, the GitHub artifact SHA-256 digest, and the exact zip entry set. They are also not exported, so a regression there cannot fail any test. Consider exporting them or extracting the validation into pure functions and testing rejection cases such as an unexpected tar/zip entry or a digest mismatch.
| } | ||
| } | ||
| try { | ||
| for (const selected of ['npmjs', 'github']) { |
There was a problem hiding this comment.
This loop only verifies that each selected mirror rejects a divergent opposite mirror. The successful
selected='github' path is never exercised, so the GitHub-specific npmrc _authToken=${GH_PACKAGES_TOKEN} line, the GH_PACKAGES_TOKEN env injection, and the GitHub publish invocation are unverified. Add a github success case that asserts GitHub auth/config is present while GH_TOKEN, NODE_AUTH_TOKEN, NPM_TOKEN, and npm_config_registry remain isolated.
doistbot
left a comment
There was a problem hiding this comment.
This PR reworks the release pipeline into a main-only pack workflow plus a protected retained-artifact publisher, with provenance, digest, and both-registry preflight checks, ahead of the @todoist/ui-extensions-core@6.0.1 publication (merge still gated on lockfile regeneration and real validation).
Few things worth tightening:
- The test suite never exercises
inspect/downloadOriginal, leaving the tar entry allowlist, duplicate-entry detection, required dist files, GitHub artifact digest, and zip entry set untested — export them and add rejection cases (unexpected/duplicate tar entries, digest mismatch, unexpected zip entries). - The GitHub publication path isn't covered: add a successful
selected='github'case asserting theGH_PACKAGES_TOKENnpmrc auth/env injection whileGH_TOKEN,NODE_AUTH_TOKEN,NPM_TOKEN, andnpm_config_registrystay isolated. - Add rejection fixtures for the CLI (e.g. an unexpected zip entry and an out-of-allowlist tar entry like
package/../evil) asserting non-zero exit before any write. pull_requesttriggering now exposes the secret-bearing Bootstrap step to fork PRs — skip that step for forks, drop the token if no longer needed, or move it to a trusted workflow per the Secrets Management standard.
I also included a few optional follow-up notes in the details below.
Optional follow-up notes (9)
scripts/release.mjs:226:
pkg.repositoryis dereferenced without a guard. The GitHub Packages metadata endpoint returnsrepository: nullwhen the package isn't linked to a repository, so this line fails with an opaqueTypeError: Cannot read properties of null (reading 'full_name')instead of the actionable message used elsewhere at this boundary. Assertpkg.repositoryexists first and tell the operator to ask the package administrator to restore linkage.scripts/release.mjs:112: The workflow filename is duplicated:
workflowPathis imported as.github/workflows/core-pack.yml, but this API call hardcodesactions/workflows/core-pack.yml. Renaming the workflow file would updateworkflowPathandmetadata.workflowwhile this lookup silently breaks. Derive the API path fromworkflowPath(e.g.,workflowPath.replace('.github/', 'actions/')) or add a shared constant.scripts/release.mjs:266: In non-interactive (CI) mode this first
preflight()is redundant: nothing changes between here and the recheck at line 299 (no login runs, only temp npmrc files are written), yet both registries are fetched and both tarballs downloaded twice. The pre-login check only fails fast before 2FA in interactive mode, so gate it withif (interactive).scripts/release-policy.mjs:43: The registry names are hardcoded here while
scripts/release.mjsdefines the same set inregistriesandcore-deploy.ymlrepeats thedestinationchoices. If a mirror is added or renamed,preflightBothcan skip it or fail on a stale name. Keep one source of truth: exportregistriesfromrelease-policy.mjs, iterateObject.keys(registries)here, and import that map inrelease.mjs.scripts/release.mjs:249: The integrity formula
sha512-${digest(..., 'sha512', 'base64')}is duplicated here and ininspect()at line 73. Extract a singleintegrityOf(bytes)helper next todigest()and use it in both paths (and the tests) so the two computations can't drift.scripts/release.mjs:217: This URL hardcodes the
todoistorg andui-extensions-coreslug, duplicatingrepositoryandpackageNamealready defined in this module. Derive them from those constants (e.g.repository.split('/')[0]and the slug frompackageName) or add dedicated constants, so a future org/package rename doesn't silently break this metadata lookup.scripts/release.mjs:123: The retained artifact name
ui-extensions-core-releaseis duplicated betweencore-pack.yml'supload-artifactname and this filter. Renaming the upload causes this filter to return zero entries and fail withRequire one original retained release artifact, without pointing at the rename. Hoist the name intorelease-policy.mjsso the JS side no longer repeats the literal.scripts/release-policy.mjs:43: The npmjs and github registry inspections run sequentially, so preflight worst-case wall time doubles (each fetch has a 30s timeout and, when a same-version copy exists, downloads the full tarball). The reads are independent and must both finish before any write, so run them concurrently with
Promise.allover the registry names and assign results by key to preserve the deterministiccopiesshape.scripts/release.test.mjs:225: The recorded npm publish invocation is checked only for
--ignore-scripts,--provenance=false, and the tag.--access=publicand--registry=https://registry.npmjs.org/are part of the public-release and isolated-routing contract, but neither is asserted; dropping public access or routing the npm publish to the wrong registry would pass. Assert the registry flag, public access, and the scope routing in the generated npmrc.
| import test from 'node:test' | ||
|
|
||
| import { preflightBoth, validateSourceRun, validateTag } from './release-policy.mjs' | ||
| import { publish, readTarball } from './release.mjs' |
There was a problem hiding this comment.
The suite imports only
publish and readTarball, so inspect and downloadOriginal are never exercised. Those functions enforce the tar entry allowlist/duplicate detection, required dist files, the GitHub artifact SHA-256 digest, and the exact zip entry set — a regression in any of them would pass CI. Export them (or extract the validation into pure functions) and add rejection cases such as an unexpected tar entry, a duplicate entry, a digest mismatch, and an unexpected zip entry.
| } | ||
| } | ||
| try { | ||
| for (const selected of ['npmjs', 'github']) { |
There was a problem hiding this comment.
This loop only verifies that each selected mirror rejects a divergent opposite mirror. The successful
selected='github' path is never exercised, so the //npm.pkg.github.com/:_authToken=${GH_PACKAGES_TOKEN} npmrc line, the GH_PACKAGES_TOKEN env injection, and the GitHub npm publish invocation are unverified. Add a github success case asserting that GitHub auth/config is present while GH_TOKEN, NODE_AUTH_TOKEN, NPM_TOKEN, and npm_config_registry stay isolated.
|
|
||
| // Run the actual download/verify CLI with a recording gh executable and real | ||
| // local tar/ZIP fixtures. There is no network, product build or publication. | ||
| test('CLI recovers the original successful artifact after a failed later attempt', () => { |
There was a problem hiding this comment.
This CLI test only exercises the happy download/verify path plus a wrong-attempt and artifact-digest rejection. The archive/tarball tamper guards in
inspect/downloadOriginal — unexpected zip entries, tar entry allowlist and duplicate entries, missing required dist files, expired or multiple artifacts, and source-manifest equality — still have no rejection test, so a regression in those release-security checks would pass. Add crafted fixtures that fail, at minimum, an unexpected zip entry and an out-of-allowlist tar entry (e.g. package/../evil), and assert the command exits non-zero before any write.
| - 'packages/ui-extensions-core/**' | ||
| - 'package.json' | ||
| - 'package-lock.json' | ||
| - 'scripts/**' |
There was a problem hiding this comment.
Adding
scripts/** and .github/workflows/** to the pull_request trigger expands the fork-PR surface of a job that still injects NODE_AUTH_TOKEN: ${{secrets.GH_PACKAGES_TOKEN}} in the Bootstrap step. Doist's Secrets Management standard says not to use secrets in workflows triggered by pull requests from forks (https://handbook.doist.com/doc/standard-secrets-management-). Skip the secret-bearing Bootstrap step for fork PRs (or move it to a trusted workflow), or drop the token if the public @todoist/* packages no longer require GitHub registry auth.
doistbot
left a comment
There was a problem hiding this comment.
This PR migrates UI Extensions Core to the todoist scope, replacing the tag-triggered publish with a single main-only dispatch workflow that packs once and publishes the same tarball to both npm and GitHub Packages, plus docs and tooling/config updates. Few things worth tightening:
- The deploy workflow publishes to npmjs and then GitHub Packages in one sequential job; if the GitHub publish fails after npm succeeds, re-running fails on npm's exact-version check, leaving the mirrors divergent. Splitting into separate jobs that consume the retained
core-packageartifact would let a single-mirror failure be retried safely. - The PR description (and README) reference scripts/release.mjs, scripts/release-policy.mjs, a core-pack.yml workflow, and their mocked publisher tests — none of which exist in the diff or tree; what ships has no digest/provenance validation, no both-registry preflight, and no consumer of the retained artifact for retries. Either restore that publisher or correct the description/README so operators know the artifact is download-only and retries are manual.
With those addressed plus the pending lockfile regeneration and validation steps noted in the description, this looks ready to land.
I also included a few optional follow-up notes in the details below.
Optional follow-up notes (2)
.github/workflows/core-deploy.yml:29: This
npm install --global npm@11.19.0runs beforenpm ci, but the removed workflow comment documented the opposite ordering as required: upgrading npm beforenpm ciwas the exact pattern that previously caused lockfile format mismatches breaking installation. If 11.19.0 is safe with this lockfile, drop the concern deliberately, but if the upgrade was only moved to enable--provenanceat publish time, install npm afternpm ci(e.g., right before the Pack step) to keep the documented-safe sequence.docs/consumer-compatibility.md:9: This new file (and the new README section and line 37 here) links to
github.com/Doist/ui-extensions/...using the old org name. Redirects work today, but since this PR is exactly the org/scope migration, new docs should point attodoist/ui-extensionsso they don't rot if redirects are ever dropped.
| name: core-package | ||
| path: ${{ runner.temp }}/core-release/*.tgz | ||
| if-no-files-found: error | ||
| - name: Publish to npm |
There was a problem hiding this comment.
Publishing to npmjs first in the same job makes partial failures unrecoverable. If the GitHub Packages publish at line 48 fails after npm succeeds, the two registries are left divergent, but re-running this workflow re-runs the entire job and fails here because npm refuses to republish the same version. The old workflow kept the npm and GitHub publishes as separate jobs, so only the failed mirror needed re-running. Split these back into separate jobs that download the retained
core-package artifact (or otherwise make each registry write idempotent/preflighted) so a single-mirror failure can be retried without repacking or hitting the already-published registry.
| jobs: | ||
| # Publish to GitHub package registry | ||
| publish-github: | ||
| publish: |
There was a problem hiding this comment.
The PR description and the prior review rounds reference scripts/release.mjs, scripts/release-policy.mjs, .github/workflows/core-pack.yml, and their mocked tests (inspect/downloadOriginal guards, both-registry preflight, artifact recovery) — none of those files exist in this diff or in the working tree. What actually ships is a single workflow that packs and publishes directly, with no digest/provenance validation, no both-registry preflight, and no consumer of the uploaded
core-package artifact for the retry path the README describes ("Keep the original tarball if either registry needs a retry"). Either restore the described publisher and its tests or correct the PR description and README so operators know the retained artifact is currently download-only and retries are manual.
[Posted by Jarvis]
Migrates the active package to
@todoist/ui-extensions-core@6.0.1, updates repository/tooling references, and regenerates the real lockfile against the published@todoisttooling packages. The private root, runtime code, card schemas and deployment identities remain unchanged.Removes the custom release scripts, their tests, the separate pack workflow and the migration release runbook. The remaining manual
core-deploy.ymlworkflow checks/builds core, packs once, and publishes the same tarball to npmjs and GitHub Packages with standard npm commands. The first npm release is interactive; subsequent npm releases use trusted publishing.Validation: fresh npm ci; full core integrity check (lint, type checking, all 44 tests, CommonJS/ESM builds); repository formatting; production dependency audit; actionlint; fresh read-only review. All pass locally. The legacy React package remains retired; its consumer API blockers are documented separately.