Skip to content

chore(publish): add publishConfig {access:public, provenance:true}#193

Closed
John-David Dalton (jdalton) wants to merge 4 commits intomainfrom
chore/publishconfig-provenance
Closed

chore(publish): add publishConfig {access:public, provenance:true}#193
John-David Dalton (jdalton) wants to merge 4 commits intomainfrom
chore/publishconfig-provenance

Conversation

@jdalton
Copy link
Copy Markdown
Collaborator

Summary

  • Pin publishConfig: {access: "public", provenance: true} on the root package.json.
  • Provenance attestation becomes a property of the package, not a property of the workflow's --provenance CLI flag. Survives any future emergency-publish path that bypasses provenance.yml.
  • access: "public" also load-bears for first-publish of @scoped packages on a fresh npm registry session.

Test plan

  • Next workflow-driven publish includes provenance attestation
  • CI green

…delay

Adopt native APIs where the option surface lines up, with feature-detect
fallbacks where needed. Engines is >=22, so the builtins are present in
practice; detection guards against monkey-patching and minor-version gaps.

src/primordials.ts
- Add `ArrayFromAsync` (ES2024). Unbound, matching `ArrayFrom` — the
  spec algorithm uses `this` only for the species constructor and
  falls back to plain Array when undefined.

src/promises.ts
- Add `fromAsync<T>()` helper backed by the new `ArrayFromAsync`
  primordial, with a `for await` + push fallback for older runtimes.
- Refactor `withResolvers` to consume the existing
  `PromiseWithResolvers` primordial directly instead of re-detecting.

src/globs.ts
- Route `glob` / `globSync` through `node:fs.glob` / `node:fs.globSync`
  when the caller's options reduce to `cwd` + `ignore` (mapped to
  `exclude`); fall back to fast-glob for the wider option surface.
- `getGlobMatcher` fast-paths single non-negated patterns through
  `path.matchesGlob` (Node 22.5+/20.17+) and caches the result in the
  existing LRU. Trailing-slash normalization still applies.
- Async path uses the new `fromAsync` helper instead of an IIFE.
- `canUseNodeFsGlob` and `getMatchesGlob` exported as `@internal` for
  unit tests. Tri-state cache uses a `_probed` boolean (no `null`).

src/crypto.ts (new)
- `hash(algorithm, data, encoding)` helper that prefers Node's one-shot
  `crypto.hash` (~30% faster on small inputs) with a
  `createHash().update().digest()` fallback. `getNativeHash` exposed
  as `@internal`. Wired into `package.json` exports.

src/http-request.ts
- Replace 3 `await new Promise(r => setTimeout(r, ms))` sites with
  `await delay(ms)` from `node:timers/promises`. JSDoc example updated.

src/dlx/{cache,integrity,binary}.ts
- Route 4 one-shot `createHash(...).update(...).digest(...)` calls
  through the new `hash()` helper. `binary.ts` keeps `getCrypto()` for
  `timingSafeEqual`.

test/unit/{globs,dlx/package}.test.mts
- Mark two describes that mutate describe-scope variables as sequential.
  Pre-existing flakes exposed reliably by the faster `fs.glob` path
  (vitest default `sequence.concurrent: true` raced on shared `tmpRoot` /
  `process.env['SOCKET_DLX_DIR']`).

test/unit/{primordials,promises,crypto}.test.mts
- New tests covering `ArrayFromAsync`, `fromAsync` (native + fallback
  branches), `hash`, and `getNativeHash`.

Coverage on modified files: 98% statements, 100% functions, 89% branches.
Pure formatting output from `pnpm run fix --all`:
- .git-hooks/pre-commit.mts: " → ' on a literal string
- xport.schema.json: collapse single-element `required` arrays onto
  one line (Prettier default)
Provenance attestation becomes a property of the package, not a
property of the workflow's --provenance CLI flag. access:public
also load-bears for first-publish of @Scoped packages on a fresh
npm registry session.
@jdalton
Copy link
Copy Markdown
Collaborator Author

Switching to direct push to main per repo policy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant