Skip to content

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

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

refactor(functions-utils): replace dependencies with native APIs#7148
43081j wants to merge 1 commit 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

📝 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.

Walkthrough

Replaces cpy, path-exists, tmp-promise, and sort-on usage in functions-utils. The add function now uses fs.access and fs.cp, filtering junk files during recursive copies. Test helpers use Node.js temporary-directory APIs, while tests use native existence and file-copy operations plus a local sorting helper.

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

Possibly related PRs

  • netlify/build#7107: Refactors related filesystem copy and cache logic to use fs.cp and junk-file filtering.

Suggested reviewers: serhalp

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: replacing functions-utils dependencies with native APIs.
Description check ✅ Passed The description covers the dependency replacements and checklist, but it is missing the required Fixes #issue reference and explicit motivation.
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

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: 7ee8dd4

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