Skip to content

Commit e226226

Browse files
committed
first shot at generation script and standardizing blast furnace data
1 parent 51fd362 commit e226226

File tree

81 files changed

+133
-80
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+133
-80
lines changed

scripts/generate.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// file: build-recipes.mjs
2+
import fs from "fs/promises";
3+
import path from "path";
4+
5+
(async function init() {
6+
const recipesDir = path.join(process.cwd(), "static", "recipe");
7+
const outputFile = path.join(process.cwd(), "static", "processed_recipes.json");
8+
9+
const filter = (data) => {
10+
// i'm not using this _internal filterable prop, but gosh if it doesn't seem like a cool idea
11+
const { _internal, ...cleaned } = data;
12+
13+
return cleaned;
14+
};
15+
16+
async function readRecipes(dir) {
17+
const entries = await fs.readdir(dir, { withFileTypes: true });
18+
const tree = {};
19+
20+
for (const entry of entries) {
21+
const fullPath = path.join(dir, entry.name);
22+
23+
if (entry.isDirectory()) {
24+
const subtree = await readRecipes(fullPath);
25+
26+
if (Object.keys(subtree).length) {
27+
tree[entry.name] = subtree;
28+
}
29+
} else if (entry.isFile() && path.extname(entry.name) === ".json") {
30+
const raw = await fs.readFile(fullPath, "utf8");
31+
let json;
32+
33+
try {
34+
json = JSON.parse(raw);
35+
} catch (err) {
36+
console.error(`⚠️ Skipping ${fullPath}: invalid JSON`);
37+
continue;
38+
}
39+
40+
const filtered = filter(json);
41+
const key = path.basename(entry.name, ".json");
42+
tree[key] = filtered;
43+
}
44+
}
45+
46+
return tree;
47+
}
48+
49+
const recipes = await readRecipes(recipesDir);
50+
51+
await fs.writeFile(outputFile, JSON.stringify(recipes, null, 2), "utf8");
52+
console.log(`✅ Filtered recipes written to ${outputFile}`);
53+
})();

static/recipe/blast_furnace/aluminum_ingot.json renamed to static/recipe/industrial_blast_furnace/aluminum_ingot.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"type": "techreborn:blast_furnace",
2+
"type": "techreborn:industrial_blast_furnace",
33
"heat": 1700,
44
"ingredients": [
55
{

static/recipe/blast_furnace/angler_pottery_sherd.json renamed to static/recipe/industrial_blast_furnace/angler_pottery_sherd.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"type": "techreborn:blast_furnace",
2+
"type": "techreborn:industrial_blast_furnace",
33
"heat": 1000,
44
"ingredients": [
55
{

static/recipe/blast_furnace/archer_pottery_sherd.json renamed to static/recipe/industrial_blast_furnace/archer_pottery_sherd.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"type": "techreborn:blast_furnace",
2+
"type": "techreborn:industrial_blast_furnace",
33
"heat": 1000,
44
"ingredients": [
55
{

static/recipe/blast_furnace/arms_up_pottery_sherd.json renamed to static/recipe/industrial_blast_furnace/arms_up_pottery_sherd.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"type": "techreborn:blast_furnace",
2+
"type": "techreborn:industrial_blast_furnace",
33
"heat": 1000,
44
"ingredients": [
55
{

static/recipe/blast_furnace/blackstone.json renamed to static/recipe/industrial_blast_furnace/blackstone.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"type": "techreborn:blast_furnace",
2+
"type": "techreborn:industrial_blast_furnace",
33
"heat": 3000,
44
"ingredients": [
55
{

static/recipe/blast_furnace/blade_pottery_sherd.json renamed to static/recipe/industrial_blast_furnace/blade_pottery_sherd.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"type": "techreborn:blast_furnace",
2+
"type": "techreborn:industrial_blast_furnace",
33
"heat": 1000,
44
"ingredients": [
55
{

static/recipe/blast_furnace/brewer_pottery_sherd.json renamed to static/recipe/industrial_blast_furnace/brewer_pottery_sherd.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"type": "techreborn:blast_furnace",
2+
"type": "techreborn:industrial_blast_furnace",
33
"heat": 1000,
44
"ingredients": [
55
{

static/recipe/blast_furnace/bronze_ingot_from_axe.json renamed to static/recipe/industrial_blast_furnace/bronze_ingot_from_axe.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"type": "techreborn:blast_furnace",
2+
"type": "techreborn:industrial_blast_furnace",
33
"heat": 1000,
44
"ingredients": [
55
{

static/recipe/blast_furnace/bronze_ingot_from_boots.json renamed to static/recipe/industrial_blast_furnace/bronze_ingot_from_boots.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"type": "techreborn:blast_furnace",
2+
"type": "techreborn:industrial_blast_furnace",
33
"heat": 1000,
44
"ingredients": [
55
{

0 commit comments

Comments
 (0)