[utils] Replace the `uuid` dependency with `crypto.randomUUID()`

Open Beginner friendly
#10,210 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript
Domain
testing, tooling

Research direction

Start with the single call site in packages/utils/src/fs.ts:244 and read the related fs.test.ts, especially its uuid module spy. Remove the production and development uuid dependencies from packages/utils and update the test to cover the generated temporary directory path without that spy. Run fs.test.ts and verify the dependency entries are gone from consumers' trees.

Written by the indexing model from the issue text.

Description

Carried over from https://github.com/MetaMask/utils/pull/289, which was open when @metamask/utils moved into core.

packages/utils declares uuid@^9.0.1 as a production dependency and @types/uuid@^9.0.8 as a dev dependency, for a single call site:

// packages/utils/src/fs.ts:244
const directoryPath = path.join(os.tmpdir(), projectName, uuidV4());

crypto.randomUUID() has been available since Node 14.17 and the package requires Node 22, so the dependency can go. That also drops @types/uuid and one entry from every consumer's tree.

fs.test.ts currently spies on the module (jest.spyOn(uuid, 'v4')), so the test needs reworking alongside it.

Dominant language
TypeScript
Stars
413
Forks
308
Avg merge
1d 4h
Merged PRs (30d)
253

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MetaMask/core

All issues in MetaMask/core

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.