pkgxdev / pkgx

the last thing you’ll install
https://pkgx.sh
Apache License 2.0
8.81k stars 1.36k forks source link

Where is markdown blocks execition engine? #1015

Closed abitrolly closed 1 week ago

abitrolly commented 1 week ago

I remember there was a piece of code that executed and probably updated markdown blocks. Is it still available somewhere? Would like to reuse it for some troubleshooting. Tired of pasting code blocks in dead documents that need to be updated when new versions of tools inside released.

dosubot[bot] commented 1 week ago

Hey @abitrolly! I'm here to help you with any issues or questions you have. I can assist with bug fixes, answer your queries, and guide you on becoming a contributor. Let me know how I can assist you!

I couldn't find any information about the markdown blocks execution engine in the repository. It seems there are no references to it in the documentation, commit messages, or issue tracker .

To continue talking to Dosu, mention @dosu.

jhheider commented 1 week ago

Are you looking for xcfile.dev?

abitrolly commented 1 week ago

@jhheider thanks, but it looks like it is meant to run tasks, and doesn't update the output in markdown files (need deeper checks). I remember this repo used to run the script that updated and/or validated command output.

jhheider commented 1 week ago

Hm, I'm not sure what that would be. We have task runners like xc and just and, of course, make, packages. And stuff link amber-lang, shellcheck and other tools to make scripting reliable. But I don't specifically know of a tool for updating and validating scripts. pier might be the closest, but I don't think it's what you're looking for.

abitrolly commented 1 week ago

I knew it, but lost. I think it was used for unit testing or something. Got this so far.

Where is this pier?

jhheider commented 1 week ago

https://github.com/pkgxdev/pantry/blob/main/projects/crates.io/pier/package.yml

abitrolly commented 1 week ago

Yea, organizing shell snippets is a bit different task.

abitrolly commented 1 week ago

Found something extracted from Go internals https://github.com/rogpeppe/go-internal/tree/master/cmd/testscript

abitrolly commented 1 week ago

Found two other project that execute test files combining commands with expected output.

I packed testscript for Homebrew. Now I need to see what it takes for pkgx to run it.

jhheider commented 1 week ago

very little; i should be able to do it today.

abitrolly commented 1 week ago
test:
  - run: test "$(testscript $FIXTURE)" = "PASS"
    fixture:
      extname: txtar
      contents: |
        exec echo hello!
        stdout hello!

Maybe pkgx should adopt txtar format too. :D

testscript: |
  exec testscript hello.txtar
  stdout PASS

  -- hello.txtar --
  exec echo hello!
  stdout hello!
jhheider commented 1 week ago

there's an even simpler solution:

interprets:
  extensions: txtar
  args: testscript

test:
  dependencies:
    pkgx.sh: 1
  script:
    - run: test "$(pkgx $FIXTURE)" = "PASS"
      fixture:
        extname: txtar
        contents: |
          exec echo hello!
          stdout hello!
abitrolly commented 1 week ago

there's an even simpler solution:

Not sure why. The code got some additional lines, and it is not clear what they do.

jhheider commented 1 week ago

because now pkgx can execute txtar scripts directly. That's what the interprets: block enables.