mirror of
https://github.com/ful1e5/Bibata_Cursor.git
synced 2025-05-23 03:26:58 -04:00
🚀 Schema Generator
This commit is contained in:
parent
bcecd39bd8
commit
64339a3ebc
1 changed files with 56 additions and 90 deletions
|
@ -24,44 +24,28 @@ const generateConfigs = (
|
||||||
const schemaSvgsPath = path.resolve(schemesPath, schemaName);
|
const schemaSvgsPath = path.resolve(schemesPath, schemaName);
|
||||||
fs.mkdirSync(schemaSvgsPath, { recursive: true });
|
fs.mkdirSync(schemaSvgsPath, { recursive: true });
|
||||||
|
|
||||||
generateStaticSchema(rawSvgsDir, customize, base, outline, schemaSvgsPath);
|
staticCursors.map((cursor: string) => {
|
||||||
|
// Read file
|
||||||
|
let content = fs
|
||||||
|
.readFileSync(path.resolve(rawSvgsDir, cursor), "utf-8")
|
||||||
|
.toString();
|
||||||
|
|
||||||
generateAnimatedSchema(rawSvgsDir, base, outline, watch, schemaSvgsPath);
|
// try => replace `customize` colors
|
||||||
|
// onError => replace `schema` main colors
|
||||||
// Creating Dir for store bitmaps
|
try {
|
||||||
const bitmapsDir = path.resolve(process.cwd(), "bitmaps", schemaName);
|
let { base: b, outline: o } = customize![cursor];
|
||||||
fs.mkdirSync(bitmapsDir, { recursive: true });
|
if (!b) b = base;
|
||||||
|
if (!o) o = outline;
|
||||||
// push config to Object
|
content = content.replace("#00FF00", b).replace("#0000FF", o);
|
||||||
configs[schema] = {
|
} catch (error) {
|
||||||
svgsDir: schemaSvgsPath,
|
content = content.replace("#00FF00", base).replace("#0000FF", outline);
|
||||||
bitmapsDir,
|
|
||||||
animatedCursors,
|
|
||||||
staticCursors,
|
|
||||||
animatedClip
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return configs;
|
// Save Schema
|
||||||
};
|
const cursorPath = path.resolve(schemaSvgsPath, cursor);
|
||||||
|
fs.writeFileSync(cursorPath, content, "utf-8");
|
||||||
|
});
|
||||||
|
|
||||||
export { generateConfigs };
|
|
||||||
|
|
||||||
function generateAnimatedSchema(
|
|
||||||
rawSvgsDir: string,
|
|
||||||
base: string,
|
|
||||||
outline: string,
|
|
||||||
watch:
|
|
||||||
| {
|
|
||||||
background: string;
|
|
||||||
color1: string;
|
|
||||||
color2: string;
|
|
||||||
color3: string;
|
|
||||||
color4: string;
|
|
||||||
}
|
|
||||||
| undefined,
|
|
||||||
schemaSvgsPath: string
|
|
||||||
) {
|
|
||||||
for (let [cursor] of Object.entries(animatedCursors)) {
|
for (let [cursor] of Object.entries(animatedCursors)) {
|
||||||
// Read file
|
// Read file
|
||||||
let content = fs
|
let content = fs
|
||||||
|
@ -71,6 +55,7 @@ function generateAnimatedSchema(
|
||||||
// Animated Cursors have two parts:
|
// Animated Cursors have two parts:
|
||||||
// 1) Cursor Color
|
// 1) Cursor Color
|
||||||
// 2) Watch Color
|
// 2) Watch Color
|
||||||
|
|
||||||
content = content.replace("#00FF00", base).replace("#0000FF", outline);
|
content = content.replace("#00FF00", base).replace("#0000FF", outline);
|
||||||
|
|
||||||
// try => replace `customize` colors
|
// try => replace `customize` colors
|
||||||
|
@ -96,41 +81,22 @@ function generateAnimatedSchema(
|
||||||
const cursorPath = path.resolve(schemaSvgsPath, cursor);
|
const cursorPath = path.resolve(schemaSvgsPath, cursor);
|
||||||
fs.writeFileSync(cursorPath, content, "utf-8");
|
fs.writeFileSync(cursorPath, content, "utf-8");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function generateStaticSchema(
|
// Creating Dir for store bitmaps
|
||||||
rawSvgsDir: string,
|
const bitmapsDir = path.resolve(process.cwd(), "bitmaps", schemaName);
|
||||||
customize:
|
fs.mkdirSync(bitmapsDir, { recursive: true });
|
||||||
| {
|
|
||||||
[name: string]: {
|
// push config to Object
|
||||||
outline?: string | undefined;
|
configs[schema] = {
|
||||||
base?: string | undefined;
|
svgsDir: schemaSvgsPath,
|
||||||
|
bitmapsDir,
|
||||||
|
animatedCursors,
|
||||||
|
staticCursors,
|
||||||
|
animatedClip
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
| undefined,
|
|
||||||
base: string,
|
|
||||||
outline: string,
|
|
||||||
schemaSvgsPath: string
|
|
||||||
) {
|
|
||||||
staticCursors.map((cursor: string) => {
|
|
||||||
// Read file
|
|
||||||
let content = fs
|
|
||||||
.readFileSync(path.resolve(rawSvgsDir, cursor), "utf-8")
|
|
||||||
.toString();
|
|
||||||
|
|
||||||
// try => replace `customize` colors
|
return configs;
|
||||||
// onError => replace `schema` main colors
|
};
|
||||||
try {
|
|
||||||
let { base: b, outline: o } = customize![cursor];
|
|
||||||
if (!b) b = base;
|
|
||||||
if (!o) o = outline;
|
|
||||||
content = content.replace("#00FF00", b).replace("#0000FF", o);
|
|
||||||
} catch (error) {
|
|
||||||
content = content.replace("#00FF00", base).replace("#0000FF", outline);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save Schema
|
export { generateConfigs };
|
||||||
const cursorPath = path.resolve(schemaSvgsPath, cursor);
|
|
||||||
fs.writeFileSync(cursorPath, content, "utf-8");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue