keycloak_theme/scripts/link-in-starter.ts

50 lines
1.2 KiB
TypeScript
Raw Normal View History

import * as fs from "fs";
import { join } from "path";
2024-09-08 12:00:07 +02:00
import { startRebuildOnSrcChange } from "./shared/startRebuildOnSrcChange";
2024-08-14 07:10:48 +02:00
import { crawl } from "../src/bin/tools/crawl";
import { run } from "./shared/run";
2024-08-14 07:10:48 +02:00
{
const dirPath = "node_modules";
try {
fs.rmSync(dirPath, { recursive: true, force: true });
} catch {
// NOTE: This is a workaround for windows
// we can't remove locked executables.
crawl({
dirPath,
returnedPathsType: "absolute"
}).forEach(filePath => {
try {
fs.rmSync(filePath, { force: true });
} catch (error) {
if (filePath.endsWith(".exe")) {
return;
}
throw error;
}
});
}
}
2024-05-20 15:48:51 +02:00
fs.rmSync("dist", { recursive: true, force: true });
fs.rmSync(".yarn_home", { recursive: true, force: true });
run("yarn install");
run("yarn build");
2024-06-25 22:50:51 +02:00
const starterName = "keycloakify-starter";
fs.rmSync(join("..", starterName, "node_modules"), {
2024-05-20 15:48:51 +02:00
recursive: true,
force: true
});
run("yarn install", { cwd: join("..", starterName) });
run(`npx tsx ${join("scripts", "link-in-app.ts")} ${starterName}`);
startRebuildOnSrcChange();