gererate diffrent comment depending on the file type
This commit is contained in:
parent
884195d30d
commit
8c99aa4b9d
@ -32,29 +32,37 @@ export async function getUiModuleFileSourceCodeReadyToBeCopied(params: {
|
|||||||
await fsPr.readFile(pathJoin(uiModuleDirPath, KEYCLOAK_THEME, fileRelativePath))
|
await fsPr.readFile(pathJoin(uiModuleDirPath, KEYCLOAK_THEME, fileRelativePath))
|
||||||
).toString("utf8");
|
).toString("utf8");
|
||||||
|
|
||||||
const comment = (() => {
|
const toComment = (lines: string[]) => {
|
||||||
if (isForEjection) {
|
for (const ext of [".ts", ".tsx", ".css", ".less", ".sass", ".js", ".jsx"]) {
|
||||||
return [
|
if (!fileRelativePath.endsWith(ext)) {
|
||||||
`/*`,
|
continue;
|
||||||
` * This file was ejected from ${uiModuleName} version ${uiModuleVersion}.`,
|
|
||||||
` */`
|
|
||||||
].join("\n");
|
|
||||||
} else {
|
|
||||||
return [
|
|
||||||
`/*`,
|
|
||||||
` *`,
|
|
||||||
` * WARNING: Before modifying this file run the following command:`,
|
|
||||||
` * `,
|
|
||||||
` * $ npx keycloakify eject-file --file ${fileRelativePath.split(pathSep).join("/")}`,
|
|
||||||
` * `,
|
|
||||||
` * This file comes from ${uiModuleName} version ${uiModuleVersion}.`,
|
|
||||||
` *`,
|
|
||||||
` */`
|
|
||||||
].join("\n");
|
|
||||||
}
|
}
|
||||||
})();
|
|
||||||
|
|
||||||
|
return [`/**`, ...lines.map(line => ` * ${line}`), ` */`].join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileRelativePath.endsWith(".html")) {
|
||||||
|
return [`<!--`, ...lines.map(line => ` ${line}`), `-->`].join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
const comment = toComment(
|
||||||
|
isForEjection
|
||||||
|
? [`This file was ejected from ${uiModuleName} version ${uiModuleVersion}.`]
|
||||||
|
: [
|
||||||
|
`WARNING: Before modifying this file run the following command:`,
|
||||||
|
``,
|
||||||
|
`$ npx keycloakify eject-file --file ${fileRelativePath.split(pathSep).join("/")}`,
|
||||||
|
``,
|
||||||
|
`This file comes from ${uiModuleName} version ${uiModuleVersion}.`
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (comment !== undefined) {
|
||||||
sourceCode = [comment, ``, sourceCode].join("\n");
|
sourceCode = [comment, ``, sourceCode].join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
const destFilePath = pathJoin(buildContext.themeSrcDirPath, fileRelativePath);
|
const destFilePath = pathJoin(buildContext.themeSrcDirPath, fileRelativePath);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user