caderek / aocrunner

Advent of Code runner
ISC License
163 stars 23 forks source link

feat: add `update:readme` command #14

Closed teofanis closed 1 year ago

teofanis commented 1 year ago

Why this PR? I followed the docs and configured the starting template and started solving day 1 of advent of code. I misused the template and on my first solution I copied the answer from the console and pasted it directly in AoC website.

The answer was correct, but unfortunately, I was no-longer able to send my answers for part 2 using the "send" command as the script will return the following Status and exit.

image

I also read the note about automated requests and understand the risks/reason behind the implementation.

I do, however miss the feature to automatically update the day badges on the readme file, so here's the proposal.

The npm run update:readme command exposes the existing updateReadMe() function thats uses the .aocrunner.json to generate the badges.

Let me know of your thoughts :)

caderek commented 1 year ago

So if I understand it correctly:

Your solution is ok, but I would prefer to not complicate package.json, when that action can be performed interactively via command in the runner itself. If that's ok I will add it, it will be a change in one file.

Btw, even without additional command, if you fix the .aocrunner.json, the README would be updated (including previous days) when you send your solution for the next puzzle.

teofanis commented 1 year ago

So if I understand it correctly:

  • you sent the answer manually,
  • you updated .aocrunner.json manually with your answer (?), if not you can do this by changing solved field to true, and result to your solution for that specific day and part.
  • you want to be able to trigger README update that currently runs only after successful send command.

Your solution is ok, but I would prefer to not complicate package.json, when that action can be performed interactively via command in the runner itself. If that's ok I will add it, it will be a change in one file.

Btw, even without additional command, if you fix the .aocrunner.json, the README would be updated (including previous days) when you send your solution for the next puzzle.

Yes, that's correct.

I like the idea of having the option interactively, but I also like the flexibility of being able to perform this via the script, without needing to start the runner. For example in a pre-push/pre-commit hook.

Again it's up to you to take the decision, I'm just giving my opinion :).

caderek commented 1 year ago

I also like the flexibility of being able to perform this via the script, without needing to start the runner.

You convinced me, looks good.

Edit:

While this will add the command to the package.json for all new projects, for current project just run npx aocrunner update:readme or add "update:readme": "aocrunner update:readme" to your existing package.json manually.