Skip to content

feat(packageFiles): fail if a "prepare" npm script is defined - #732

Merged
GermanBluefox merged 1 commit into
ioBroker:masterfrom
mcm1957:feat/check-prepare-script
Sep 5, 2026
Merged

feat(packageFiles): fail if a "prepare" npm script is defined#732
GermanBluefox merged 1 commit into
ioBroker:masterfrom
mcm1957:feat/check-prepare-script

Conversation

@mcm1957

@mcm1957 mcm1957 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

What changed

Extends validatePackageFiles() (the tests.packageFiles check) with a new test that fails if a prepare script is defined in the scripts section of package.json.

Why

A prepare npm script runs automatically on every npm install of the adapter — including installations by end users. This can break installations (e.g. if it invokes build tooling or dev-only dependencies that aren't present in a production install), so adapters should not ship one.

Details

  • The check lives in the existing Check contents of package.json describe block and mirrors the style of the neighbouring dependency checks (guards with isObject, throws an AssertionError with the offending value included).
  • A missing scripts section passes fine.
  • Added a CHANGELOG.md entry under WORK IN PROGRESS.
  • Regenerated build/tests/packageFiles/index.js to match.

npm run check and npm run lint both pass.

🤖 Generated with Claude Code

A "prepare" script runs on every "npm install" of the adapter,
including for end users, and can break installations. Add a
packageFiles validation test that raises an error when the
"scripts" section of package.json defines "prepare".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mcm1957
mcm1957 force-pushed the feat/check-prepare-script branch from ca9b854 to 9d76a70 Compare September 4, 2026 19:22
@mcm1957

mcm1957 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@GermanBluefox
I suggest to let standard tests fail if a prepare script is present. I do not know any adapter which need to use a prepare script (prebuild, prepackage etc are allow although they are not used widely. Only prepare can have sideeffets at target system (instaling all devDependencies) and is not needed. Code can und should be built at least when creating th package.

Please review an merge if OK from your side

@GermanBluefox
GermanBluefox merged commit 15cd757 into ioBroker:master Sep 5, 2026
9 checks passed
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