Explicitely prohibit space and special character in theme names
This commit is contained in:
parent
04307c8226
commit
802a6ab5ec
@ -469,26 +469,44 @@ export function getBuildContext(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const themeNames = ((): [string, ...string[]] => {
|
const themeNames = ((): [string, ...string[]] => {
|
||||||
if (buildOptions.themeName === undefined) {
|
const themeNames = ((): [string, ...string[]] => {
|
||||||
return parsedPackageJson.name === undefined
|
if (buildOptions.themeName === undefined) {
|
||||||
? ["keycloakify"]
|
return parsedPackageJson.name === undefined
|
||||||
: [
|
? ["keycloakify"]
|
||||||
parsedPackageJson.name
|
: [
|
||||||
.replace(/^@(.*)/, "$1")
|
parsedPackageJson.name
|
||||||
.split("/")
|
.replace(/^@(.*)/, "$1")
|
||||||
.join("-")
|
.split("/")
|
||||||
];
|
.join("-")
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof buildOptions.themeName === "string") {
|
||||||
|
return [buildOptions.themeName];
|
||||||
|
}
|
||||||
|
|
||||||
|
const [mainThemeName, ...themeVariantNames] = buildOptions.themeName;
|
||||||
|
|
||||||
|
assert(mainThemeName !== undefined);
|
||||||
|
|
||||||
|
return [mainThemeName, ...themeVariantNames];
|
||||||
|
})();
|
||||||
|
|
||||||
|
for (const themeName of themeNames) {
|
||||||
|
if (!/^[a-zA-Z0-9_-]+$/.test(themeName)) {
|
||||||
|
console.error(
|
||||||
|
chalk.red(
|
||||||
|
[
|
||||||
|
`Invalid theme name: ${themeName}`,
|
||||||
|
`Theme names should only contain letters, numbers, and "_" or "-"`
|
||||||
|
].join(" ")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
process.exit(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof buildOptions.themeName === "string") {
|
return themeNames;
|
||||||
return [buildOptions.themeName];
|
|
||||||
}
|
|
||||||
|
|
||||||
const [mainThemeName, ...themeVariantNames] = buildOptions.themeName;
|
|
||||||
|
|
||||||
assert(mainThemeName !== undefined);
|
|
||||||
|
|
||||||
return [mainThemeName, ...themeVariantNames];
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const projectBuildDirPath = (() => {
|
const projectBuildDirPath = (() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user