Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Allow generated output to be placed relative to other rules #343

Closed
alexlo03 opened this issue Mar 14, 2023 · 2 comments · Fixed by #347
Closed

[FEATURE] Allow generated output to be placed relative to other rules #343

alexlo03 opened this issue Mar 14, 2023 · 2 comments · Fixed by #347
Labels
enhancement New feature or request

Comments

@alexlo03
Copy link

alexlo03 commented Mar 14, 2023

Is your feature request related to a problem? Please describe.
I am unable to get the CODEOWNERS output to be ordered. Since order determines rule precedence, it is something I need in order to use this solution. For example I may have a super rule that is like **/special.yaml is only editable by maintainers no matter where it is in the repo. I can do this by putting it at the bottom of the CODEOWNERS file.

Describe the solution you'd like
Presently the codeowners-generator wants to put its output at the BOTTOM of the CODEOWNERS file. I would like it to look for "# GENERATE_CODEOWNERS_HERE" and place the block there if it exists.

I would place that token in the middle of my existing CODEOWNERS file, because the bottom rules are important and need to take precedence.

Describe alternatives you've considered
I may be able to do this with the "run after" script, but it seems possible to do this as a first class feature.

Additional context
Maybe I missed a better way to do this? If so, apologies!

@alexlo03 alexlo03 added the enhancement New feature or request label Mar 14, 2023
@alexlo03 alexlo03 changed the title [FEATURE] [FEATURE] Allow generated output to be placed relative to other rules Mar 14, 2023
@gagoar
Copy link
Owner

gagoar commented Mar 14, 2023

thank you @alexlo03 for your request!

Sounds very doable actually. To summarize:
add an option to keep the block where it starts (and is in the file already).

That's something we can do. I will have to add an option like preserve-position or something like that.

@gagoar gagoar mentioned this issue Mar 19, 2023
3 tasks
@gagoar
Copy link
Owner

gagoar commented Mar 20, 2023

Just an update: I've finished the implementation here. I'm waiting for @gustavkj second pair of eyes. Feel free to review if Ts is your thing!

gagoar added a commit that referenced this issue Mar 22, 2023
## Description

This PR adds a new option to preserve the position of the generated
block if the user so desires. this is helpful when there's certain
strict order the developer wants to keep. Normally because there are
manual entries.

This closes #343 

Missing:

- [x] CLI option
- [x] Documentation
- [x] Logic Refactor (because it looks ugly what I did)

Extra:

So I was playing with ChatGPT, and I decided to ask for rewrites on my
code the changes are not that bad. So I left them in
@gagoar gagoar mentioned this issue Mar 22, 2023
gagoar added a commit that referenced this issue Mar 23, 2023
Bumping version 2.2.0
That comes with:
- Preserve block position
[`#347`](#347)
- ChatGPT rewrote it
[`#349`](#349)
- Using swc instead of ts-jest
[`#348`](#348)
- Update Node.js to v16.19.1
[`#341`](#341)
- Update dependency husky to v8.0.3
[`#339`](#339)
- adding composite action to use codeowners-generator in a workflow
[`#337`](#337)
- 2.1.5
[`#346`](#346)
- Preserve block position (#347)
[`#343`](#343)
- adding composite action to use codeowners-generator in a workflow
(#337)
[`#335`](#335)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants