Fix build
This commit is contained in:
parent
de312c60b1
commit
ad78221025
@ -14,7 +14,7 @@
|
|||||||
"grant-exec-perms": "node dist/bin/tools/grant-exec-perms.js",
|
"grant-exec-perms": "node dist/bin/tools/grant-exec-perms.js",
|
||||||
"test": "node dist/test",
|
"test": "node dist/test",
|
||||||
"enable_short_import_path": "yarn build && denoify_enable_short_npm_import_path",
|
"enable_short_import_path": "yarn build && denoify_enable_short_npm_import_path",
|
||||||
"copy-files": "copyfiles -u 1 src/**/*.ftl src/**/*.xml dist/",
|
"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",
|
||||||
"watch": "tsc -w"
|
"watch": "tsc -w"
|
||||||
},
|
},
|
||||||
@ -52,11 +52,11 @@
|
|||||||
"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": "2.0.0-beta.15",
|
"evt": "2.0.0-beta.15",
|
||||||
"minimal-polyfills": "^2.1.6",
|
"minimal-polyfills": "^2.1.6",
|
||||||
"powerhooks": "^0.0.17",
|
"powerhooks": "^0.0.19",
|
||||||
|
"scripting-tools": "^0.19.13",
|
||||||
"tss-react": "^0.0.11"
|
"tss-react": "^0.0.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
Object.defineProperty(
|
||||||
|
Object,
|
||||||
|
"deepAssign",
|
||||||
|
{
|
||||||
|
"value": function callee(target, source) {
|
||||||
|
Object.keys(source).forEach(function (key) {
|
||||||
|
var value = source[key];
|
||||||
|
if (target[key] === undefined) {
|
||||||
|
target[key] = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (value instanceof Object) {
|
||||||
|
if (value instanceof Array) {
|
||||||
|
value.forEach(function (entry) {
|
||||||
|
target[key].push(entry);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callee(target[key], value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
target[key] = value;
|
||||||
|
});
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
var es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;
|
||||||
|
|
||||||
|
var unes = {
|
||||||
|
'&': '&',
|
||||||
|
'&': '&',
|
||||||
|
'<': '<',
|
||||||
|
'<': '<',
|
||||||
|
'>': '>',
|
||||||
|
'>': '>',
|
||||||
|
''': "'",
|
||||||
|
''': "'",
|
||||||
|
'"': '"',
|
||||||
|
'"': '"'
|
||||||
|
};
|
||||||
|
var cape = function (m) { return unes[m]; };
|
||||||
|
|
||||||
|
Object.defineProperty(
|
||||||
|
String,
|
||||||
|
"htmlUnescape",
|
||||||
|
{
|
||||||
|
"value": function (un) {
|
||||||
|
return String.prototype.replace.call(un, es, cape);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
@ -9,15 +9,20 @@ import fs from "fs";
|
|||||||
import { join as pathJoin } from "path";
|
import { join as pathJoin } from "path";
|
||||||
import { objectKeys } from "evt/tools/typeSafety/objectKeys";
|
import { objectKeys } from "evt/tools/typeSafety/objectKeys";
|
||||||
|
|
||||||
export type PageId = "login.ftl" | "register.ftl" | "info.ftl" | "error.ftl";
|
export const pageIds= [ "login.ftl", "register.ftl", "info.ftl", "error.ftl"] as const;
|
||||||
|
|
||||||
|
export type PageId = typeof pageIds[number];
|
||||||
|
|
||||||
|
function loadAdjacentFile(fileBasename: string){
|
||||||
|
return fs.readFileSync(pathJoin(__dirname, fileBasename))
|
||||||
|
.toString("utf8");
|
||||||
|
};
|
||||||
|
|
||||||
function loadFtlFile(ftlFileBasename: PageId | "template.ftl") {
|
function loadFtlFile(ftlFileBasename: PageId | "template.ftl") {
|
||||||
return fs.readFileSync(pathJoin(__dirname, ftlFileBasename))
|
return loadAdjacentFile(ftlFileBasename)
|
||||||
.toString("utf8")
|
|
||||||
.match(/^<script>const _=((?:.|\n)+)<\/script>[\n]?$/)![1];
|
.match(/^<script>const _=((?:.|\n)+)<\/script>[\n]?$/)![1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function generateFtlFilesCodeFactory(
|
export function generateFtlFilesCodeFactory(
|
||||||
params: {
|
params: {
|
||||||
ftlValuesGlobalName: string;
|
ftlValuesGlobalName: string;
|
||||||
@ -41,7 +46,6 @@ export function generateFtlFilesCodeFactory(
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
([
|
([
|
||||||
["link", "href"],
|
["link", "href"],
|
||||||
["script", "src"],
|
["script", "src"],
|
||||||
@ -68,10 +72,12 @@ export function generateFtlFilesCodeFactory(
|
|||||||
' <#list scripts as script>',
|
' <#list scripts as script>',
|
||||||
' <script src="${script}" type="text/javascript"></script>',
|
' <script src="${script}" type="text/javascript"></script>',
|
||||||
' </#list>',
|
' </#list>',
|
||||||
'</#if>',
|
'</#if>'
|
||||||
].join("\n")
|
].join("\n")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const pageSpecificCodePlaceholder = "<!-- dIddLqMeOedErIdLsPdNdI9dSl42sw -->";
|
||||||
|
|
||||||
$("head").prepend(
|
$("head").prepend(
|
||||||
[
|
[
|
||||||
...(Object.keys(cssGlobalsToDefine).length === 0 ? [] : [
|
...(Object.keys(cssGlobalsToDefine).length === 0 ? [] : [
|
||||||
@ -83,19 +89,26 @@ export function generateFtlFilesCodeFactory(
|
|||||||
'</style>',
|
'</style>',
|
||||||
''
|
''
|
||||||
]),
|
]),
|
||||||
|
...["Object.deepAssign.js", "String.htmlUnescape.js"].map(
|
||||||
|
fileBasename => [
|
||||||
|
"<script>",
|
||||||
|
loadAdjacentFile(fileBasename),
|
||||||
|
"</script>"
|
||||||
|
].join("\n")
|
||||||
|
),
|
||||||
'<script>',
|
'<script>',
|
||||||
' Object.deepAssign(',
|
` window.${ftlValuesGlobalName}= Object.assign(`,
|
||||||
` window.${ftlValuesGlobalName},`,
|
` {},`,
|
||||||
` ${objectKeys(ftlCommonPlaceholders)[0]}`,
|
` ${objectKeys(ftlCommonPlaceholders)[0]}`,
|
||||||
' );',
|
' );',
|
||||||
'</script>',
|
'</script>',
|
||||||
'',
|
'',
|
||||||
objectKeys(ftlCommonPlaceholders)[1],
|
pageSpecificCodePlaceholder,
|
||||||
''
|
'',
|
||||||
|
objectKeys(ftlCommonPlaceholders)[1]
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
const partiallyFixedIndexHtmlCode = $.html();
|
const partiallyFixedIndexHtmlCode = $.html();
|
||||||
|
|
||||||
function generateFtlFilesCode(
|
function generateFtlFilesCode(
|
||||||
@ -113,51 +126,23 @@ export function generateFtlFilesCodeFactory(
|
|||||||
...ftlCommonPlaceholders
|
...ftlCommonPlaceholders
|
||||||
};
|
};
|
||||||
|
|
||||||
$("head").prepend(
|
let ftlCode = $.html()
|
||||||
|
.replace(
|
||||||
|
pageSpecificCodePlaceholder,
|
||||||
[
|
[
|
||||||
'',
|
|
||||||
'<script>',
|
'<script>',
|
||||||
'',
|
` Object.assign(`,
|
||||||
` window.${ftlValuesGlobalName} = Object.assign(`,
|
` window.${ftlValuesGlobalName},`,
|
||||||
` { "pageId": "${pageId}" },`,
|
` { "pageId": "${pageId}" }`,
|
||||||
|
' );',
|
||||||
|
` Object.assign(`,
|
||||||
|
` window.${ftlValuesGlobalName},`,
|
||||||
` ${objectKeys(ftlPlaceholders)[0]}`,
|
` ${objectKeys(ftlPlaceholders)[0]}`,
|
||||||
' );',
|
' );',
|
||||||
'',
|
'</script>'
|
||||||
' Object.defineProperty(',
|
|
||||||
' Object,',
|
|
||||||
' "deepAssign",',
|
|
||||||
' {',
|
|
||||||
' "value": function callee(target, source) {',
|
|
||||||
' Object.keys(source).forEach(function (key) {',
|
|
||||||
' var value = source[key];',
|
|
||||||
' if( target[key] === undefined ){',
|
|
||||||
' target[key]= value;',
|
|
||||||
' return;',
|
|
||||||
' }',
|
|
||||||
' if( value instanceof Object ){',
|
|
||||||
' if( value instanceof Array ){',
|
|
||||||
' value.forEach(function (entry){',
|
|
||||||
' target[key].push(entry);',
|
|
||||||
' });',
|
|
||||||
' return;',
|
|
||||||
' }',
|
|
||||||
' callee(target[key], value);',
|
|
||||||
' return;',
|
|
||||||
' }',
|
|
||||||
' target[key]= value;',
|
|
||||||
' });',
|
|
||||||
' return target;',
|
|
||||||
' }',
|
|
||||||
' }',
|
|
||||||
' );',
|
|
||||||
'',
|
|
||||||
'</script>',
|
|
||||||
''
|
|
||||||
].join("\n")
|
].join("\n")
|
||||||
);
|
);
|
||||||
|
|
||||||
let ftlCode = $.html();
|
|
||||||
|
|
||||||
objectKeys(ftlPlaceholders)
|
objectKeys(ftlPlaceholders)
|
||||||
.forEach(id => ftlCode = ftlCode.replace(id, ftlPlaceholders[id]));
|
.forEach(id => ftlCode = ftlCode.replace(id, ftlPlaceholders[id]));
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
"type": "${message.type}",
|
"type": "${message.type}",
|
||||||
"summary": "${kcSanitize(message.summary)?no_esc}"
|
"summary": String.htmlUnescape("${message.summary}")
|
||||||
};
|
};
|
||||||
|
|
||||||
</#if>
|
</#if>
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
replaceImportFromStaticInCssCode,
|
replaceImportFromStaticInCssCode,
|
||||||
replaceImportFromStaticInJsCode
|
replaceImportFromStaticInJsCode
|
||||||
} from "./replaceImportFromStatic";
|
} from "./replaceImportFromStatic";
|
||||||
import { generateFtlFilesCodeFactory } from "./generateFtl";
|
import { generateFtlFilesCodeFactory, pageIds } from "./generateFtl";
|
||||||
import { builtinThemesUrl } from "../install-builtin-keycloak-themes";
|
import { builtinThemesUrl } from "../install-builtin-keycloak-themes";
|
||||||
import { downloadAndUnzip } from "../tools/downloadAndUnzip";
|
import { downloadAndUnzip } from "../tools/downloadAndUnzip";
|
||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
@ -70,14 +70,14 @@ export function generateKeycloakThemeResources(
|
|||||||
).toString("utf8")
|
).toString("utf8")
|
||||||
});
|
});
|
||||||
|
|
||||||
(["login.ftl", "register.ftl"] as const).forEach(pageId => {
|
pageIds.forEach(pageId => {
|
||||||
|
|
||||||
const { ftlCode } = generateFtlFilesCode({ pageId });
|
const { ftlCode } = generateFtlFilesCode({ pageId });
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
pathJoin(themeDirPath, pageId),
|
pathJoin(themeDirPath, pageId),
|
||||||
Buffer.from(ftlCode, "utf8")
|
Buffer.from(ftlCode, "utf8")
|
||||||
)
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
13
yarn.lock
13
yarn.lock
@ -708,6 +708,11 @@ has@^1.0.3:
|
|||||||
dependencies:
|
dependencies:
|
||||||
function-bind "^1.1.1"
|
function-bind "^1.1.1"
|
||||||
|
|
||||||
|
html-escaper@^3.0.3:
|
||||||
|
version "3.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-3.0.3.tgz#4d336674652beb1dcbc29ef6b6ba7f6be6fdfed6"
|
||||||
|
integrity sha512-RuMffC89BOWQoY0WKGpIhn5gX3iI54O6nRA0yC124NYVtzjmFWBIiFd8M0x+ZdX0P9R4lADg1mgP8C7PxGOWuQ==
|
||||||
|
|
||||||
htmlparser2@^6.0.0:
|
htmlparser2@^6.0.0:
|
||||||
version "6.0.0"
|
version "6.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-6.0.0.tgz#c2da005030390908ca4c91e5629e418e0665ac01"
|
resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-6.0.0.tgz#c2da005030390908ca4c91e5629e418e0665ac01"
|
||||||
@ -932,10 +937,10 @@ path-type@^4.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
|
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
|
||||||
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
|
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
|
||||||
|
|
||||||
powerhooks@^0.0.17:
|
powerhooks@^0.0.19:
|
||||||
version "0.0.17"
|
version "0.0.19"
|
||||||
resolved "https://registry.yarnpkg.com/powerhooks/-/powerhooks-0.0.17.tgz#840295271d989c27b83047fad44973434c509ba7"
|
resolved "https://registry.yarnpkg.com/powerhooks/-/powerhooks-0.0.19.tgz#86f4157dbde32cd44082c756ab747c64f6045449"
|
||||||
integrity sha512-9z0C5pnVJI3SRKgcoAjbOxVa1lf/e58N+YdByThue1C4DUqfp8umx9XvrRJJ3dGwl6A0RRrJlyPM1KXjVChQMQ==
|
integrity sha512-yaODFWkflrZCSz4lvRQ2O4AjolheiE6oXa1F4mny2LUOwai4ip+zer16fgXEM53R+IiDnqj6ff8wooU5x4GslQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
evt "2.0.0-beta.13"
|
evt "2.0.0-beta.13"
|
||||||
memoizee "^0.4.15"
|
memoizee "^0.4.15"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user