Skip to content

refactor(functions-utils): replace dependencies with native APIs - #7148

Open
43081j wants to merge 5 commits into
netlify:mainfrom
43081j:jg/the-purge-functions-utils
Open

refactor(functions-utils): replace dependencies with native APIs#7148
43081j wants to merge 5 commits into
netlify:mainfrom
43081j:jg/the-purge-functions-utils

Conversation

@43081j

@43081j 43081j commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

This replaces the following in functions-utils:

  • cpy with fs.cp, still filtering out junk
  • path-exists with fs.access and, in tests, existsSync
  • sort-on with a basic sort function
  • tmp-promise with fs.mkdtemp and randomUUID

For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures
    we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or
    something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures
    your code follows our style guide and passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

This replaces the following in `functions-utils`:

- `cpy` with `fs.cp`, still filtering out `junk`
- `path-exists` with `fs.access` and, in tests, `existsSync`
- `sort-on` with a basic sort function
- `tmp-promise` with `fs.mkdtemp` and `randomUUID`
@43081j
43081j requested a review from a team as a code owner July 30, 2026 17:53
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9f744222-2d7e-4819-8283-123443db643a

📥 Commits

Reviewing files that changed from the base of the PR and between 938d1f2 and 270ac6c.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • packages/functions-utils/package.json
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • netlify/blueprints (manual)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/functions-utils/package.json

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved function copying by excluding unwanted system files.
    • Added clearer errors when a source path cannot be found.
    • Improved handling when replacing existing destination files.
  • Maintenance

    • Updated temporary-directory handling for more reliable test execution.
    • Simplified file-copying and function-list ordering behavior.
    • Improved consistency when managing copied function files.

Walkthrough

Replaces cpy, path-exists, tmp-promise, and sort-on with Node.js APIs and local test logic. The add function now uses fs.access and fs.cp with junk-file filtering. Test helpers use native temporary-directory APIs. Tests use native filesystem assertions and copying.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: serhalp

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes replacing functions-utils dependencies with native APIs.
Description check ✅ Passed The description summarizes the dependency replacements and confirms tests and contribution checks, but it omits an issue reference and Summary heading.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

e18e dependency analysis

No dependency warnings found.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/functions-utils/src/main.ts`:
- Around line 14-28: Ensure the destination directory returned by getDist() is
created before the fs.cp call in the copy flow. Add the directory-creation step
after validating dist and before copying src, while preserving the existing
recursive copy, force, and filter options.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3191968d-7aa6-4408-87d8-06b91e101428

📥 Commits

Reviewing files that changed from the base of the PR and between af94ccf and 7ee8dd4.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • packages/functions-utils/package.json
  • packages/functions-utils/src/main.ts
  • packages/functions-utils/tests/helpers/main.ts
  • packages/functions-utils/tests/main.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • netlify/blueprints (manual)

Comment thread packages/functions-utils/src/main.ts
@pkg-pr-new

pkg-pr-new Bot commented Jul 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

@netlify/build

npm i https://pkg.pr.new/@netlify/build@7148

@netlify/build-info

npm i https://pkg.pr.new/@netlify/build-info@7148

@netlify/cache-utils

npm i https://pkg.pr.new/@netlify/cache-utils@7148

@netlify/config

npm i https://pkg.pr.new/@netlify/config@7148

@netlify/edge-bundler

npm i https://pkg.pr.new/@netlify/edge-bundler@7148

@netlify/functions-utils

npm i https://pkg.pr.new/@netlify/functions-utils@7148

@netlify/git-utils

npm i https://pkg.pr.new/@netlify/git-utils@7148

@netlify/headers-parser

npm i https://pkg.pr.new/@netlify/headers-parser@7148

@netlify/api

npm i https://pkg.pr.new/@netlify/api@7148

@netlify/nock-udp

npm i https://pkg.pr.new/@netlify/nock-udp@7148

@netlify/opentelemetry-sdk-setup

npm i https://pkg.pr.new/@netlify/opentelemetry-sdk-setup@7148

@netlify/opentelemetry-utils

npm i https://pkg.pr.new/@netlify/opentelemetry-utils@7148

@netlify/redirect-parser

npm i https://pkg.pr.new/@netlify/redirect-parser@7148

@netlify/run-utils

npm i https://pkg.pr.new/@netlify/run-utils@7148

@netlify/zip-it-and-ship-it

npm i https://pkg.pr.new/@netlify/zip-it-and-ship-it@7148

commit: 270ac6c

serhalp
serhalp previously approved these changes Aug 2, 2026

@serhalp serhalp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 woo!

@serhalp serhalp self-assigned this Aug 2, 2026
@43081j

43081j commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

fixed the lint errors 👍

the e18e bot seems confused but may be because we're not caught up with main 🤔

@serhalp

serhalp commented Aug 4, 2026

Copy link
Copy Markdown
Member

@43081j if you resolve these conflicts we can get this one merged in

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.

2 participants