Add script for downloading base themes
This commit is contained in:
parent
6ef4348c99
commit
0d5462d2f1
23
README.md
23
README.md
@ -15,3 +15,26 @@
|
||||
-
|
||||
<a href="https://github.com/garronej/keycloak-react-theming">Documentation</a>
|
||||
</p>
|
||||
|
||||
# REQUIREMENT
|
||||
## For building the theme:
|
||||
|
||||
- `mvn` must be installed
|
||||
|
||||
## For development, (testing the theme on a docker container ect ):
|
||||
|
||||
- `rm`
|
||||
- `mkdir` )
|
||||
- `wget`
|
||||
- `unzip`
|
||||
|
||||
Tested on MacOS
|
||||
|
||||
# USAGE
|
||||
|
||||
## Build the theme:
|
||||
`npx build-keycloak-theme`
|
||||
|
||||
## (Optional/Debug) Download more themes:
|
||||
|
||||
`npx download-sample-keycloak-themes`
|
||||
|
@ -10,12 +10,13 @@
|
||||
"types": "dist/lib/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc && npm run grant-exec-perms",
|
||||
"grant-exec-perms": "chmod +x dist/bin/build-keycloak-theme/index.js",
|
||||
"test": "node dist/test/build-keycloak-theme.js",
|
||||
"grant-exec-perms": "chmod +x dist/bin/{build-keycloak-theme/index,download-sample-keycloak-themes}.js",
|
||||
"test": "node dist/test/build-keycloak-theme && node dist/test/download-sample-keycloak-themes",
|
||||
"enable_short_import_path": "npm run build && denoify_enable_short_npm_import_path"
|
||||
},
|
||||
"bin": {
|
||||
"build-keycloak-theme": "dist/bin/build-keycloak-theme"
|
||||
"build-keycloak-theme": "dist/bin/build-keycloak-theme",
|
||||
"download-sample-keycloak-themes": "dist/bin/download-sample-keycloak-themes"
|
||||
},
|
||||
"author": "u/garronej",
|
||||
"license": "MIT",
|
||||
@ -42,4 +43,4 @@
|
||||
"dependencies": {
|
||||
"cheerio": "^1.0.0-rc.5"
|
||||
}
|
||||
}
|
||||
}
|
@ -8,20 +8,6 @@ import {
|
||||
} from "./replaceImportFromStatic";
|
||||
import { generateFtlFilesCodeFactory } from "./generateFtl";
|
||||
|
||||
|
||||
/*
|
||||
const reactAppBuildDirPath = pathJoin(process.cwd(), "build");
|
||||
|
||||
assert(
|
||||
fs.existsSync(reactAppBuildDirPath),
|
||||
"Run 'react-script build' first (the build dir should be present)"
|
||||
);
|
||||
|
||||
const keycloakDir = pathJoin(reactAppBuildDirPath, "..", "keycloak_build");
|
||||
|
||||
|
||||
*/
|
||||
|
||||
const ftlValuesGlobalName = "keycloakFtlValues";
|
||||
|
||||
export function generateKeycloakThemeResources(
|
||||
|
@ -3,31 +3,35 @@ import { generateJavaStackFiles } from "./generateJavaStackFiles";
|
||||
import type { ParsedPackageJson } from "./generateJavaStackFiles";
|
||||
import { join as pathJoin } from "path";
|
||||
import * as child_process from "child_process";
|
||||
import { generateDebugFiles } from "./generateDebugFiles";
|
||||
import { generateDebugFiles } from "./generateDebugFiles";
|
||||
|
||||
const reactProjectDirPath = process.cwd();
|
||||
|
||||
const parsedPackageJson: ParsedPackageJson = require(pathJoin(reactProjectDirPath, "package.json"));
|
||||
|
||||
const keycloakThemeBuildingDirPath = pathJoin(reactProjectDirPath, "build_keycloak");
|
||||
export const keycloakThemeBuildingDirPath = pathJoin(reactProjectDirPath, "build_keycloak");
|
||||
|
||||
generateKeycloakThemeResources({
|
||||
keycloakThemeBuildingDirPath,
|
||||
"reactAppBuildDirPath": pathJoin(reactProjectDirPath, "build"),
|
||||
"themeName": parsedPackageJson.name
|
||||
});
|
||||
if (require.main === module) {
|
||||
|
||||
generateJavaStackFiles({
|
||||
parsedPackageJson,
|
||||
keycloakThemeBuildingDirPath
|
||||
});
|
||||
generateKeycloakThemeResources({
|
||||
keycloakThemeBuildingDirPath,
|
||||
"reactAppBuildDirPath": pathJoin(reactProjectDirPath, "build"),
|
||||
"themeName": parsedPackageJson.name
|
||||
});
|
||||
|
||||
child_process.execSync(
|
||||
"mvn package",
|
||||
{ "cwd": keycloakThemeBuildingDirPath }
|
||||
);
|
||||
generateJavaStackFiles({
|
||||
parsedPackageJson,
|
||||
keycloakThemeBuildingDirPath
|
||||
});
|
||||
|
||||
generateDebugFiles({
|
||||
keycloakThemeBuildingDirPath,
|
||||
"packageJsonName": parsedPackageJson.name
|
||||
});
|
||||
child_process.execSync(
|
||||
"mvn package",
|
||||
{ "cwd": keycloakThemeBuildingDirPath }
|
||||
);
|
||||
|
||||
generateDebugFiles({
|
||||
keycloakThemeBuildingDirPath,
|
||||
"packageJsonName": parsedPackageJson.name
|
||||
});
|
||||
|
||||
}
|
||||
|
17
src/bin/download-sample-keycloak-themes.ts
Normal file
17
src/bin/download-sample-keycloak-themes.ts
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
import * as fs from "fs";
|
||||
import { join as pathJoin, basename as pathBasename } from "path";
|
||||
import { keycloakThemeBuildingDirPath } from "./build-keycloak-theme";
|
||||
import child_process from "child_process";
|
||||
|
||||
if (!fs.existsSync(keycloakThemeBuildingDirPath)) {
|
||||
console.log("Error: The keycloak theme need to be build");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const url = "https://github.com/garronej/keycloak-react-theming/releases/download/v0.0.1/other_keycloak_thems.zip";
|
||||
|
||||
[
|
||||
`wget ${url}`,
|
||||
...["unzip", "rm"].map(prg => `${prg} ${pathBasename(url)}`),
|
||||
].forEach(cmd => child_process.execSync(cmd, { "cwd": pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme") }));
|
@ -1,11 +1,15 @@
|
||||
|
||||
import { setupSampleReactProject } from "./setupSampleReactProject";
|
||||
import * as st from "scripting-tools";
|
||||
import { join as pathJoin } from "path";
|
||||
|
||||
const { sampleReactProjectDirPath } = setupSampleReactProject();
|
||||
|
||||
process.chdir(sampleReactProjectDirPath);
|
||||
|
||||
console.log(`Running main in ${sampleReactProjectDirPath}`);
|
||||
|
||||
import("../bin/build-keycloak-theme");
|
||||
st.execSync(
|
||||
`node ${pathJoin(__dirname, "../bin/build-keycloak-theme")}`,
|
||||
{ "cwd": sampleReactProjectDirPath }
|
||||
);
|
||||
|
||||
|
||||
|
13
src/test/download-sample-keycloak-themes.ts
Normal file
13
src/test/download-sample-keycloak-themes.ts
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
import { sampleReactProjectDirPath } from "./setupSampleReactProject";
|
||||
import * as st from "scripting-tools";
|
||||
import { join as pathJoin } from "path";
|
||||
|
||||
console.log(`Running main in ${sampleReactProjectDirPath}`);
|
||||
|
||||
st.execSync(
|
||||
`node ${pathJoin(__dirname, "../bin/download-sample-keycloak-themes")}`,
|
||||
{ "cwd": sampleReactProjectDirPath }
|
||||
);
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
import * as st from "scripting-tools";
|
||||
import { join as pathJoin, basename as pathBasename } from "path";
|
||||
|
||||
export function setupSampleReactProject() {
|
||||
export const sampleReactProjectDirPath = pathJoin(__dirname, "..", "..", "sample_react_project");
|
||||
|
||||
const sampleReactProjectDirPath = pathJoin(__dirname, "..", "..", "sample_react_project");
|
||||
export function setupSampleReactProject() {
|
||||
|
||||
st.execSync(`rm -rf ${sampleReactProjectDirPath}`);
|
||||
st.execSync(`mkdir ${sampleReactProjectDirPath}`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user