jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
7.94k stars 191 forks source link

The order of appearance of scripts in generated readme should have same order as defined in devbox.json #1991

Open ametad opened 3 months ago

ametad commented 3 months ago

What problem are you trying to solve?

The command devbox generate readme ignores the order of the scripts and re-orders it in the readme file to alphabetical order. I use the order explicitly for the humans who read it, so they have a clue what to do first.

Example of the problem

Scripts

The devbox.json with the scripts in a particular order:

{
  "shell": {
    "init_hook": [],
    "scripts": {
      "step-one": [
        "echo \"step-one\""
      ],
      "step-two": [
        "echo \"step-two\""
      ],
      "step-three": [
        "echo \"step-three\""
      ],
      "step-four": [
        "echo \"step-four\""
      ]
    }
  }
}

Generated README.md

This is the generated readme file created with devbox generate readme:

Scripts

Scripts are custom commands that can be run using this project's environment. This project has the following scripts:

Script Details

devbox run step-four

echo "step-four"

devbox run step-one

echo "step-one"

devbox run step-three

echo "step-three"

devbox run step-two

echo "step-two"

What solution would you like?

The generated Markdown in the README.md file should have the same order as in the devbox.json file, like so:

Scripts

Scripts are custom commands that can be run using this project's environment. This project has the following scripts:

Script Details

devbox run step-one

echo "step-one"

devbox run step-two

echo "step-two"

devbox run step-three

echo "step-three"

devbox run step-four

echo "step-four"

Alternatives you've considered

For now I prepend the script name with a number, but this is cumbersome for maintenance. Because when an extra step is requirement somewhere in between, the next script names also has to change. This is not great...

Example of alternative

{
  "shell": {
    "init_hook": [],
    "scripts": {
      "01-step-one": [
        "echo \"step-one\""
      ],
      "02-step-two": [
        "echo \"step-two\""
      ],
      "03-step-three": [
        "echo \"step-three\""
      ],
      "04-step-four": [
        "echo \"step-four\""
      ]
    }
  }
}

Generated README.md

Scripts

Scripts are custom commands that can be run using this project's environment. This project has the following scripts: