Skip to content

Commit 171ebcf

Browse files
CopilotApollon77
andauthored
Add package.json validation to reject iobroker.js-controller as dependency (#696)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Apollon77 <11976694+Apollon77@users.noreply.github.com> Co-authored-by: Ingo Fischer <github@fischer-ka.de>
1 parent 7286dd6 commit 171ebcf

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
## **WORK IN PROGRESS**
88
* (@Apollon77/@copilot) Add validation for JSON files in admin/ and admin/i18n/ directories
99
* (@Apollon77/@copilot) Logs npm and installation errors to console for easier debugging
10+
* (@Apollon77/@copilot) Add validation to fail if iobroker.js-controller is listed as a package.json dependency
1011
* (@Apollon77/@copilot) Add support for TypeScript-only adapters that use .ts files as main entry point without transpilation
1112
* (@Apollon77/@copilot) Re-enabled validation checks for README.md and LICENSE files in packageFiles tests
1213

build/tests/packageFiles/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,19 @@ function validatePackageFiles(adapterDir) {
166166
}
167167
}
168168
});
169+
it('iobroker.js-controller is not listed as a dependency', () => {
170+
for (const depType of [
171+
'dependencies',
172+
'devDependencies',
173+
'optionalDependencies',
174+
'peerDependencies',
175+
]) {
176+
if ((0, typeguards_1.isObject)(packageContent[depType]) && 'iobroker.js-controller' in packageContent[depType]) {
177+
// eslint-disable-next-line @typescript-eslint/only-throw-error
178+
throw new chai_1.AssertionError(`iobroker.js-controller must not be listed in ${depType}, found "${packageContent[depType]['iobroker.js-controller']}"!`);
179+
}
180+
}
181+
});
169182
});
170183
describe(`Check contents of io-package.json`, () => {
171184
beforeEach(function () {

src/tests/packageFiles/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,22 @@ export function validatePackageFiles(adapterDir: string): void {
154154
}
155155
}
156156
});
157+
158+
it('iobroker.js-controller is not listed as a dependency', () => {
159+
for (const depType of [
160+
'dependencies',
161+
'devDependencies',
162+
'optionalDependencies',
163+
'peerDependencies',
164+
] as const) {
165+
if (isObject(packageContent[depType]) && 'iobroker.js-controller' in packageContent[depType]) {
166+
// eslint-disable-next-line @typescript-eslint/only-throw-error
167+
throw new AssertionError(
168+
`iobroker.js-controller must not be listed in ${depType}, found "${packageContent[depType]['iobroker.js-controller']}"!`,
169+
);
170+
}
171+
}
172+
});
157173
});
158174

159175
describe(`Check contents of io-package.json`, () => {

0 commit comments

Comments
 (0)