Skip to content

Commit

Permalink
Uninstall adapter from package-lock.json only before re-installing ta…
Browse files Browse the repository at this point in the history
…rball (#613)

Co-authored-by: Michael Schröder <[email protected]>
  • Loading branch information
MiSchroe and Michael Schröder authored Jul 30, 2024
1 parent 58c0bc0 commit 2aaf00d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
15 changes: 14 additions & 1 deletion build/tests/integration/lib/adapterSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ class AdapterSetup {
const tarballPath = path.resolve(this.adapterDir, tarballName);
await (0, fs_extra_1.copy)(tarballPath, path.resolve(this.testDir, tarballName));
await (0, fs_extra_1.unlink)(tarballPath);
// Let npm remove the adapter in the package-lock.json file(s),
// so that the installation in the following step
// won't grab the cached files.
// See https://github.com/ioBroker/testing/issues/612
debug("Removing the adapter from package-lock.json");
await (0, executeCommand_1.executeCommand)("npm", [
"uninstall",
this.adapterFullName,
"--package-lock-only",
"--omit=dev",
], {
cwd: this.testDir,
});
// Complete the package.json, so npm can do it's magic
debug("Saving the adapter in package.json");
const packageJsonPath = path.join(this.testDir, "package.json");
Expand All @@ -93,7 +106,7 @@ class AdapterSetup {
await (0, fs_extra_1.remove)(this.testAdapterDir);
debug("Installing adapter");
// Defer to npm to install the controller (if it wasn't already)
await (0, executeCommand_1.executeCommand)("npm", ["i", "--production"], {
await (0, executeCommand_1.executeCommand)("npm", ["i", "--omit=dev"], {
cwd: this.testDir,
});
debug(" => done!");
Expand Down
2 changes: 1 addition & 1 deletion build/tests/integration/lib/controllerSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class ControllerSetup {
const wasJsControllerInstalled = await this.isJsControllerInstalled();
// Defer to npm to install the controller (if it wasn't already)
debug("(Re-)installing JS Controller...");
await (0, executeCommand_1.executeCommand)("npm", ["i", "--production"], {
await (0, executeCommand_1.executeCommand)("npm", ["i", "--omit=dev"], {
cwd: this.testDir,
});
// Prepare/clean the databases and config
Expand Down
5 changes: 3 additions & 2 deletions build/tests/packageFiles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,12 @@ function validatePackageFiles(adapterDir) {
iopackContent.common.noConfig === "true" ||
iopackContent.common.adminUI?.config === "none";
if (!hasNoConfigPage) {
it("The adapter uses Material UI or JSON Config for the admin UI", () => {
it("The adapter uses a supported admin UI", () => {
const hasSupportedUI = !!iopackContent.common.materialize ||
iopackContent.common.adminUI?.config === "html" ||
iopackContent.common.adminUI?.config === "json" ||
iopackContent.common.adminUI?.config === "materialize";
(0, chai_1.expect)(hasSupportedUI, "Unsupported Admin UI, must be materialize or json config!").to.be.true;
(0, chai_1.expect)(hasSupportedUI, "Unsupported Admin UI, must be html, materialize or JSON config!").to.be.true;
});
}
});
Expand Down
20 changes: 19 additions & 1 deletion src/tests/integration/lib/adapterSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@ export class AdapterSetup {
await copy(tarballPath, path.resolve(this.testDir, tarballName));
await unlink(tarballPath);

// Let npm remove the adapter in the package-lock.json file(s),
// so that the installation in the following step
// won't grab the cached files.
// See https://github.com/ioBroker/testing/issues/612
debug("Removing the adapter from package-lock.json");
await executeCommand(
"npm",
[
"uninstall",
this.adapterFullName,
"--package-lock-only",
"--omit=dev",
],
{
cwd: this.testDir,
},
);

// Complete the package.json, so npm can do it's magic
debug("Saving the adapter in package.json");
const packageJsonPath = path.join(this.testDir, "package.json");
Expand All @@ -101,7 +119,7 @@ export class AdapterSetup {

debug("Installing adapter");
// Defer to npm to install the controller (if it wasn't already)
await executeCommand("npm", ["i", "--production"], {
await executeCommand("npm", ["i", "--omit=dev"], {
cwd: this.testDir,
});

Expand Down
2 changes: 1 addition & 1 deletion src/tests/integration/lib/controllerSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class ControllerSetup {
const wasJsControllerInstalled = await this.isJsControllerInstalled();
// Defer to npm to install the controller (if it wasn't already)
debug("(Re-)installing JS Controller...");
await executeCommand("npm", ["i", "--production"], {
await executeCommand("npm", ["i", "--omit=dev"], {
cwd: this.testDir,
});
// Prepare/clean the databases and config
Expand Down

0 comments on commit 2aaf00d

Please sign in to comment.