LeonBlade / xnbcli

A CLI tool for XNB packing/unpacking purpose built for Stardew Valley.
GNU General Public License v3.0
262 stars 75 forks source link

Minor issues on Linux #1

Closed MysticTempest closed 6 years ago

MysticTempest commented 6 years ago

Hi, I was just made aware of this tool; figured I'd give it a shot. It's definitely a nice alternative to using the Wine workaround.

But, I came across a few small issues while testing the v1.0.0 release for Linux.

Error 1. Line Feed/EOL error in the scripts: Example:

Aescylon-3:~/Downloads/xnbcli$ ./pack.sh
bash: ./pack.sh: /bin/bash^M: bad interpreter: No such file or directory"

Error 2. Scripts, and xnbcli binary are not executable.

Error 3. xnbcli can not create directories when packing files, causing a failure to repack the files if they were in sub-directories in the unpacked folder. However, it has no issue creating new directories when files are being unpacked.

Example packing with 2 Crops.json files. One under 'unpacked', the other in a sub-directory:

Aescylon-3:~/Downloads/xnbcli$ ./pack.sh 
[INFO] Reading file "unpacked/crops.json" ...
[INFO] Output file saved: packed/crops.xnb

[INFO] Reading file "unpacked/Content/TileSheets/crops.json" ...
[ERROR] Filename: unpacked/Content/TileSheets/crops.json
Error: ENOENT: no such file or directory, open 'packed/Content/TileSheets/crops.xnb'
    at Object.fs.openSync (fs.js:663:18)
    at Object.fs.openSync (pkg/prelude/bootstrap.js:483:32)
    at Object.fs.writeFileSync (fs.js:1314:33)
    at processPack (/snapshot/xnbcli/xnbcli.js:0:0)
    at Walker.walker.on (/snapshot/xnbcli/xnbcli.js:0:0)
    at Walker.emit (events.js:159:13)
    at Object.emitSingleEvents [as emitNodeType] (/snapshot/xnbcli/node_modules/walk/lib/node-type-emitter.js:55:13)
    at Walker._wLstatHandler (/snapshot/xnbcli/node_modules/walk/lib/walk.js:87:19)
    at /snapshot/xnbcli/node_modules/walk/lib/walk.js:105:12
    at FSReqWrap.oncomplete (fs.js:167:5)

Success 1
Fail 1

Error 4. xnbcli will not read .yaml files.


Suggested Fixes/Current Workarounds:

Assuming you're running Windows. You can probably use something like Notepad++ to convert the DOS EOL to a UNIX EOL. I know you can do so in Geany.

Same with setting, and preserving the executable bit for the files in the zip. Might need a Linux VM, or Cygwin/Windows Subystem for Linux to do those tasks; as I'm not quite sure if Windows has support for that.

What I personally did under Linux to fix my issues:

  1. Opened, Geany -> "Document" tab -> Set Line Endings -> Convert and Set to LF (Unix); then resaved. //Fix line endings.

  2. Ran in the terminal, chmod +x *.sh xnbcli //Set files to be executable.

  3. Ran in the terminal, cd ./unpacked && find . -type d -exec mkdir -p ../packed/{} \; && cd .. //If there's a directory structure in 'unpacked' recreate it in the 'packed' folder before repacking files.

  4. Inform users it'll only read .json data files when packing. I spent a bit trying to troubleshoot why it wouldn't pack my .yaml files. Eventually, I stopped trying to pack files, and instead tried to unpack some XNB files; that's when I noticed that it output .json files.

    So, any WIP mods in the .yaml format, or unpacked backup files will need to be repacked with XNBnode first; or converted to the same .json format before this tool can use them.

    Not too big of a deal for new modders using this as their first XNB packer/unpacker. But, definitely a good heads up for those who have used XNBnode in the past, and may have .yamls lying around.

Other then those few things; it seems to work great! Much appreciated!

LeonBlade commented 6 years ago

First off, thank you for the issue.

  1. The line endings is because I wrote the shell scripts on Windows at the time, I should have used vim under WSL but didn't think about it. I will fix this issue, thanks.

  2. I did set them to executable before packaging but it obviously didn't seem to work. I'll try again. Thanks.

  3. This should not be an issue but I may have made a mistake. I changed how the code walks through directories just before releasing to avoid a problem with the root directory in the output kept the "packed" or "unpacked" and decided to use walker instead. I'll look into this again to make sure I didn't forget anything.

  4. You're right, it doesn't support YAML files. I could support YAML but I don't like it which is why I don't support it. I will consider how to handle this problem. Since a majority of the files are data files, anyone who has changes would need to redo everything. So, supporting YAML in some way should be done. I'll add a pre-step to any packing process that converts YAML to JSON and include some sort of a message that their files will be converted.

Thank you again for creating this issue.