[utils] Replace the `uuid` dependency with `crypto.randomUUID()`
- Dominant language
- TypeScript
- Stars
- 413
- Forks
- 308
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 253
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:
```ts
// 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.
Contributor guide
No contributing guide indexed for this repository
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.
Assessment
- Tech stack
- node.js, typescript
- Domain
- testing, tooling
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100