Remove all reference to --external-assets, broken feature
This commit is contained in:
@ -37,12 +37,7 @@ export function generateFtlFilesCodeFactory(
|
||||
cssGlobalsToDefine: Record<string, string>;
|
||||
indexHtmlCode: string;
|
||||
urlPathname: string;
|
||||
} & ({
|
||||
mode: "standalone";
|
||||
} | {
|
||||
mode: "external assets";
|
||||
urlOrigin: string;
|
||||
})
|
||||
}
|
||||
) {
|
||||
|
||||
const { ftlValuesGlobalName, cssGlobalsToDefine, indexHtmlCode, urlPathname } = params;
|
||||
@ -53,19 +48,7 @@ export function generateFtlFilesCodeFactory(
|
||||
|
||||
const { fixedJsCode } = replaceImportsFromStaticInJsCode({
|
||||
ftlValuesGlobalName,
|
||||
"jsCode": $(element).html()!,
|
||||
...(() => {
|
||||
switch (params.mode) {
|
||||
case "standalone": return {
|
||||
"mode": params.mode
|
||||
};
|
||||
case "external assets": return {
|
||||
"mode": params.mode,
|
||||
"urlOrigin": params.urlOrigin,
|
||||
"urlPathname": params.urlPathname,
|
||||
};
|
||||
}
|
||||
})()
|
||||
"jsCode": $(element).html()!
|
||||
});
|
||||
|
||||
$(element).text(fixedJsCode);
|
||||
@ -76,18 +59,7 @@ export function generateFtlFilesCodeFactory(
|
||||
|
||||
const { fixedCssCode } = replaceImportsInInlineCssCode({
|
||||
"cssCode": $(element).html()!,
|
||||
"urlPathname": params.urlPathname,
|
||||
...(() => {
|
||||
switch (params.mode) {
|
||||
case "standalone": return {
|
||||
"mode": params.mode
|
||||
};
|
||||
case "external assets": return {
|
||||
"mode": params.mode,
|
||||
"urlOrigin": params.urlOrigin,
|
||||
};
|
||||
}
|
||||
})()
|
||||
"urlPathname": params.urlPathname
|
||||
});
|
||||
|
||||
$(element).text(fixedCssCode);
|
||||
@ -106,24 +78,13 @@ export function generateFtlFilesCodeFactory(
|
||||
return;
|
||||
}
|
||||
|
||||
switch (params.mode) {
|
||||
case "external assets":
|
||||
$(element).attr(
|
||||
attrName,
|
||||
href.replace(/^\//, `${params.urlOrigin}/`)
|
||||
);
|
||||
break;
|
||||
case "standalone":
|
||||
$(element).attr(
|
||||
attrName,
|
||||
href.replace(
|
||||
new RegExp(`^${urlPathname.replace(/\//g, "\\/")}`),
|
||||
"${url.resourcesPath}/build/"
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
$(element).attr(
|
||||
attrName,
|
||||
href.replace(
|
||||
new RegExp(`^${urlPathname.replace(/\//g, "\\/")}`),
|
||||
"${url.resourcesPath}/build/"
|
||||
)
|
||||
);
|
||||
|
||||
})
|
||||
);
|
||||
|
@ -21,12 +21,7 @@ export function generateKeycloakThemeResources(
|
||||
reactAppBuildDirPath: string;
|
||||
keycloakThemeBuildingDirPath: string;
|
||||
urlPathname: string;
|
||||
} & ({
|
||||
mode: "standalone";
|
||||
} | {
|
||||
mode: "external assets";
|
||||
urlOrigin: string;
|
||||
})
|
||||
}
|
||||
) {
|
||||
|
||||
const { themeName, reactAppBuildDirPath, keycloakThemeBuildingDirPath, urlPathname } = params;
|
||||
@ -50,42 +45,28 @@ export function generateKeycloakThemeResources(
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (params.mode === "standalone") {
|
||||
|
||||
if (/\.css?$/i.test(filePath)) {
|
||||
if (/\.css?$/i.test(filePath)) {
|
||||
|
||||
const { cssGlobalsToDefine, fixedCssCode } = replaceImportsInCssCode(
|
||||
{ "cssCode": sourceCode.toString("utf8") }
|
||||
);
|
||||
const { cssGlobalsToDefine, fixedCssCode } = replaceImportsInCssCode(
|
||||
{ "cssCode": sourceCode.toString("utf8") }
|
||||
);
|
||||
|
||||
allCssGlobalsToDefine = {
|
||||
...allCssGlobalsToDefine,
|
||||
...cssGlobalsToDefine
|
||||
};
|
||||
allCssGlobalsToDefine = {
|
||||
...allCssGlobalsToDefine,
|
||||
...cssGlobalsToDefine
|
||||
};
|
||||
|
||||
return { "modifiedSourceCode": Buffer.from(fixedCssCode, "utf8") };
|
||||
|
||||
}
|
||||
return { "modifiedSourceCode": Buffer.from(fixedCssCode, "utf8") };
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (/\.js?$/i.test(filePath)) {
|
||||
|
||||
const { fixedJsCode } = replaceImportsFromStaticInJsCode({
|
||||
"jsCode": sourceCode.toString("utf8"),
|
||||
ftlValuesGlobalName,
|
||||
...(() => {
|
||||
switch (params.mode) {
|
||||
case "external assets": return {
|
||||
"mode": params.mode,
|
||||
"urlOrigin": params.urlOrigin,
|
||||
"urlPathname": params.urlPathname
|
||||
};
|
||||
case "standalone": return {
|
||||
"mode": params.mode
|
||||
};
|
||||
}
|
||||
})()
|
||||
ftlValuesGlobalName
|
||||
});
|
||||
|
||||
return { "modifiedSourceCode": Buffer.from(fixedJsCode, "utf8") };
|
||||
@ -103,18 +84,7 @@ export function generateKeycloakThemeResources(
|
||||
"indexHtmlCode": fs.readFileSync(
|
||||
pathJoin(reactAppBuildDirPath, "index.html")
|
||||
).toString("utf8"),
|
||||
urlPathname,
|
||||
...(() => {
|
||||
switch (params.mode) {
|
||||
case "external assets": return {
|
||||
"mode": params.mode,
|
||||
"urlOrigin": params.urlOrigin
|
||||
};
|
||||
case "standalone": return {
|
||||
"mode": params.mode
|
||||
};
|
||||
}
|
||||
})()
|
||||
urlPathname
|
||||
});
|
||||
|
||||
pageIds.forEach(pageId => {
|
||||
|
@ -11,8 +11,6 @@ import { URL } from "url";
|
||||
|
||||
const reactProjectDirPath = process.cwd();
|
||||
|
||||
const doUseExternalAssets = process.argv[2]?.toLowerCase() === "--external-assets";
|
||||
|
||||
const parsedPackageJson: ParsedPackageJson = require(pathJoin(reactProjectDirPath, "package.json"));
|
||||
|
||||
export const keycloakThemeBuildingDirPath = pathJoin(reactProjectDirPath, "build_keycloak");
|
||||
@ -26,8 +24,7 @@ if (require.main === module) {
|
||||
keycloakThemeBuildingDirPath,
|
||||
"reactAppBuildDirPath": pathJoin(reactProjectDirPath, "build"),
|
||||
"themeName": parsedPackageJson.name,
|
||||
...(() => {
|
||||
|
||||
"urlPathname": (() => {
|
||||
|
||||
const url = (() => {
|
||||
|
||||
@ -39,35 +36,12 @@ if (require.main === module) {
|
||||
|
||||
})();
|
||||
|
||||
const urlPathname =
|
||||
url === undefined ?
|
||||
"/" :
|
||||
url.pathname.replace(/([^/])$/, "$1/");
|
||||
return url === undefined ?
|
||||
"/" :
|
||||
url.pathname.replace(/([^/])$/, "$1/");
|
||||
|
||||
return !doUseExternalAssets ?
|
||||
{
|
||||
"mode": "standalone",
|
||||
urlPathname
|
||||
} as const
|
||||
:
|
||||
{
|
||||
"mode": "external assets",
|
||||
urlPathname,
|
||||
"urlOrigin": (() => {
|
||||
|
||||
if (url === undefined) {
|
||||
console.error("ERROR: You must specify 'homepage' in your package.json");
|
||||
process.exit(-1);
|
||||
}
|
||||
|
||||
return url.origin;
|
||||
|
||||
})()
|
||||
|
||||
} as const;
|
||||
|
||||
})()
|
||||
|
||||
});
|
||||
|
||||
const { jarFilePath } = generateJavaStackFiles({
|
||||
|
@ -5,27 +5,14 @@ export function replaceImportsFromStaticInJsCode(
|
||||
params: {
|
||||
ftlValuesGlobalName: string;
|
||||
jsCode: string;
|
||||
} & ({
|
||||
mode: "standalone";
|
||||
} | {
|
||||
mode: "external assets";
|
||||
urlOrigin: string;
|
||||
urlPathname: string;
|
||||
})
|
||||
}
|
||||
): { fixedJsCode: string; } {
|
||||
|
||||
const { jsCode, ftlValuesGlobalName } = params;
|
||||
|
||||
const fixedJsCode = jsCode.replace(
|
||||
/[a-z]+\.[a-z]+\+"static\//g,
|
||||
(() => {
|
||||
switch (params.mode) {
|
||||
case "standalone":
|
||||
return `window.${ftlValuesGlobalName}.url.resourcesPath + "/build/static/`;
|
||||
case "external assets":
|
||||
return `"${params.urlOrigin}${params.urlPathname}static/`;
|
||||
}
|
||||
})()
|
||||
`window.${ftlValuesGlobalName}.url.resourcesPath + "/build/static/`
|
||||
);
|
||||
|
||||
return { fixedJsCode };
|
||||
@ -36,12 +23,7 @@ export function replaceImportsInInlineCssCode(
|
||||
params: {
|
||||
cssCode: string;
|
||||
urlPathname: string;
|
||||
} & ({
|
||||
mode: "standalone";
|
||||
} | {
|
||||
mode: "external assets";
|
||||
urlOrigin: string;
|
||||
})
|
||||
}
|
||||
): { fixedCssCode: string; } {
|
||||
|
||||
const { cssCode, urlPathname } = params;
|
||||
@ -50,13 +32,7 @@ export function replaceImportsInInlineCssCode(
|
||||
urlPathname === "/" ?
|
||||
/url\(\/([^/][^)]+)\)/g :
|
||||
new RegExp(`url\\(${urlPathname}([^)]+)\\)`, "g"),
|
||||
(...[, group]) => `url(${(() => {
|
||||
switch (params.mode) {
|
||||
case "standalone": return "${url.resourcesPath}/build/" + group;
|
||||
case "external assets": return params.urlOrigin + urlPathname + group
|
||||
}
|
||||
})()
|
||||
})`
|
||||
(...[, group]) => `url(${"${url.resourcesPath}/build/" + group})`
|
||||
);
|
||||
|
||||
return { fixedCssCode };
|
||||
|
@ -12,7 +12,6 @@ generateKeycloakThemeResources({
|
||||
"themeName": "keycloakify-demo-app",
|
||||
"reactAppBuildDirPath": pathJoin(sampleReactProjectDirPath, "build"),
|
||||
"keycloakThemeBuildingDirPath": pathJoin(sampleReactProjectDirPath, "build_keycloak_theme"),
|
||||
"mode": "standalone",
|
||||
"urlPathname": "/keycloakify-demo-app/"
|
||||
});
|
||||
|
||||
|
@ -19,8 +19,7 @@ const { fixedJsCode } = replaceImportsFromStaticInJsCode({
|
||||
3: "0664cdc0"
|
||||
}[e] + ".chunk.js"
|
||||
}
|
||||
`,
|
||||
"mode": "standalone"
|
||||
`
|
||||
});
|
||||
|
||||
console.log({ fixedJsCode });
|
||||
|
Reference in New Issue
Block a user