Remove some dead code
This commit is contained in:
parent
804abef0de
commit
4506b3f6d4
@ -20,7 +20,6 @@ export async function downloadKeycloakStaticResources(
|
||||
keycloakVersion: string;
|
||||
usedResources: {
|
||||
resourcesCommonFilePaths: string[];
|
||||
resourcesFilePaths: string[];
|
||||
} | undefined
|
||||
}
|
||||
) {
|
||||
|
@ -6,12 +6,10 @@ import type { ThemeType } from "../generateFtl";
|
||||
/** Assumes the theme type exists */
|
||||
export function readStaticResourcesUsage(params: { keycloakifySrcDirPath: string; themeSrcDirPath: string; themeType: ThemeType }): {
|
||||
resourcesCommonFilePaths: string[];
|
||||
resourcesFilePaths: string[];
|
||||
} {
|
||||
const { keycloakifySrcDirPath, themeSrcDirPath, themeType } = params;
|
||||
|
||||
const resourcesCommonFilePaths = new Set<string>();
|
||||
const resourcesFilePaths = new Set<string>();
|
||||
|
||||
for (const srcDirPath of [pathJoin(keycloakifySrcDirPath, themeType), pathJoin(themeSrcDirPath, themeType)]) {
|
||||
const filePaths = crawl({ "dirPath": srcDirPath, "returnedPathsType": "absolute" }).filter(filePath => /\.(ts|tsx|js|jsx)$/.test(filePath));
|
||||
@ -26,51 +24,43 @@ export function readStaticResourcesUsage(params: { keycloakifySrcDirPath: string
|
||||
const wrap = readPaths({ rawSourceFile });
|
||||
|
||||
wrap.resourcesCommonFilePaths.forEach(filePath => resourcesCommonFilePaths.add(filePath));
|
||||
wrap.resourcesFilePaths.forEach(filePath => resourcesFilePaths.add(filePath));
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
"resourcesCommonFilePaths": Array.from(resourcesCommonFilePaths),
|
||||
"resourcesFilePaths": Array.from(resourcesFilePaths)
|
||||
"resourcesCommonFilePaths": Array.from(resourcesCommonFilePaths)
|
||||
};
|
||||
}
|
||||
|
||||
/** Exported for testing purpose */
|
||||
export function readPaths(params: { rawSourceFile: string }): {
|
||||
resourcesCommonFilePaths: string[];
|
||||
resourcesFilePaths: string[];
|
||||
} {
|
||||
const { rawSourceFile } = params;
|
||||
|
||||
const resourcesCommonFilePaths = new Set<string>();
|
||||
const resourcesFilePaths = new Set<string>();
|
||||
|
||||
for (const isCommon of [true, false]) {
|
||||
const set = isCommon ? resourcesCommonFilePaths : resourcesFilePaths;
|
||||
|
||||
{
|
||||
const regexp = new RegExp(`resources${isCommon ? "Common" : ""}Path\\s*}([^\`]+)\``, "g");
|
||||
const regexp = new RegExp(`resourcesCommonPath\\s*}([^\`]+)\``, "g");
|
||||
|
||||
const matches = [...rawSourceFile.matchAll(regexp)];
|
||||
|
||||
for (const match of matches) {
|
||||
const filePath = match[1];
|
||||
|
||||
set.add(filePath);
|
||||
resourcesCommonFilePaths.add(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const regexp = new RegExp(`resources${isCommon ? "Common" : ""}Path\\s*[+,]\\s*["']([^"'\`]+)["'\`]`, "g");
|
||||
const regexp = new RegExp(`resourcesCommonPath\\s*[+,]\\s*["']([^"'\`]+)["'\`]`, "g");
|
||||
|
||||
const matches = [...rawSourceFile.matchAll(regexp)];
|
||||
|
||||
for (const match of matches) {
|
||||
const filePath = match[1];
|
||||
|
||||
set.add(filePath);
|
||||
}
|
||||
resourcesCommonFilePaths.add(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +71,6 @@ export function readPaths(params: { rawSourceFile: string }): {
|
||||
};
|
||||
|
||||
return {
|
||||
"resourcesCommonFilePaths": Array.from(resourcesCommonFilePaths).map(normalizePath),
|
||||
"resourcesFilePaths": Array.from(resourcesFilePaths).map(normalizePath)
|
||||
"resourcesCommonFilePaths": Array.from(resourcesCommonFilePaths).map(normalizePath)
|
||||
};
|
||||
}
|
||||
|
@ -9,8 +9,7 @@ describe("Ensure it's able to extract used Keycloak resources", () => {
|
||||
"node_modules/patternfly/dist/css/patternfly-additions.min.css",
|
||||
"lib/zocial/zocial.css",
|
||||
"node_modules/jquery/dist/jquery.min.js"
|
||||
],
|
||||
"resourcesFilePaths": ["css/login.css"]
|
||||
]
|
||||
};
|
||||
|
||||
it("works with coding style n°1", () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user