keycloak-scim/start.js
Stan Silvert f2e26b0049
Cypress tests for masthead. (#304)
* Cypress tests for masthead.

* Update snapshot

* Update Keycloak version.

* Fix download address

* Update start.js

Co-authored-by: Erik Jan de Wit <erikjan.dewit@gmail.com>

* Follow redirect when downloading keycloak.

* Refactor HeaderPage into Masthead and ModalUtils

* Minor change to kick off build.

* logOutTest no longer needs a param

* goToAcctMgtTest no longer needs a param

* Update tests/cypress/support/pages/admin_console/Masthead.js

Co-authored-by: Aboullos <61687012+Aboullos@users.noreply.github.com>

* Update tests/cypress/support/pages/admin_console/Masthead.js

Co-authored-by: Aboullos <61687012+Aboullos@users.noreply.github.com>

* Fix userDropdown() method

* Minor refactor

Co-authored-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Co-authored-by: Aboullos <61687012+Aboullos@users.noreply.github.com>
2021-01-21 07:09:50 -05:00

63 lines
1.6 KiB
JavaScript
Executable file

#!/usr/bin/env node
const http = require("https");
const fs = require("fs");
const path = require("path");
const { spawn } = require("child_process");
const decompress = require("decompress");
const decompressTargz = require("decompress-targz");
const args = process.argv.slice(2);
const version = args[0] || "12.0.1";
const folder = "server";
const fileName = path.join(folder, `keycloak-${version}.tar.gz`);
const serverPath = path.join(folder, `keycloak-${version}`);
const extension = process.platform === "win32" ? ".bat" : ".sh";
if (!fs.existsSync(folder)) {
fs.mkdirSync(folder);
}
const decompressKeycloak = () =>
decompress(fileName, folder, {
plugins: [decompressTargz()],
})
.then(() => {
console.log("Files decompressed");
})
.catch((e) => console.error(e));
const run = () => {
const proc = spawn(path.join(serverPath, "bin", `standalone${extension}`), [
"-Djboss.socket.binding.port-offset=100",
]);
proc.stdout.on("data", (data) => {
console.log(data.toString());
});
};
const request = (url, file) => {
http.get(url, (response) => {
if (response.statusCode == 302) {
request(response.headers.location, file);
} else {
response.pipe(file);
response.on("end", () => {
console.log("Downloaded keycloak");
decompressKeycloak().then(() => run());
});
}
});
};
if (!fs.existsSync(fileName)) {
const file = fs.createWriteStream(fileName);
request(
`https://github.com/keycloak/keycloak/releases/download/${version}/keycloak-${version}.tar.gz`,
file
);
} else if (!fs.existsSync(serverPath)) {
decompressKeycloak().then(() => run());
} else {
run();
}