fix build
This commit is contained in:
parent
52ba14cd8f
commit
2a5a4c16ea
@ -49,10 +49,10 @@
|
||||
"properties-parser": "^0.3.1",
|
||||
"react": "^17.0.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"scripting-tools": "^0.19.13",
|
||||
"typescript": "^4.1.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"scripting-tools": "^0.19.13",
|
||||
"cheerio": "^1.0.0-rc.5",
|
||||
"evt": "^1.9.12",
|
||||
"minimal-polyfills": "^2.1.6",
|
||||
|
@ -29,7 +29,7 @@ export function generateKeycloakThemeResources(
|
||||
transformCodebase({
|
||||
"destDirPath": pathJoin(themeDirPath, "resources", "build"),
|
||||
"srcDirPath": reactAppBuildDirPath,
|
||||
"transformSourceCodeString": ({ filePath, sourceCode }) => {
|
||||
"transformSourceCode": ({ filePath, sourceCode }) => {
|
||||
|
||||
if (/\.css?$/i.test(filePath)) {
|
||||
|
||||
@ -83,23 +83,24 @@ export function generateKeycloakThemeResources(
|
||||
|
||||
{
|
||||
|
||||
const destDirPath = pathJoin(themeDirPath, "..", "tmp_xxKdLpdIdLd");
|
||||
const tmpDirPath = pathJoin(themeDirPath, "..", "tmp_xxKdLpdIdLd");
|
||||
|
||||
downloadAndUnzip({
|
||||
"url": keycloakBuiltinThemesAndThirdPartyExamplesThemsUrl,
|
||||
destDirPath
|
||||
"destDirPath": tmpDirPath
|
||||
});
|
||||
|
||||
child_process.execSync(
|
||||
[
|
||||
"mv",
|
||||
pathJoin("keycloak", "common"),
|
||||
pathJoin("..", "common")
|
||||
].join(" "),
|
||||
{ "cwd": destDirPath }
|
||||
);
|
||||
transformCodebase({
|
||||
"srcDirPath": pathJoin(tmpDirPath, "keycloak", "common"),
|
||||
"destDirPath": pathJoin(tmpDirPath, "..", "common")
|
||||
});
|
||||
|
||||
child_process.execSync(`rm -r ${destDirPath}`);
|
||||
transformCodebase({
|
||||
"srcDirPath": pathJoin(tmpDirPath, "keycloak", "login", "resources"),
|
||||
"destDirPath": pathJoin(themeDirPath, "resources")
|
||||
});
|
||||
|
||||
child_process.execSync(`rm -r ${tmpDirPath}`);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import { keycloakThemeBuildingDirPath } from "./build-keycloak-theme";
|
||||
import { downloadAndUnzip } from "./tools/downloadAndUnzip";
|
||||
import { join as pathJoin } from "path";
|
||||
import { join as pathJoin } from "path";
|
||||
|
||||
export const keycloakBuiltinThemesAndThirdPartyExamplesThemsUrl =
|
||||
"https://github.com/garronej/keycloak-react-theming/releases/download/v0.0.1/other_keycloak_thems.zip";
|
||||
|
@ -1,8 +1,10 @@
|
||||
|
||||
import { basename as pathBasename } from "path";
|
||||
import child_process from "child_process";
|
||||
import { basename as pathBasename, join as pathJoin } from "path";
|
||||
import { execSync } from "child_process";
|
||||
import fs from "fs";
|
||||
import { transformCodebase } from "../tools/transformCodebase";
|
||||
|
||||
/** assert url ends with .zip */
|
||||
export function downloadAndUnzip(
|
||||
params: {
|
||||
url: string;
|
||||
@ -12,11 +14,21 @@ export function downloadAndUnzip(
|
||||
|
||||
const { url, destDirPath } = params;
|
||||
|
||||
fs.mkdirSync(destDirPath, { "recursive": true });
|
||||
const tmpDirPath = pathJoin(destDirPath, "..", "tmp_xxKdOxnEdx");
|
||||
|
||||
[
|
||||
`wget ${url}`,
|
||||
...["unzip", "rm"].map(prg => `${prg} ${pathBasename(url)}`),
|
||||
].forEach(cmd => child_process.execSync(cmd, { "cwd": destDirPath }));
|
||||
execSync(`rm -rf ${tmpDirPath}`);
|
||||
|
||||
fs.mkdirSync(tmpDirPath, { "recursive": true });
|
||||
|
||||
execSync(`wget ${url}`, { "cwd": tmpDirPath })
|
||||
execSync(`unzip ${pathBasename(url)}`, { "cwd": tmpDirPath });
|
||||
execSync(`rm ${pathBasename(url)}`, { "cwd": tmpDirPath });
|
||||
|
||||
transformCodebase({
|
||||
"srcDirPath": tmpDirPath,
|
||||
"destDirPath": destDirPath,
|
||||
});
|
||||
|
||||
execSync(`rm -r ${tmpDirPath}`);
|
||||
|
||||
}
|
@ -3,34 +3,42 @@
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import { crawl } from "./crawl";
|
||||
import { id } from "evt/tools/typeSafety/id";
|
||||
|
||||
/** Apply a transformation function to every file of directory */
|
||||
export function transformCodebase(
|
||||
params: {
|
||||
srcDirPath: string;
|
||||
destDirPath: string;
|
||||
transformSourceCodeString: (params: {
|
||||
type TransformSourceCode =
|
||||
(params: {
|
||||
sourceCode: Buffer;
|
||||
filePath: string;
|
||||
}) => {
|
||||
modifiedSourceCode: Buffer;
|
||||
newFileName?: string;
|
||||
} | undefined;
|
||||
|
||||
/** Apply a transformation function to every file of directory */
|
||||
export function transformCodebase(
|
||||
params: {
|
||||
srcDirPath: string;
|
||||
destDirPath: string;
|
||||
transformSourceCode?: TransformSourceCode;
|
||||
}
|
||||
) {
|
||||
|
||||
const { srcDirPath, destDirPath, transformSourceCodeString } = params;
|
||||
const {
|
||||
srcDirPath,
|
||||
destDirPath,
|
||||
transformSourceCode = id<TransformSourceCode>(({ sourceCode }) => ({ "modifiedSourceCode": sourceCode }))
|
||||
} = params;
|
||||
|
||||
for (const file_relative_path of crawl(srcDirPath)) {
|
||||
|
||||
const filePath = path.join(srcDirPath, file_relative_path);
|
||||
|
||||
const transformSourceCodeStringResult = transformSourceCodeString({
|
||||
const transformSourceCodeResult = transformSourceCode({
|
||||
"sourceCode": fs.readFileSync(filePath),
|
||||
"filePath": path.join(srcDirPath, file_relative_path)
|
||||
});
|
||||
|
||||
if (transformSourceCodeStringResult === undefined) {
|
||||
if (transformSourceCodeResult === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -44,7 +52,7 @@ export function transformCodebase(
|
||||
{ "recursive": true }
|
||||
);
|
||||
|
||||
const { newFileName, modifiedSourceCode } = transformSourceCodeStringResult;
|
||||
const { newFileName, modifiedSourceCode } = transformSourceCodeResult;
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(
|
||||
|
@ -1,24 +1,18 @@
|
||||
|
||||
import {
|
||||
setupSampleReactProject,
|
||||
setupSampleReactProject,
|
||||
sampleReactProjectDirPath
|
||||
} from "./setupSampleReactProject";
|
||||
import * as st from "scripting-tools";
|
||||
import { join as pathJoin } from "path";
|
||||
import { getProjectRoot } from "../bin/tools/getProjectRoot";
|
||||
|
||||
import { getProjectRoot } from "../bin/tools/getProjectRoot";
|
||||
|
||||
setupSampleReactProject();
|
||||
|
||||
|
||||
console.log(`Running main in ${sampleReactProjectDirPath}`);
|
||||
|
||||
console.log(
|
||||
st.execSync(
|
||||
`node ${pathJoin(getProjectRoot(), "dist", "bin", "build-keycloak-theme")}`,
|
||||
{ "cwd": sampleReactProjectDirPath }
|
||||
)
|
||||
);
|
||||
st.execSyncTrace(
|
||||
`node ${pathJoin(getProjectRoot(), "dist", "bin", "build-keycloak-theme")}`,
|
||||
{ "cwd": sampleReactProjectDirPath }
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
@ -4,13 +4,9 @@ import * as st from "scripting-tools";
|
||||
import { join as pathJoin } from "path";
|
||||
import { getProjectRoot } from "../bin/tools/getProjectRoot";
|
||||
|
||||
console.log(`Running main in ${sampleReactProjectDirPath}`);
|
||||
|
||||
console.log(
|
||||
st.execSync(
|
||||
`node ${pathJoin(getProjectRoot(), "dist", "bin", "download-sample-keycloak-themes")}`,
|
||||
{ "cwd": sampleReactProjectDirPath }
|
||||
)
|
||||
);
|
||||
st.execSyncTrace(
|
||||
`node ${pathJoin(getProjectRoot(), "dist", "bin", "download-sample-keycloak-themes")}`,
|
||||
{ "cwd": sampleReactProjectDirPath }
|
||||
)
|
||||
|
||||
|
||||
|
@ -1,20 +1,14 @@
|
||||
|
||||
import { getProjectRoot } from "../bin/tools/getProjectRoot";
|
||||
import * as st from "scripting-tools";
|
||||
import { join as pathJoin, basename as pathBasename } from "path";
|
||||
import { getProjectRoot } from "../bin/tools/getProjectRoot";
|
||||
import { join as pathJoin } from "path";
|
||||
import { downloadAndUnzip } from "../bin/tools/downloadAndUnzip";
|
||||
|
||||
export const sampleReactProjectDirPath = pathJoin(getProjectRoot(), "sample_react_project");
|
||||
|
||||
export function setupSampleReactProject() {
|
||||
|
||||
st.execSync(`rm -rf ${sampleReactProjectDirPath}`);
|
||||
st.execSync(`mkdir ${sampleReactProjectDirPath}`);
|
||||
|
||||
const url = "https://github.com/garronej/keycloak-react-theming/releases/download/v0.0.1/sample_build_dir_and_package_json.zip";
|
||||
|
||||
[
|
||||
`wget ${url}`,
|
||||
...["unzip", "rm"].map(prg => `${prg} ${pathBasename(url)}`)
|
||||
].forEach(cmd => st.execSync(cmd, { "cwd": sampleReactProjectDirPath }));
|
||||
|
||||
}
|
||||
downloadAndUnzip({
|
||||
"url": "https://github.com/garronej/keycloak-react-theming/releases/download/v0.0.1/sample_build_dir_and_package_json.zip",
|
||||
"destDirPath": sampleReactProjectDirPath
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user