mirror of
https://github.com/ful1e5/Bibata_Cursor.git
synced 2025-05-29 06:15:24 -04:00
🌈 Schema generator
This commit is contained in:
parent
3f573c17c6
commit
656bb2bb0d
1 changed files with 22 additions and 10 deletions
|
@ -10,10 +10,11 @@ import {
|
||||||
staticCursors
|
staticCursors
|
||||||
} from "../config";
|
} from "../config";
|
||||||
import { ColorSchema, Config } from "../types";
|
import { ColorSchema, Config } from "../types";
|
||||||
|
import { writeSchemaData } from "./writeSchema";
|
||||||
|
|
||||||
// --------------------------------------- Generate Configs 🛠
|
// --------------------------------------- Generate Configs 🛠
|
||||||
|
|
||||||
const generateConfigs = (colorSchemes: ColorSchema, dirPrefix: string) => {
|
const generateConfigs = (colorSchemes: ColorSchema, themeName: string) => {
|
||||||
if (!fs.existsSync(rawSvgsDir)) {
|
if (!fs.existsSync(rawSvgsDir)) {
|
||||||
console.error(`🚨 .svg files not found in ${rawSvgsDir}`);
|
console.error(`🚨 .svg files not found in ${rawSvgsDir}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
@ -22,14 +23,14 @@ const generateConfigs = (colorSchemes: ColorSchema, dirPrefix: string) => {
|
||||||
const configs: Record<string, Config> = {};
|
const configs: Record<string, Config> = {};
|
||||||
|
|
||||||
for (let [schema] of Object.entries(colorSchemes)) {
|
for (let [schema] of Object.entries(colorSchemes)) {
|
||||||
const schemaName = `${dirPrefix}-${schema}`;
|
const schemaName = `${themeName}-${schema}`;
|
||||||
|
|
||||||
const schemaSvgsPath = path.resolve(schemesPath, schemaName);
|
const schemaSvgsPath = path.resolve(schemesPath, schemaName);
|
||||||
fs.mkdirSync(schemaSvgsPath, { recursive: true });
|
fs.mkdirSync(schemaSvgsPath, { recursive: true });
|
||||||
|
|
||||||
const { base, outline, watch } = colorSchemes[schema];
|
const { base, outline, watch } = colorSchemes[schema];
|
||||||
|
|
||||||
staticCursors.forEach((cursor: string) => {
|
const sCursors = staticCursors.map((cursor: string) => {
|
||||||
// Read file
|
// Read file
|
||||||
let content = fs.readFileSync(cursor, "utf-8").toString();
|
let content = fs.readFileSync(cursor, "utf-8").toString();
|
||||||
|
|
||||||
|
@ -38,11 +39,16 @@ const generateConfigs = (colorSchemes: ColorSchema, dirPrefix: string) => {
|
||||||
.replace(new RegExp(outlineKeyColor, "g"), outline);
|
.replace(new RegExp(outlineKeyColor, "g"), outline);
|
||||||
|
|
||||||
// Save Schema
|
// Save Schema
|
||||||
const cursorPath = path.resolve(schemaSvgsPath, "static", cursor);
|
const cursorPath = path.resolve(
|
||||||
fs.writeFileSync(cursorPath, content, "utf-8");
|
schemaSvgsPath,
|
||||||
|
"static",
|
||||||
|
path.basename(cursor)
|
||||||
|
);
|
||||||
|
writeSchemaData(cursorPath, content);
|
||||||
|
return cursorPath;
|
||||||
});
|
});
|
||||||
|
|
||||||
animatedCursors.forEach((cursor: string) => {
|
const aCursors = animatedCursors.map((cursor: string) => {
|
||||||
// Read file
|
// Read file
|
||||||
let content = fs
|
let content = fs
|
||||||
.readFileSync(path.resolve(rawSvgsDir, cursor), "utf-8")
|
.readFileSync(path.resolve(rawSvgsDir, cursor), "utf-8")
|
||||||
|
@ -67,8 +73,14 @@ const generateConfigs = (colorSchemes: ColorSchema, dirPrefix: string) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save Schema
|
// Save Schema
|
||||||
const cursorPath = path.resolve(schemaSvgsPath, "animated", cursor);
|
const cursorPath = path.resolve(
|
||||||
fs.writeFileSync(cursorPath, content, "utf-8");
|
schemaSvgsPath,
|
||||||
|
"animated",
|
||||||
|
path.basename(cursor)
|
||||||
|
);
|
||||||
|
writeSchemaData(cursorPath, content);
|
||||||
|
|
||||||
|
return cursorPath;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Creating Dir for store bitmaps
|
// Creating Dir for store bitmaps
|
||||||
|
@ -78,8 +90,8 @@ const generateConfigs = (colorSchemes: ColorSchema, dirPrefix: string) => {
|
||||||
// push config to Object
|
// push config to Object
|
||||||
configs[schema] = {
|
configs[schema] = {
|
||||||
bitmapsDir,
|
bitmapsDir,
|
||||||
animatedCursors,
|
animatedCursors: aCursors,
|
||||||
staticCursors
|
staticCursors: sCursors
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue