Feat scrip: download-builtin-keycloak-theme for downloading any version of the builtin themes
This commit is contained in:
parent
fb5f358686
commit
c52b8cc98e
1
.gitignore
vendored
1
.gitignore
vendored
@ -43,3 +43,4 @@ jspm_packages
|
||||
/dist
|
||||
|
||||
/sample_react_project/
|
||||
/.yarn_home/
|
||||
|
@ -14,11 +14,12 @@
|
||||
"grant-exec-perms": "node dist/bin/tools/grant-exec-perms.js",
|
||||
"test": "node dist/test/bin/main && node dist/test/lib",
|
||||
"copy-files": "copyfiles -u 1 src/**/*.ftl src/**/*.xml src/**/*.js dist/",
|
||||
"generate-messages": "node dist/bin/generate-i18n-messages.js"
|
||||
"generate-messages": "node dist/bin/generate-i18n-messages.js",
|
||||
"link_in_test_app": "node dist/bin/link_in_test_app.js"
|
||||
},
|
||||
"bin": {
|
||||
"build-keycloak-theme": "dist/bin/build-keycloak-theme/index.js",
|
||||
"install-builtin-keycloak-themes": "dist/bin/install-builtin-keycloak-themes.js"
|
||||
"download-builtin-keycloak-theme": "dist/bin/download-builtin-keycloak-theme.js"
|
||||
},
|
||||
"author": "u/garronej",
|
||||
"license": "MIT",
|
||||
|
@ -4,7 +4,6 @@ import { join as pathJoin, relative as pathRelative, basename as pathBasename }
|
||||
import * as child_process from "child_process";
|
||||
import { generateDebugFiles, containerLaunchScriptBasename } from "./generateDebugFiles";
|
||||
import { URL } from "url";
|
||||
import type { KeycloakVersion } from "../KeycloakVersion";
|
||||
|
||||
type ParsedPackageJson = {
|
||||
name: string;
|
||||
@ -12,8 +11,6 @@ type ParsedPackageJson = {
|
||||
homepage?: string;
|
||||
};
|
||||
|
||||
const keycloakVersion: KeycloakVersion = "15.0.2";
|
||||
|
||||
const reactProjectDirPath = process.cwd();
|
||||
|
||||
const doUseExternalAssets = process.argv[2]?.toLowerCase() === "--external-assets";
|
||||
@ -70,7 +67,10 @@ export function main() {
|
||||
})(),
|
||||
extraPagesId,
|
||||
extraThemeProperties,
|
||||
keycloakVersion
|
||||
//We have to leave it at that otherwise we break our default theme.
|
||||
//Problem is that we can't guarantee that the the old resources common
|
||||
//will still be available on the newer keycloak version.
|
||||
"keycloakVersion": "11.0.3"
|
||||
});
|
||||
|
||||
const { jarFilePath } = generateJavaStackFiles({
|
||||
@ -88,7 +88,7 @@ export function main() {
|
||||
generateDebugFiles({
|
||||
keycloakThemeBuildingDirPath,
|
||||
themeName,
|
||||
keycloakVersion
|
||||
"keycloakVersion": "15.0.2"
|
||||
});
|
||||
|
||||
console.log([
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
replaceImportsFromStaticInJsCode
|
||||
} from "./replaceImportFromStatic";
|
||||
import { generateFtlFilesCodeFactory, pageIds } from "./generateFtl";
|
||||
import { downloadBuiltinKeycloakTheme } from "../install-builtin-keycloak-themes";
|
||||
import { downloadBuiltinKeycloakTheme } from "../download-builtin-keycloak-theme";
|
||||
import * as child_process from "child_process";
|
||||
import { resourcesCommonPath, resourcesPath, subDirOfPublicDirBasename } from "../../lib/getKcContext/kcContextMocks/urlResourcesPath";
|
||||
import { isInside } from "../tools/isInside";
|
||||
|
@ -3,7 +3,7 @@
|
||||
import { keycloakThemeBuildingDirPath } from "./build-keycloak-theme";
|
||||
import { join as pathJoin } from "path";
|
||||
import { downloadAndUnzip } from "./tools/downloadAndUnzip"
|
||||
import type { KeycloakVersion } from "../bin/KeycloakVersion";
|
||||
import type { KeycloakVersion } from "./KeycloakVersion";
|
||||
|
||||
export function downloadBuiltinKeycloakTheme(
|
||||
params: {
|
||||
@ -28,8 +28,7 @@ export function downloadBuiltinKeycloakTheme(
|
||||
|
||||
if (require.main === module) {
|
||||
|
||||
downloadBuiltinKeycloakTheme({
|
||||
"keycloakVersion": (() => {
|
||||
const keycloakVersion = (() => {
|
||||
|
||||
const keycloakVersion = process.argv[2] as (KeycloakVersion | undefined);
|
||||
|
||||
@ -39,8 +38,15 @@ if (require.main === module) {
|
||||
|
||||
return keycloakVersion;
|
||||
|
||||
})(),
|
||||
"destDirPath": pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme")
|
||||
})();
|
||||
|
||||
const destDirPath = pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme");
|
||||
|
||||
console.log(`Downloading builtins theme of Keycloak ${keycloakVersion} here ${destDirPath}`);
|
||||
|
||||
downloadBuiltinKeycloakTheme({
|
||||
keycloakVersion,
|
||||
destDirPath
|
||||
});
|
||||
|
||||
}
|
@ -2,7 +2,7 @@ import "minimal-polyfills/Object.fromEntries";
|
||||
import * as fs from "fs";
|
||||
import { join as pathJoin, relative as pathRelative } from "path";
|
||||
import { crawl } from "./tools/crawl";
|
||||
import { downloadBuiltinKeycloakTheme } from "./install-builtin-keycloak-themes";
|
||||
import { downloadBuiltinKeycloakTheme } from "./download-builtin-keycloak-theme";
|
||||
import { getProjectRoot } from "./tools/getProjectRoot";
|
||||
import { rm_rf, rm_r } from "./tools/rm";
|
||||
import { keycloakVersions } from "./KeycloakVersion";
|
||||
|
131
src/bin/link_in_test_app.ts
Normal file
131
src/bin/link_in_test_app.ts
Normal file
@ -0,0 +1,131 @@
|
||||
|
||||
import { execSync } from "child_process";
|
||||
import { join as pathJoin, relative as pathRelative } from "path";
|
||||
import * as fs from "fs";
|
||||
|
||||
const keycloakifyDirPath = pathJoin(__dirname, "..", "..");
|
||||
|
||||
fs.writeFileSync(
|
||||
pathJoin(keycloakifyDirPath, "dist", "package.json"),
|
||||
Buffer.from(
|
||||
JSON.stringify(
|
||||
(() => {
|
||||
const packageJsonParsed = JSON.parse(
|
||||
fs
|
||||
.readFileSync(pathJoin(keycloakifyDirPath, "package.json"))
|
||||
.toString("utf8"),
|
||||
);
|
||||
|
||||
return {
|
||||
...packageJsonParsed,
|
||||
"main": packageJsonParsed["main"].replace(/^dist\//, ""),
|
||||
"types": packageJsonParsed["types"].replace(/^dist\//, ""),
|
||||
};
|
||||
})(),
|
||||
null,
|
||||
2,
|
||||
),
|
||||
"utf8",
|
||||
),
|
||||
);
|
||||
|
||||
const commonThirdPartyDeps = (() => {
|
||||
const namespaceModuleNames = ["@emotion"];
|
||||
const standaloneModuleNames = ["react", "@types/react", "powerhooks", "tss-react", "evt"];
|
||||
|
||||
return [
|
||||
...namespaceModuleNames
|
||||
.map(namespaceModuleName =>
|
||||
fs
|
||||
.readdirSync(
|
||||
pathJoin(
|
||||
keycloakifyDirPath,
|
||||
"node_modules",
|
||||
namespaceModuleName,
|
||||
),
|
||||
)
|
||||
.map(
|
||||
submoduleName =>
|
||||
`${namespaceModuleName}/${submoduleName}`,
|
||||
),
|
||||
)
|
||||
.reduce((prev, curr) => [...prev, ...curr], []),
|
||||
...standaloneModuleNames,
|
||||
];
|
||||
})();
|
||||
|
||||
const yarnHomeDirPath = pathJoin(keycloakifyDirPath, ".yarn_home");
|
||||
|
||||
execSync(
|
||||
["rm -rf", "mkdir"].map(cmd => `${cmd} ${yarnHomeDirPath}`).join(" && "),
|
||||
);
|
||||
|
||||
const execYarnLink = (params: { targetModuleName?: string; cwd: string }) => {
|
||||
const { targetModuleName, cwd } = params;
|
||||
|
||||
const cmd = [
|
||||
"yarn",
|
||||
"link",
|
||||
...(targetModuleName !== undefined ? [targetModuleName] : []),
|
||||
].join(" ");
|
||||
|
||||
console.log(`$ cd ${pathRelative(keycloakifyDirPath, cwd) || "."} && ${cmd}`);
|
||||
|
||||
execSync(cmd, {
|
||||
cwd,
|
||||
"env": {
|
||||
...process.env,
|
||||
"HOME": yarnHomeDirPath,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const testAppNames = ["keycloakify-demo-app"] as const;
|
||||
|
||||
const getTestAppPath = (testAppName: typeof testAppNames[number]) =>
|
||||
pathJoin(keycloakifyDirPath, "..", testAppName);
|
||||
|
||||
testAppNames.forEach(testAppName =>
|
||||
execSync("yarn install", { "cwd": getTestAppPath(testAppName) }),
|
||||
);
|
||||
|
||||
console.log("=== Linking common dependencies ===");
|
||||
|
||||
const total = commonThirdPartyDeps.length;
|
||||
let current = 0;
|
||||
|
||||
commonThirdPartyDeps.forEach(commonThirdPartyDep => {
|
||||
current++;
|
||||
|
||||
console.log(`${current}/${total} ${commonThirdPartyDep}`);
|
||||
|
||||
const localInstallPath = pathJoin(
|
||||
...[
|
||||
keycloakifyDirPath,
|
||||
"node_modules",
|
||||
...(commonThirdPartyDep.startsWith("@")
|
||||
? commonThirdPartyDep.split("/")
|
||||
: [commonThirdPartyDep]),
|
||||
],
|
||||
);
|
||||
|
||||
execYarnLink({ "cwd": localInstallPath });
|
||||
|
||||
testAppNames.forEach(testAppName =>
|
||||
execYarnLink({
|
||||
"cwd": getTestAppPath(testAppName),
|
||||
"targetModuleName": commonThirdPartyDep,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
console.log("=== Linking in house dependencies ===");
|
||||
|
||||
execYarnLink({ "cwd": pathJoin(keycloakifyDirPath, "dist") });
|
||||
|
||||
testAppNames.forEach(testAppName =>
|
||||
execYarnLink({
|
||||
"cwd": getTestAppPath(testAppName),
|
||||
"targetModuleName": "keycloakify",
|
||||
}),
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user