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

Add add-icon-data script #7849

Merged
merged 23 commits into from Sep 25, 2022
Merged

Conversation

LitoMore
Copy link
Member

@LitoMore LitoMore commented Sep 23, 2022

Resolves #7848

I used a simple localeCompare on titles. So it's valid when we add simple icons (the lowercase). I may need to check the duplication of their slugs. Seems our-lint has the same issue.

Overview

Command

npm run add-icon-data

Prompts

field validation
title Not empty The title should be unique Its slug should be unique
hex /^#?[a-f0-9]{3,8}$/i
source /^https:\/\/[^\s]+$/

The confirm prompt is inspired by npm init command.

Preview

CleanShot 2022-09-24 at 23 54 59@2x

@LitoMore LitoMore added the meta Issues or pull requests regarding the project or repository itself label Sep 23, 2022
@LitoMore LitoMore changed the title Add add-icon script [WIP] Add add-icon script Sep 23, 2022
@LitoMore LitoMore requested a review from a team September 23, 2022 03:59
@LitoMore LitoMore marked this pull request as ready for review September 23, 2022 04:02
@LitoMore
Copy link
Member Author

I don't have a good idea to implement the UX for aliases. Any ideas?

@LitoMore LitoMore changed the title [WIP] Add add-icon script Add add-icon script Sep 23, 2022
Copy link
Member

@mondeja mondeja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this 👍🏼

I think that the current implementation solves mainly the problem of the ordering in the data file. It does not validate so many things. Additionally, add-icon is really confusing, should be renamed to add-icon-data as the script is not adding an icon, only their object to the data file?

Also, I think that we should standarize the assertions done to our data in tests and reuse them in other parts of the project like this script, but that could be in a separate PR.

scripts/add-icon.js Outdated Show resolved Hide resolved
scripts/add-icon.js Outdated Show resolved Hide resolved
scripts/add-icon.js Outdated Show resolved Hide resolved
scripts/add-icon.js Outdated Show resolved Hide resolved
scripts/add-icon.js Outdated Show resolved Hide resolved
scripts/add-icon.js Outdated Show resolved Hide resolved
scripts/add-icon.js Outdated Show resolved Hide resolved
scripts/add-icon.js Outdated Show resolved Hide resolved
scripts/add-icon.js Outdated Show resolved Hide resolved
Copy link
Member

@mondeja mondeja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you're adding a terminal color formatting library we can replace the unicode characters used in scripts/lint/ourlint.js:

errors.forEach((error) => console.error(`\u001b[31m${error}\u001b[0m`));

@mondeja
Copy link
Member

mondeja commented Sep 23, 2022

Related: #7850 and #7851

@LitoMore LitoMore changed the title Add add-icon script Add add-icon-data script Sep 23, 2022
@LitoMore
Copy link
Member Author

Waiting for #7854 (the locale comparison) and #7855 (the URL regex) to merge.

scripts/add-icon-data.js Outdated Show resolved Hide resolved
Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com>
@mondeja
Copy link
Member

mondeja commented Sep 24, 2022

Are you planning to add the rest of the fields @LitoMore?

@LitoMore
Copy link
Member Author

Are you planning to add the rest of the fields? (@mondeja)

Let me try.

scripts/utils.js Outdated Show resolved Hide resolved
scripts/add-icon-data.js Outdated Show resolved Hide resolved
Copy link
Member

@mondeja mondeja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done a couple of changes. Now looks good to me 🌠

Can be improved in the future though, feel free to merge it!

@LitoMore LitoMore merged commit 5958fc1 into simple-icons:develop Sep 25, 2022
@LitoMore LitoMore deleted the script-for-add-icon branch September 25, 2022 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta Issues or pull requests regarding the project or repository itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a script for filling the JSON file
2 participants