Use keycloakify-dev-resources instead of .keycloakify

This commit is contained in:
Joseph Garrone
2024-09-16 13:36:50 +02:00
parent 07e4f99f80
commit b4e94d3c00
9 changed files with 16 additions and 64 deletions

View File

@ -1,59 +1,8 @@
import * as child_process from "child_process";
import { transformCodebase } from "../src/bin/tools/transformCodebase";
import { join as pathJoin, sep as pathSep } from "path";
import { assert } from "tsafe/assert";
run("yarn build");
run("npx build-storybook");
const storybookStaticDirPath = "storybook-static";
{
let hasPatched = false;
transformCodebase({
srcDirPath: storybookStaticDirPath,
destDirPath: storybookStaticDirPath,
transformSourceCode: ({ fileRelativePath, sourceCode }) => {
replace_dot_keycloakify: {
if (fileRelativePath.includes(pathSep)) {
break replace_dot_keycloakify;
}
if (!fileRelativePath.endsWith(".js")) {
break replace_dot_keycloakify;
}
const search = `DOT_KEYCLOAKIFY:".keycloakify"`;
if (!sourceCode.includes(search)) {
break replace_dot_keycloakify;
}
hasPatched = true;
return {
modifiedSourceCode: Buffer.from(
sourceCode
.toString("utf8")
.replace(search, `DOT_KEYCLOAKIFY:"dot_keycloakify"`),
"utf8"
)
};
}
return { modifiedSourceCode: sourceCode };
}
});
assert(hasPatched);
}
transformCodebase({
srcDirPath: pathJoin(storybookStaticDirPath, ".keycloakify"),
destDirPath: pathJoin(storybookStaticDirPath, "dot_keycloakify")
});
function run(command: string, options?: { env?: NodeJS.ProcessEnv }) {
console.log(`$ ${command}`);