build(repo): simplify generation
All checks were successful
Actions / Build Plugins (pull_request) Successful in 1m17s

This commit is contained in:
cswimr 2024-12-29 17:32:32 -05:00
parent 6b73a82819
commit 7341343534
Signed by: cswimr
GPG key ID: 0EC431A8DA8F8087
3 changed files with 41 additions and 4 deletions

30
generate.js Normal file
View file

@ -0,0 +1,30 @@
import { readdirSync, statSync, existsSync } from "fs";
import { join } from "path";
import { execSync } from "child_process";
import { fileURLToPath } from "url";
import path from "path";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const srcDir = join(__dirname, "src");
try {
const directories = readdirSync(srcDir).filter((file) =>
statSync(join(srcDir, file)).isDirectory()
);
directories.forEach((dir) => {
const generatorPath = join(srcDir, dir, "generator", "index.js");
if (existsSync(generatorPath)) {
console.log(`Running generator for ${dir}...`);
try {
execSync(`node "${generatorPath}"`, { stdio: "inherit" });
} catch (error) {
console.error(`Error running generator for ${dir}:`, error);
}
console.log(`Generator for ${dir} completed.`);
}
});
} catch (error) {
console.error("Error reading directories:", error);
}

View file

@ -7,10 +7,7 @@
"build": "yarn generate && gauntlet build",
"dev": "gauntlet dev",
"format": "eslint --fix .",
"generate": "yarn run generate:tailwindcss",
"generate:tailwindcss:css": "yarn dlx tailwindcss -i ./src/tailwindcss/generator/input.css -o ./assets/tailwindcss/generated/output.css",
"generate:tailwindcss:classes": "node ./src/tailwindcss/generator/index.js",
"generate:tailwindcss": "yarn run generate:tailwindcss:css && yarn run generate:tailwindcss:classes"
"generate": "node ./generate.js"
},
"dependencies": {
"@project-gauntlet/api": "0.12.0",

View file

@ -2,6 +2,16 @@ import fs from "fs";
import css from "css";
import path from "path";
import { fileURLToPath } from "url";
import { execSync } from "child_process";
try {
execSync(
"yarn dlx tailwindcss -i ./src/tailwindcss/generator/input.css -o ./assets/tailwindcss/generated/output.css",
{ stdio: "inherit" }
);
} catch (error) {
console.error("Error running tailwindcss: ", error);
}
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);