-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat: add categories
and categories:create
#530
Conversation
@erunion updates complete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @garrett-wade! I have a few overarching questions about approach on the create
command below. Would love your feedback as a user of this tool!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the context @garrett-wade! I think the example makes sense and I can see title-uniqueness checks being useful. Could you make the following changes:
-
Could you refactor your partial-slug matching to do exact title-matching instead? Partial slug matching may incur some weird false positives and title-matching seems more robust.
-
Could you wrap the aforementioned matching logic in a flag called
preventDuplicateTitles
? In general I think the default behavior should follow the behavior of our API and the dashboard, but this way users can opt-in to ensuring that titles are unique. -
Can you merge the
main
branch into this branch and re-runnpm install
with at leastnpm@7
and update the lockfile? It appears tests are still failing.
- Wrap matching logic in `preventDuplicates` flag - Update test coverage to reflect changes - Update README to reflect changes
@kanadgupta Agree with the title matching change, thanks for the feedback! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making those suggested changes @garrett-wade! Some more comments below:
} | ||
|
||
async function createCategory() { | ||
if (preventDuplicates) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this boolean check up so it wraps all of this logic? In other words, we shouldn't need to fetch the category list at all if preventDuplicates
is set to false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you still working on this? This comment got marked as resolved but it's still applicable so I'm going to unresolve it! Just to reiterate, the getNumberOfPages
and matchCategory
functions should not be running at all if preventDuplicates
is set to false.
Co-authored-by: Kanad Gupta <[email protected]>
} | ||
|
||
async function createCategory() { | ||
if (preventDuplicates) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you still working on this? This comment got marked as resolved but it's still applicable so I'm going to unresolve it! Just to reiterate, the getNumberOfPages
and matchCategory
functions should not be running at all if preventDuplicates
is set to false.
@kanadgupta updated based on requests above, for |
The initial version of this was making a duplicate call for the first page of categories. This refactors it so it uses the initial call to both grab the count and the first page of results. I also extracted this logic and put it in a shared lib function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on this @garrett-wade! I added a few commits where I reverted the package* file changes, consolidated and refactored some logic, and made some small copy edits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for all the work on this
@erunion @kanadgupta Thanks for all the collaboration and feedback on this. Learned a lot and enjoy working with both of you! |
🧰 Changes
Added support for two new commands
categories
andcategories:create
.categories
returns a raw json of all categories for a version including pagination.categories:create
allows you to create a new category with a specifiedtitle
andtype
for your project version. Thetitle
will be converted to a slug in param case. If a category already exists with the same slug and type forthe specified version then a new category is not created and the id of the existing category is returned. This includes if the slug contains incremented suffix such as
-1
or-2
. If there are multiple categories with a matching slug and type then only one matching category is returned.🧬 QA & Testing
categories
rdme login
rdme categories
categories:create
rdme login
rdme categories:create "test title" --categoryType guide
and see a new category was created with a slug oftest-title
rdme categories:create "test title" --categoryType guide
and see a new category was not created but rather it returns the slug and id of the category created in the previous step.rdme categories:create "test title" --categoryType reference
and see a new category was created with a slug oftest-title-1
rdme categories:create "test title" --categoryType reference
and see a new category was not created but rather it returns the slug and id of the category created in the previous step.rdme categories:create "test title"
and see acategoryType
of "guide" or "reference" is required