wowsims / cata

World of Warcraft Cataclysm Classic simulations.
https://wowsims.github.io/cata/
MIT License
20 stars 44 forks source link

Makefile edit for FreeBSD support #786

Closed dexxiez closed 2 weeks ago

dexxiez commented 3 weeks ago

Make file edit to check if there was a change on package.json and if the user is running FreeBSD. If they are it will use rollup instead of Vite due to incompatibilities. It will run npm install after to fix any lock file inconsistencies.

I chose jq instead of any build in util like sed etc because jq is structure aware instead of straight text find and replace.

addresses #586

1337LutZ commented 3 weeks ago

How will this revert the change when you want to commit? Or is it up to the user to not commit the changes?

dexxiez commented 3 weeks ago

How will this revert the change when you want to commit? Or is it up to the user to not commit the changes?

I was considering how to approach this, as within the issue where I put in git statements, I didn't know if it would be appropriate to put git related items in a makefile, bit I might be thinking too much into it, I don't know. Thoughts?

1337LutZ commented 3 weeks ago

The easiest solution would be to just keep track of the package.json when people create pull requests. I have had the idea for a while to add Husky for git hooks which could tackle that. However would prefer some more time to set it up.

1337LutZ commented 3 weeks ago

@dexxiez Actually another one could be creating a test in the test github action that just checks if the package.json contains the wasm override and let it fail

dexxiez commented 3 weeks ago

@dexxiez Actually another one could be creating a test in the test script that just checks if the package.json contains the wasm override and let it fail

Smart. ill have a squiz. one sec

MikeJakubik commented 2 weeks ago

This is great, the cherry on the top would be to not rely on jq however, but something more standard (i.e. sed, awk, etc.). Jq is not part of a FreeBSD install, but it is available as a port/pkg.

However, I understand you want to work with more parsable data types, FreeBSD does have a neat feature as part of its base install, and that is libxo. Many commands support it directly or you can use the xo command to work with data structures such as XML, Json, or HTML. I'm curious if this would be usable here, but if you have a working solution and no time then it's OK, just thought it would be neat to share this info.

libxo (man page)

xo (command man page)

Here are some neat examples

[root@fbsd14 ~]# wc --libxo json,pretty,warn /etc/motd
{
  "wc": {
    "file": [
      {
        "lines": 21,
        "words": 97,
        "characters": 900,
        "filename": "/etc/motd"
      }
    ]
  }
}

[root@fbsd14 ~]# ps auxw -U _dhcp --libxo json,pretty,warn
{
  "process-information": {
    "process": [
      {
        "user": "_dhcp",
        "pid": "1886",
        "percent-cpu": "0.0",
        "percent-memory": "0.0",
        "virtual-size": "13304",
        "rss": "2960",
        "terminal-name": "- ",
        "state": "ICs",
        "start-time": "22:31  ",
        "cpu-time": "0:00.00",
        "command": "dhclient: wlan0 (dhclient)"
      }
    ]
  }
}

In a scripted environment

#!/bin/sh
xo --pretty --style json --top-wrap --open hello/user '{:name} {:date}' "$(whoami)" "$(date +%H:%M:%S)"
xo --pretty --style json --top-wrap --close hello/user
[root@fbsd14 ~]# sh hello.sh 
{
  "hello": {
    "user": {
      "name": "root",
      "date": "22:30:06"
    }
  }
}
dexxiez commented 2 weeks ago

This is great, the cherry on the top would be to not rely on jq however, but something more standard (i.e. sed, awk, etc.). Jq is not part of a FreeBSD install, but it is available as a port/pkg.

However, I understand you want to work with more parsable data types, FreeBSD does have a neat feature as part of its base install, and that is libxo. Many commands support it directly or you can use the xo command to work with data structures such as XML, Json, or HTML. I'm curious if this would be usable here, but if you have a working solution and no time then it's OK, just thought it would be neat to share this info.

libxo (man page)

xo (command man page)

Here are some neat examples

[root@fbsd14 ~]# wc --libxo json,pretty,warn /etc/motd
{
  "wc": {
    "file": [
      {
        "lines": 21,
        "words": 97,
        "characters": 900,
        "filename": "/etc/motd"
      }
    ]
  }
}

[root@fbsd14 ~]# ps auxw -U _dhcp --libxo json,pretty,warn
{
  "process-information": {
    "process": [
      {
        "user": "_dhcp",
        "pid": "1886",
        "percent-cpu": "0.0",
        "percent-memory": "0.0",
        "virtual-size": "13304",
        "rss": "2960",
        "terminal-name": "- ",
        "state": "ICs",
        "start-time": "22:31  ",
        "cpu-time": "0:00.00",
        "command": "dhclient: wlan0 (dhclient)"
      }
    ]
  }
}

In a scripted environment

#!/bin/sh
xo --pretty --style json --top-wrap --open hello/user '{:name} {:date}' "$(whoami)" "$(date +%H:%M:%S)"
xo --pretty --style json --top-wrap --close hello/user
[root@fbsd14 ~]# sh hello.sh 
{
  "hello": {
    "user": {
      "name": "root",
      "date": "22:30:06"
    }
  }
}

I've had a look, and it looks like there isn't much parsing functionality in xo. It seems to be more 1 way which is out (emitting), so you use their syntax to emit other formats, JSON being one of them. So sadly I don't think it can be used easily in this context.