Fix other scripts
This commit is contained in:
parent
2b6c991190
commit
59d47592d9
@ -19,7 +19,7 @@
|
|||||||
"_format": "prettier '**/*.{ts,tsx,json,md}'",
|
"_format": "prettier '**/*.{ts,tsx,json,md}'",
|
||||||
"format": "yarn _format --write",
|
"format": "yarn _format --write",
|
||||||
"format:check": "yarn _format --list-different",
|
"format:check": "yarn _format --list-different",
|
||||||
"generate-messages": "ts-node --skipProject scripts/generate-i18n-messages.ts",
|
"generate-i18n-messages": "ts-node --skipProject scripts/generate-i18n-messages.ts",
|
||||||
"link-in-app": "ts-node --skipProject scripts/link-in-app.ts",
|
"link-in-app": "ts-node --skipProject scripts/link-in-app.ts",
|
||||||
"link-in-starter": "yarn link-in-app keycloakify-starter",
|
"link-in-starter": "yarn link-in-app keycloakify-starter",
|
||||||
"tsc-watch": "tsc -p src/bin -w & tsc -p src/lib -w "
|
"tsc-watch": "tsc -p src/bin -w & tsc -p src/lib -w "
|
||||||
|
@ -16,71 +16,73 @@ const propertiesParser = require("properties-parser");
|
|||||||
const { isSilent } = getCliOptions(process.argv.slice(2));
|
const { isSilent } = getCliOptions(process.argv.slice(2));
|
||||||
const logger = getLogger({ isSilent });
|
const logger = getLogger({ isSilent });
|
||||||
|
|
||||||
for (const keycloakVersion of ["11.0.3", "15.0.2", "18.0.1"]) {
|
(async () => {
|
||||||
logger.log(JSON.stringify({ keycloakVersion }));
|
for (const keycloakVersion of ["11.0.3", "15.0.2", "18.0.1", "21.0.1"]) {
|
||||||
|
logger.log(JSON.stringify({ keycloakVersion }));
|
||||||
|
|
||||||
const tmpDirPath = pathJoin(getProjectRoot(), "tmp_xImOef9dOd44");
|
const tmpDirPath = pathJoin(getProjectRoot(), "tmp_xImOef9dOd44");
|
||||||
|
|
||||||
fs.rmSync(tmpDirPath, { "recursive": true, "force": true });
|
fs.rmSync(tmpDirPath, { "recursive": true, "force": true });
|
||||||
|
|
||||||
downloadBuiltinKeycloakTheme({
|
await downloadBuiltinKeycloakTheme({
|
||||||
keycloakVersion,
|
keycloakVersion,
|
||||||
"destDirPath": tmpDirPath,
|
"destDirPath": tmpDirPath,
|
||||||
isSilent
|
isSilent
|
||||||
});
|
});
|
||||||
|
|
||||||
type Dictionary = { [idiomId: string]: string };
|
type Dictionary = { [idiomId: string]: string };
|
||||||
|
|
||||||
const record: { [typeOfPage: string]: { [language: string]: Dictionary } } = {};
|
const record: { [typeOfPage: string]: { [language: string]: Dictionary } } = {};
|
||||||
|
|
||||||
{
|
{
|
||||||
const baseThemeDirPath = pathJoin(tmpDirPath, "base");
|
const baseThemeDirPath = pathJoin(tmpDirPath, "base");
|
||||||
|
|
||||||
crawl(baseThemeDirPath).forEach(filePath => {
|
crawl(baseThemeDirPath).forEach(filePath => {
|
||||||
const match = filePath.match(/^([^/]+)\/messages\/messages_([^.]+)\.properties$/);
|
const match = filePath.match(/^([^/]+)\/messages\/messages_([^.]+)\.properties$/);
|
||||||
|
|
||||||
if (match === null) {
|
if (match === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [, typeOfPage, language] = match;
|
const [, typeOfPage, language] = match;
|
||||||
|
|
||||||
(record[typeOfPage] ??= {})[language.replace(/_/g, "-")] = Object.fromEntries(
|
(record[typeOfPage] ??= {})[language.replace(/_/g, "-")] = Object.fromEntries(
|
||||||
Object.entries(propertiesParser.parse(fs.readFileSync(pathJoin(baseThemeDirPath, filePath)).toString("utf8"))).map(
|
Object.entries(propertiesParser.parse(fs.readFileSync(pathJoin(baseThemeDirPath, filePath)).toString("utf8"))).map(
|
||||||
([key, value]: any) => [key, value.replace(/''/g, "'")]
|
([key, value]: any) => [key, value.replace(/''/g, "'")]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.rmSync(tmpDirPath, { recursive: true, force: true });
|
||||||
|
|
||||||
|
Object.keys(record).forEach(pageType => {
|
||||||
|
const recordForPageType = record[pageType];
|
||||||
|
|
||||||
|
Object.keys(recordForPageType).forEach(language => {
|
||||||
|
const filePath = pathJoin(getProjectRoot(), "src", "lib", "i18n", "generated_messages", keycloakVersion, pageType, `${language}.ts`);
|
||||||
|
|
||||||
|
fs.mkdirSync(pathDirname(filePath), { "recursive": true });
|
||||||
|
|
||||||
|
fs.writeFileSync(
|
||||||
|
filePath,
|
||||||
|
Buffer.from(
|
||||||
|
[
|
||||||
|
`//This code was automatically generated by running ${pathRelative(getProjectRoot(), __filename)}`,
|
||||||
|
"//PLEASE DO NOT EDIT MANUALLY",
|
||||||
|
"",
|
||||||
|
"/* spell-checker: disable */",
|
||||||
|
`const messages= ${JSON.stringify(recordForPageType[language], null, 2)};`,
|
||||||
|
"",
|
||||||
|
"export default messages;",
|
||||||
|
"/* spell-checker: enable */"
|
||||||
|
].join("\n"),
|
||||||
|
"utf8"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
logger.log(`${filePath} wrote`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
})();
|
||||||
fs.rmSync(tmpDirPath, { recursive: true, force: true });
|
|
||||||
|
|
||||||
Object.keys(record).forEach(pageType => {
|
|
||||||
const recordForPageType = record[pageType];
|
|
||||||
|
|
||||||
Object.keys(recordForPageType).forEach(language => {
|
|
||||||
const filePath = pathJoin(getProjectRoot(), "src", "lib", "i18n", "generated_messages", keycloakVersion, pageType, `${language}.ts`);
|
|
||||||
|
|
||||||
fs.mkdirSync(pathDirname(filePath), { "recursive": true });
|
|
||||||
|
|
||||||
fs.writeFileSync(
|
|
||||||
filePath,
|
|
||||||
Buffer.from(
|
|
||||||
[
|
|
||||||
`//This code was automatically generated by running ${pathRelative(getProjectRoot(), __filename)}`,
|
|
||||||
"//PLEASE DO NOT EDIT MANUALLY",
|
|
||||||
"",
|
|
||||||
"/* spell-checker: disable */",
|
|
||||||
`const messages= ${JSON.stringify(recordForPageType[language], null, 2)};`,
|
|
||||||
"",
|
|
||||||
"export default messages;",
|
|
||||||
"/* spell-checker: enable */"
|
|
||||||
].join("\n"),
|
|
||||||
"utf8"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
logger.log(`${filePath} wrote`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -23,7 +23,7 @@ if (require.main === module) {
|
|||||||
|
|
||||||
const builtinKeycloakThemeTmpDirPath = pathJoin(keycloakThemeEmailDirPath, "..", "tmp_xIdP3_builtin_keycloak_theme");
|
const builtinKeycloakThemeTmpDirPath = pathJoin(keycloakThemeEmailDirPath, "..", "tmp_xIdP3_builtin_keycloak_theme");
|
||||||
|
|
||||||
downloadBuiltinKeycloakTheme({
|
await downloadBuiltinKeycloakTheme({
|
||||||
keycloakVersion,
|
keycloakVersion,
|
||||||
"destDirPath": builtinKeycloakThemeTmpDirPath,
|
"destDirPath": builtinKeycloakThemeTmpDirPath,
|
||||||
isSilent
|
isSilent
|
||||||
|
@ -42,6 +42,7 @@ export function crc32(input: Readable | String | Buffer): Promise<number> {
|
|||||||
} else if (input instanceof Readable) {
|
} else if (input instanceof Readable) {
|
||||||
return new Promise<number>((resolve, reject) => {
|
return new Promise<number>((resolve, reject) => {
|
||||||
let crc = ~0;
|
let crc = ~0;
|
||||||
|
input.setMaxListeners(Infinity);
|
||||||
input.on("end", () => resolve((crc ^ -1) >>> 0));
|
input.on("end", () => resolve((crc ^ -1) >>> 0));
|
||||||
input.on("error", e => reject(e));
|
input.on("error", e => reject(e));
|
||||||
input.on("data", (chunk: Buffer) => {
|
input.on("data", (chunk: Buffer) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user