Skip to content

fix: vendor node-foreman and replace util._extend with Object.assign - #3838

Merged
heroku-johnny merged 10 commits into
mainfrom
W-23597951
Jul 29, 2026
Merged

fix: vendor node-foreman and replace util._extend with Object.assign#3838
heroku-johnny merged 10 commits into
mainfrom
W-23597951

Conversation

@heroku-johnny

Copy link
Copy Markdown
Contributor

Summary

Fixes W-23597951 and GitHub issue #3736.

This PR merges schneems/foreman-fork into main. It:

  • Vendors the node-foreman library into src/lib/local/foreman/ to give us full control over the dependency
  • Removes the node-foreman npm dependency from package.json / package-lock.json
  • Replaces util._extend with Object.assign in the vendored envs.cjs, eliminating the Node.js DEP0060 deprecation warning
  • Adds unit tests for the vendored envs module
  • Rewires src/lib/local/run-foreman.cjs to import from the vendored copy

Files changed

 CHANGELOG.md                                  |  13 ++
 cspell.json                                   |   3 +-
 eslint.config.js                              |   2 +-
 package-lock.json                             |  77 ------------
 package.json                                  |   2 +-
 src/lib/local/foreman/colors.cjs              |  45 +++++++
 src/lib/local/foreman/console.cjs             | 123 ++++++++++++++++++
 src/lib/local/foreman/envs.cjs                | 116 +++++++++++++++++
 src/lib/local/foreman/forward.cjs             |  29 +++++
 src/lib/local/foreman/proc.cjs                | 141 +++++++++++++++++++++
 src/lib/local/foreman/procfile.cjs            |  55 ++++++++
 src/lib/local/foreman/proxy.cjs               | 118 ++++++++++++++++++
 src/lib/local/foreman/requirements.cjs        |  49 ++++++++
 src/lib/local/run-foreman.cjs                 | 172 +++-----------------------
 test/unit/lib/local/foreman/envs.unit.test.ts | 130 +++++++++++++++++++
 tsconfig.json                                 |   2 +-
 16 files changed, 838 insertions(+), 239 deletions(-)

Test plan

  • Run npm test — unit tests for envs.cjs pass
  • Run heroku local against a Procfile project and confirm no DEP0060 warning appears in stderr
  • Confirm node-foreman is no longer listed as a dependency in node_modules

🤖 Generated with Claude Code

schneems and others added 8 commits July 9, 2026 16:28
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.
```
@heroku-johnny
heroku-johnny requested a review from a team as a code owner July 27, 2026 19:27

@tlowrimore-heroku tlowrimore-heroku 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.

LGTM

@heroku-johnny
heroku-johnny merged commit a0b3316 into main Jul 29, 2026
19 checks passed
@heroku-johnny
heroku-johnny deleted the W-23597951 branch July 29, 2026 17:08
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.

3 participants