From ba44de87d658c966fc21cec8fbabfb7144b40c8d Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Sun, 19 May 2024 05:29:20 +0200 Subject: [PATCH] Ease testing local build in the starter --- scripts/link-in-starter.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 scripts/link-in-starter.ts diff --git a/scripts/link-in-starter.ts b/scripts/link-in-starter.ts new file mode 100644 index 00000000..0d406eee --- /dev/null +++ b/scripts/link-in-starter.ts @@ -0,0 +1,24 @@ +import * as child_process from "child_process"; +import * as fs from "fs"; +import { join } from "path"; + +fs.rmSync("node_modules", { "recursive": true, "force": true }); +fs.rmSync("dist", { "recursive": true, "force": true }); +fs.rmSync(".yarn_home", { "recursive": true, "force": true }); + +run("yarn install"); +run("yarn build"); + +fs.rmSync(join("..", "keycloakify-starter", "node_modules"), { "recursive": true, "force": true }); + +run("yarn install", { "cwd": join("..", "keycloakify-starter") }); + +run(`npx ts-node --skipProject ${join("scripts", "link-in-app.ts")} keycloakify-starter`); + +run(`npx chokidar '${join("src", "**", "*")}' -c 'yarn build'`); + +function run(command: string, options?: { cwd: string }) { + console.log(`$ ${command}`); + + child_process.execSync(command, { "stdio": "inherit", ...options }); +}