Move over data scripts from crafting-guide
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
# Crafting Guide Data
|
||||
|
||||
This repository contains all the data files and images for the mods supported by [Crafting Guide](https://github.com/andrewminer/crafting-guide).
|
||||
This repository contains all the data files and images for the mods supported by [Crafting Guide](https://github.com/andrewminer/crafting-guide). Despite being set up as an NPM module, there is no code here, just data files.
|
||||
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
read -d '' USAGE <<END
|
||||
USAGE: convert-nei-dump <source> <mod_slug> <mod_version>
|
||||
|
||||
Converts output from NEI dump files into a format which can be used by
|
||||
Crafting Guide. In particlar, this script looks for the "Item Panel" dump
|
||||
both in PNG and CSV formats and assumes they contain all the data for the
|
||||
target mod.
|
||||
|
||||
Unfortunate, NEI doesn't generate enough information to fill in all the
|
||||
recipes for each item: only their names. Once this script has converted the
|
||||
data, you will need to manually enter the missing content.
|
||||
|
||||
<source> : the "dumps" directory where NEI dropped its content
|
||||
<mod_slug> : the slug of the mod being converted
|
||||
<mod_version> : the version of the mod being converted
|
||||
END
|
||||
|
||||
|
||||
SOURCE_DIR="$1"; shift
|
||||
MOD_SLUG="$1"; shift
|
||||
MOD_VERSION="$1"; shift
|
||||
|
||||
mkdir -p "./data/$MOD_SLUG/versions/$MOD_VERSION"
|
||||
DATA_FILE="./data/$MOD_SLUG/versions/$MOD_VERSION/mod-version.cg"
|
||||
touch "$DATA_FILE"
|
||||
|
||||
if [[ "$SOURCE_DIR" == "" || "$MOD_SLUG" == "" || "$MOD_VERSION" == "" ]]; then
|
||||
echo "$USAGE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "./static/browse/$MOD_SLUG/images"
|
||||
ls $SOURCE_DIR/itempanel_icons | while read FILE; do
|
||||
ITEM_NAME="$(echo $FILE | sed 's/.png//')"
|
||||
ITEM_SLUG="$(echo $ITEM_NAME \
|
||||
| sed 's/[^a-zA-Z0-9]/_/g' \
|
||||
| sed 's/__*/_/g' \
|
||||
| sed 's/^_//' \
|
||||
| sed 's/_$//' \
|
||||
| tr '[A-Z]' '[a-z]' \
|
||||
)"
|
||||
mkdir -p "./data/$MOD_SLUG/items/$ITEM_SLUG"
|
||||
cp "$SOURCE_DIR/itempanel_icons/$FILE" "./data/$MOD_SLUG/items/$ITEM_SLUG/icon.png"
|
||||
if ! grep -q "item: $ITEM_NAME$" $DATA_FILE; then
|
||||
echo "item: $ITEM_NAME" >> $DATA_FILE
|
||||
echo "" >> $DATA_FILE
|
||||
fi
|
||||
done
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env coffee
|
||||
|
||||
fs = require 'fs'
|
||||
{Logger} = require 'crafting-guide-common'
|
||||
{ModVersionParser} = require 'crafting-guide'
|
||||
{ModVersion} = require 'crafting-guide'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
if process.argv.length is 3
|
||||
sourceFileName = process.argv[2]
|
||||
targetFileName = process.argv[2]
|
||||
else if process.argv.length is 4
|
||||
sourceFileName = process.argv[2]
|
||||
targetFileName = process.argv[3]
|
||||
else
|
||||
console.error """
|
||||
|
||||
USAGE: reformat <source> (<target>)
|
||||
|
||||
Reformats a given recipe book into the latest version of the recipe book
|
||||
format. This includes alphabetizing entries, simplifying item lists, and
|
||||
upgrading to the latest version.
|
||||
|
||||
If given a single argument, the named file will be replaced with the
|
||||
reformatted version. If two arguments are given, then the output will be
|
||||
written to the second file. If a "-" is given as the second file, the
|
||||
output will be written to stdout.
|
||||
|
||||
"""
|
||||
process.exit -1
|
||||
|
||||
global.logger = new Logger level:Logger.WARNING
|
||||
|
||||
try
|
||||
text = fs.readFileSync sourceFileName, 'UTF-8'
|
||||
parser = new ModVersionParser model:new ModVersion modSlug:'', version:''
|
||||
modVersion = parser.parse text
|
||||
text = parser.unparse(modVersion).trim().replace(/^\s\s*$/gm, '')
|
||||
|
||||
if targetFileName is '-'
|
||||
console.log text
|
||||
else
|
||||
fs.writeFileSync targetFileName, text, encoding:'UTF-8'
|
||||
catch e
|
||||
console.error e.stack
|
||||
Reference in New Issue
Block a user