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