Skip to content

fix: vendor node-foreman to resolve Node.js deprecation warning#3742

Open
schneems wants to merge 7 commits into
mainfrom
schneems/foreman-fork
Open

fix: vendor node-foreman to resolve Node.js deprecation warning#3742
schneems wants to merge 7 commits into
mainfrom
schneems/foreman-fork

Conversation

@schneems

@schneems schneems commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Remove warning from loading foreman by vendoring the library and fixing the offending code.

close #3736.

Type of Change

Breaking Changes (major semver update)

  • Add a ! after your change type to denote a change that breaks current behavior

Feature Additions (minor semver update)

  • feat: Introduces a new feature to the codebase

Patch Updates (patch semver update)

  • fix: Bug fix
  • deps: Dependency upgrade
  • revert: Revert a previous commit
  • chore: Change that does not affect production code
  • refactor: Refactoring existing code without changing behavior
  • test: Add/update/remove tests

Testing

Notes:

Steps:

  1. CI green

Screenshots (if applicable)

Related Issues

GitHub issue: #3736
GUS work item: GUS-W-15785346

@schneems schneems temporarily deployed to AcceptanceTests June 3, 2026 18:49 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 3, 2026 18:49 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 3, 2026 18:49 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 3, 2026 18:49 — with GitHub Actions Inactive
@schneems schneems changed the title fix: Vendor foreman fix: vendor node-foreman to resolve Node.js deprecation warning Jun 3, 2026
@schneems schneems force-pushed the schneems/foreman-fork branch from 860dccf to 112253f Compare June 3, 2026 18:59
@schneems schneems temporarily deployed to AcceptanceTests June 3, 2026 18:59 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 3, 2026 18:59 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 3, 2026 18:59 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 3, 2026 18:59 — with GitHub Actions Inactive
@schneems schneems force-pushed the schneems/foreman-fork branch 2 times, most recently from 0ba6dcb to 36121b8 Compare June 4, 2026 20:46
@schneems schneems temporarily deployed to AcceptanceTests June 4, 2026 20:46 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 4, 2026 20:46 — with GitHub Actions Inactive
@schneems schneems force-pushed the schneems/foreman-fork branch from 36121b8 to 7103ba5 Compare June 4, 2026 20:49
@schneems schneems temporarily deployed to AcceptanceTests June 4, 2026 20:49 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 4, 2026 20:49 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 4, 2026 21:40 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 4, 2026 21:40 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 4, 2026 21:40 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 4, 2026 21:40 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 5, 2026 13:43 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 5, 2026 13:43 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 5, 2026 13:43 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 5, 2026 13:43 — with GitHub Actions Inactive
@schneems schneems marked this pull request as ready for review June 5, 2026 13:53
@schneems schneems requested a review from a team as a code owner June 5, 2026 13:53
schneems added 7 commits June 5, 2026 08:54
Copy the 9 library files from node-foreman v3.0.1 (MIT license) into
src/lib/local/foreman/ with .cjs extensions and updated internal
require paths for the .cjs extension. No other changes to the
upstream source.

Refs #3736
Update run-foreman.cjs to import from ./foreman/*.cjs instead of
foreman/lib/*. Hardcode the foreman version (3.0.1) instead of reading
it from the package. Remove the foreman npm dependency from package.json
and update the tsconfig.json comment to reflect the vendored state.

Add eslint and cspell ignore patterns for the vendored foreman directory.

Refs #3736
The deprecated `util._extend` API in foreman's envs module triggers a
Node.js DEP0060 deprecation warning when running `heroku local`. Replace
it with `Object.assign` and remove the unused `util` require.

Fixes #3736
Cover keyValue parsing (basic, quoted, comments, equals in values),
flattenJSON behavior, and loadEnvs with single and comma-separated
env files. The multi-file merge test exercises the Object.assign
replacement for the former util._extend call.

Refs #3736
The exporter.cjs depends on mustache, causing an error in CI:

```

node:internal/modules/cjs/loader:1210
  throw err;
  ^

Error: Cannot find module 'mustache'
Require stack:
- /home/runner/work/cli/cli/dist/lib/local/foreman/exporters.cjs
- /home/runner/work/cli/cli/dist/lib/local/run-foreman.cjs
    at Module._resolveFilename (node:internal/modules/cjs/loader:1207:15)
    at Module._load (node:internal/modules/cjs/loader:1038:27)
    at Module.require (node:internal/modules/cjs/loader:1289:19)
    at require (node:internal/modules/helpers:182:18)
    at Object.<anonymous> (/home/runner/work/cli/cli/dist/lib/local/foreman/exporters.cjs:11:10)
    at Module._compile (node:internal/modules/cjs/loader:1521:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1623:10)
    at Module.load (node:internal/modules/cjs/loader:1266:32)
    at Module._load (node:internal/modules/cjs/loader:1091:12)
    at Module.require (node:internal/modules/cjs/loader:1289:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/runner/work/cli/cli/dist/lib/local/foreman/exporters.cjs',
    '/home/runner/work/cli/cli/dist/lib/local/run-foreman.cjs'
  ]
}
```

The `heroku local` command does not use `export` therefore it doesn't need this module, so we can remove it and the need to have mustache.
These directives were left over from the vendored node-foreman code but
the rules they suppress are never triggered, causing eslint to report
unused-directive errors and fail CI.

This was causing errors in CI

```
npx eslint src/lib/local/run-foreman.cjs 2>&1
/Users/rschneeman/Documents/projects/work/tmp/cli/src/lib/local/run-foreman.cjs
  17:1  error  Unused eslint-disable directive (no problems were reported from 'no-new')
  18:1  error  Unused eslint-disable directive (no problems were reported from 'radix')

✖ 2 problems (2 errors, 0 warnings)
  2 errors and 0 warnings potentially fixable with the `--fix` option.
```
@schneems schneems force-pushed the schneems/foreman-fork branch from 87a789a to 65be92e Compare June 5, 2026 13:54
@schneems schneems temporarily deployed to AcceptanceTests June 5, 2026 13:54 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 5, 2026 13:54 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 5, 2026 13:54 — with GitHub Actions Inactive
@schneems schneems temporarily deployed to AcceptanceTests June 5, 2026 13:54 — with GitHub Actions Inactive
@schneems schneems enabled auto-merge June 5, 2026 17:57
@schneems

schneems commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

While I cleaned up a little of the unused code, there's more that can be reduced/removed in the future. I went down that path but found that there are some codepaths that aren't exercised/tested via CI, and didn't feel comfortable continuing. Vendoring the library as-is and making minimal cleanup makes this easier to review.

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.

Warning from nodejs foreman dependency

1 participant