GitHub pages does not serve dotfile, patch storybook build #645
This commit is contained in:
parent
8677c17f29
commit
e15f13646c
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
@ -49,7 +49,7 @@ jobs:
|
||||
- run: git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${{github.repository}}.git
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: npx -y -p gh-pages@3.1.0 gh-pages -d ./storybook-static -u "github-actions-bot <actions@github.com>" --dotfiles
|
||||
- run: npx -y -p gh-pages@3.1.0 gh-pages -d ./storybook-static -u "github-actions-bot <actions@github.com>"
|
||||
|
||||
check_if_version_upgraded:
|
||||
name: Check if version upgrade
|
||||
|
@ -1,9 +1,58 @@
|
||||
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";
|
||||
|
||||
(async () => {
|
||||
run("yarn build");
|
||||
run("npx build-storybook");
|
||||
})();
|
||||
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}`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user