1
0
mirror of https://github.com/konpa/devicon.git synced 2025-08-06 14:46:46 +02:00

Revert "Revert "Fix a couple issues found in the build script""

This commit is contained in:
Clemens Bastian
2020-12-12 04:41:25 +01:00
committed by GitHub
parent 6cc0eba1ac
commit 7bf127d498
10 changed files with 160 additions and 189 deletions

View File

@@ -75,14 +75,12 @@ class SeleniumRunner:
self.driver = WebDriver(options=options, executable_path=geckodriver_path) self.driver = WebDriver(options=options, executable_path=geckodriver_path)
self.driver.get(self.ICOMOON_URL) self.driver.get(self.ICOMOON_URL)
assert "IcoMoon App" in self.driver.title assert "IcoMoon App" in self.driver.title
# wait until the whole web page is loaded by testing the hamburger input # wait until the whole web page is loaded by testing the hamburger input
hamburger_input = WebDriverWait(self.driver, SeleniumRunner.LONG_WAIT_IN_SEC).until( WebDriverWait(self.driver, self.LONG_WAIT_IN_SEC).until(
ec.element_to_be_clickable((By.CSS_SELECTOR, ec.element_to_be_clickable((By.XPATH, "(//i[@class='icon-menu'])[2]"))
"button.btn5.lh-def.transparent i.icon-menu"))
) )
hamburger_input.click()
print("Accessed icomoon.io") print("Accessed icomoon.io")
def upload_icomoon(self, icomoon_json_path: str): def upload_icomoon(self, icomoon_json_path: str):
""" """
@@ -92,11 +90,16 @@ class SeleniumRunner:
""" """
print("Uploading icomoon.json file...") print("Uploading icomoon.json file...")
try: try:
self.click_hamburger_input()
# find the file input and enter the file path # find the file input and enter the file path
import_btn = WebDriverWait(self.driver, SeleniumRunner.LONG_WAIT_IN_SEC).until( import_btn = self.driver.find_element(By.XPATH, "(//li[@class='file'])[1]//input")
ec.element_to_be_clickable((By.CSS_SELECTOR, "div#file input"))
)
import_btn.send_keys(icomoon_json_path) import_btn.send_keys(icomoon_json_path)
except SeleniumTimeoutException as e:
print(e.stacktrace)
print("Selenium timed out. Couldn't find import button.")
self.close()
raise e
except Exception as e: except Exception as e:
self.close() self.close()
raise e raise e
@@ -159,8 +162,8 @@ class SeleniumRunner:
:return: None. :return: None.
""" """
try: try:
hamburger_input = self.driver.find_element_by_css_selector( hamburger_input = self.driver.find_element_by_xpath(
"button.btn5.lh-def.transparent i.icon-menu" "(//i[@class='icon-menu'])[2]"
) )
menu_appear_callback = ec.element_to_be_clickable( menu_appear_callback = ec.element_to_be_clickable(

33
.github/scripts/build_assets/util.py vendored Normal file
View File

@@ -0,0 +1,33 @@
from pathlib import Path
from argparse import ArgumentParser
from build_assets.PathResolverAction import PathResolverAction
def get_commandline_args():
parser = ArgumentParser(description="Upload svgs to Icomoon to create icon files.")
parser.add_argument("--headless",
help="Whether to run the browser in headless/no UI mode",
action="store_true")
parser.add_argument("geckodriver_path",
help="The path to the firefox executable file",
action=PathResolverAction)
parser.add_argument("icomoon_json_path",
help="The path to the icomoon.json aka the selection.json created by Icomoon",
action=PathResolverAction)
parser.add_argument("devicon_json_path",
help="The path to the devicon.json",
action=PathResolverAction)
parser.add_argument("icons_folder_path",
help="The path to the icons folder",
action=PathResolverAction)
parser.add_argument("download_path",
help="The path where you'd like to download the Icomoon files to",
action=PathResolverAction)
return parser.parse_args()

42
.github/scripts/icomoon_build.py vendored Normal file
View File

@@ -0,0 +1,42 @@
from pathlib import Path
from selenium.common.exceptions import TimeoutException
# pycharm complains that build_assets is an unresolved ref
# don't worry about it, the script still runs
from build_assets.SeleniumRunner import SeleniumRunner
from build_assets import filehandler, util
def main():
args = util.get_commandline_args()
new_icons = filehandler.find_new_icons(args.devicon_json_path, args.icomoon_json_path)
if len(new_icons) == 0:
print("No files need to be uploaded. Ending script...")
return
# print list of new icons
print("List of new icons:", *new_icons, sep = "\n")
runner = None
try:
runner = SeleniumRunner(args.download_path,
args.geckodriver_path, args.headless)
runner.upload_icomoon(args.icomoon_json_path)
svgs = filehandler.get_svgs_paths(new_icons, args.icons_folder_path)
runner.upload_svgs(svgs)
zip_name = "devicon-v1.0.zip"
zip_path = Path(args.download_path, zip_name)
runner.download_icomoon_fonts(zip_path)
filehandler.extract_files(str(zip_path), args.download_path)
filehandler.rename_extracted_files(args.download_path)
print("Task completed.")
except TimeoutException as e:
print(e)
print(e.stacktrace)
finally:
runner.close()
if __name__ == "__main__":
main()

View File

@@ -1,61 +1,31 @@
from pathlib import Path
from argparse import ArgumentParser
from selenium.common.exceptions import TimeoutException from selenium.common.exceptions import TimeoutException
# pycharm complains that build_assets is an unresolved ref # pycharm complains that build_assets is an unresolved ref
# don't worry about it, the script still runs # don't worry about it, the script still runs
from build_assets.SeleniumRunner import SeleniumRunner from build_assets.SeleniumRunner import SeleniumRunner
from build_assets import filehandler from build_assets import filehandler, util
from build_assets.PathResolverAction import PathResolverAction
def main(): def main():
parser = ArgumentParser(description="Upload svgs to Icomoon to create icon files.") args = util.get_commandline_args()
parser.add_argument("--headless",
help="Whether to run the browser in headless/no UI mode",
action="store_true")
parser.add_argument("geckodriver_path",
help="The path to the firefox executable file",
action=PathResolverAction)
parser.add_argument("icomoon_json_path",
help="The path to the icomoon.json aka the selection.json created by Icomoon",
action=PathResolverAction)
parser.add_argument("devicon_json_path",
help="The path to the devicon.json",
action=PathResolverAction)
parser.add_argument("icons_folder_path",
help="The path to the icons folder",
action=PathResolverAction)
parser.add_argument("download_path",
help="The path where you'd like to download the Icomoon files to",
action=PathResolverAction)
args = parser.parse_args()
new_icons = filehandler.find_new_icons(args.devicon_json_path, args.icomoon_json_path) new_icons = filehandler.find_new_icons(args.devicon_json_path, args.icomoon_json_path)
if len(new_icons) == 0: if len(new_icons) == 0:
print("No files need to be peek. Ending script...") print("No files need to be uploaded. Ending script...")
return return
# print list of new icons, separated by comma # print list of new icons
print("List of new icons:") print("List of new icons:", *new_icons, sep = "\n")
print(*new_icons, sep = "\n")
runner = None
try: try:
runner = SeleniumRunner(args.download_path, runner = SeleniumRunner(args.download_path, args.geckodriver_path, args.headless)
args.geckodriver_path, args.headless)
svgs = filehandler.get_svgs_paths(new_icons, args.icons_folder_path) svgs = filehandler.get_svgs_paths(new_icons, args.icons_folder_path)
runner.upload_svgs(svgs) runner.upload_svgs(svgs)
runner.close()
print("Task completed.") print("Task completed.")
except TimeoutException as e: except TimeoutException as e:
print(e) print(e)
print(e.stacktrace) print(e.stacktrace)
finally:
runner.close() runner.close()

View File

@@ -1,71 +0,0 @@
from pathlib import Path
from argparse import ArgumentParser
from selenium.common.exceptions import TimeoutException
# pycharm complains that build_assets is an unresolved ref
# don't worry about it, the script still runs
from build_assets.SeleniumRunner import SeleniumRunner
from build_assets import filehandler
from build_assets.PathResolverAction import PathResolverAction
def main():
parser = ArgumentParser(description="Upload svgs to Icomoon to create icon files.")
parser.add_argument("--headless",
help="Whether to run the browser in headless/no UI mode",
action="store_true")
parser.add_argument("geckodriver_path",
help="The path to the firefox executable file",
action=PathResolverAction)
parser.add_argument("icomoon_json_path",
help="The path to the icomoon.json aka the selection.json created by Icomoon",
action=PathResolverAction)
parser.add_argument("devicon_json_path",
help="The path to the devicon.json",
action=PathResolverAction)
parser.add_argument("icons_folder_path",
help="The path to the icons folder",
action=PathResolverAction)
parser.add_argument("download_path",
help="The path where you'd like to download the Icomoon files to",
action=PathResolverAction)
args = parser.parse_args()
new_icons = filehandler.find_new_icons(args.devicon_json_path, args.icomoon_json_path)
if len(new_icons) == 0:
print("No files need to be uploaded. Ending script...")
return
# print list of new icons, separated by comma
print("List of new icons:")
print(*new_icons, sep = "\n")
try:
runner = SeleniumRunner(args.download_path,
args.geckodriver_path, args.headless)
runner.upload_icomoon(args.icomoon_json_path)
svgs = filehandler.get_svgs_paths(new_icons, args.icons_folder_path)
runner.upload_svgs(svgs)
zip_name = "devicon-v1.0.zip"
zip_path = Path(args.download_path, zip_name)
runner.download_icomoon_fonts(zip_path)
filehandler.extract_files(str(zip_path), args.download_path)
filehandler.rename_extracted_files(args.download_path)
runner.close()
print("Task completed.")
except TimeoutException as e:
print(e)
print(e.stacktrace)
runner.close()
if __name__ == "__main__":
main()

View File

@@ -18,11 +18,8 @@ jobs:
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install -r ./.github/scripts/requirements.txt pip install -r ./.github/scripts/requirements.txt
npm install npm install
- name: Run icomoon_upload.py - name: Executing build and create fonts via icomoon
run: > run: npm run build
python ./.github/scripts/icomoon_upload.py
./.github/scripts/build_assets/geckodriver-v0.27.0-win64/geckodriver.exe
./icomoon.json ./devicon.json ./icons ./ --headless
- name: Upload geckodriver.log for debugging purposes - name: Upload geckodriver.log for debugging purposes
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
if: ${{failure()}} if: ${{failure()}}
@@ -35,7 +32,7 @@ jobs:
with: with:
name: new_icons name: new_icons
path: ./new_icons.png path: ./new_icons.png
- name: Running npm task for building devicon.min.css - name: Build devicon.min.css
if: ${{ success() }} if: ${{ success() }}
run: npm run build-css run: npm run build-css
- name: Create Pull Request - name: Create Pull Request

View File

@@ -16,16 +16,12 @@ jobs:
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
python-version: 3.8 python-version: 3.8
- name: Install dependencies (python, pip, npm) - name: Install dependencies (python, pip)
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install -r ./.github/scripts/requirements.txt pip install -r ./.github/scripts/requirements.txt
npm install
- name: Run icomoon_peek.py - name: Run icomoon_peek.py
run: > run: npm run peek
python ./.github/scripts/icomoon_peek.py
./.github/scripts/build_assets/geckodriver-v0.27.0-win64/geckodriver.exe
./icomoon.json ./devicon.json ./icons ./ --headless
- name: Upload geckodriver.log for debugging purposes - name: Upload geckodriver.log for debugging purposes
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
if: ${{failure()}} if: ${{failure()}}

View File

@@ -51,7 +51,7 @@ The <b>plain</b> and <b>line</b> versions (with or without wordmark) are designe
The <b>original</b> version are only available in svg format, so they do not need to be as simple and can contain numerous colors. The <b>original</b> version are only available in svg format, so they do not need to be as simple and can contain numerous colors.
</p> </p>
<p> <p>
Some icons are really simple (like the Apple one), so the original version can be used as the plain version and as the icon font. In this case, you'll only need to make only one of the version (either "original" or "plain"). You can then add an alias in the <code>devicon.json</code> so they can be found with either the "original" or "plain" naming convention. Some icons are really simple (like the Apple one), so the original version can be used as the plain version and as the icon font. In this case, you'll only need to make only one of the version (either "original" or "plain"). You can then add an alias in the <code>devicon.json</code> so they can be found with either the "original" or "plain" naming convention. Note that this only applies to font icon versions only, not the SVG versions. SVG versions don't need aliases.
</p> </p>
<hr> <hr>
@@ -62,9 +62,9 @@ Some icons are really simple (like the Apple one), so the original version can b
<li>The <b>plain</b> and <b>line</b> versions (with or without wordmark) need to stay as simple as possible. They must have only one color and the paths are united before exporting to svg. <li>The <b>plain</b> and <b>line</b> versions (with or without wordmark) need to stay as simple as possible. They must have only one color and the paths are united before exporting to svg.
</li> </li>
<li>Optimize/compress your SVGs. You can use a service like <a href="https://compressor.io/">compressor</a> or <a href="https://petercollingridge.appspot.com/svg-editor">SVG Editor</a>.</li> <li>Optimize/compress your SVGs. You can use a service like <a href="https://compressor.io/">compressor</a> or <a href="https://petercollingridge.appspot.com/svg-editor">SVG Editor</a>.</li>
<li>The icon's strokes and texts must be fills. We use Icomoon to make our icon, which has its<a href="https://icomoon.io/#docs/stroke-to-fill"> requirements</a></li> <li>The icon's strokes and texts must be fills. We use Icomoon to make our icon, which has its<a href="https://icomoon.io/#docs/stroke-to-fill"> requirements.</a></li>
<li>Each <code>.svg</code> file contains one version of an icon in a <code>0 0 128 128</code> viewbox</li> <li>Each <code>.svg</code> file contains one version of an icon in a <code>0 0 128 128</code> viewbox.</li>
<li>The naming convention for the svg file is the following: <code>(icon name)-(original|plain|line)-(wordmark)</code></li> <li>The naming convention for the svg file is the following: <code>(icon name)-(original|plain|line)(-wordmark?).</code></li>
</ul> </ul>
<hr> <hr>
@@ -87,18 +87,28 @@ Some icons are really simple (like the Apple one), so the original version can b
<pre> <pre>
<code> <code>
{ {
"name": string, // the official name of the technology. Must be lower case, no space or use the dash '-' character. "name": string, // the official name of the technology. Must be lower case, no space and don't have the dash '-' character.
"tags": string[], // list of tags relating to the technology for search purpose "tags": string[], // list of tags relating to the technology for search purpose
"versions": { "versions": {
"svg": VersionString[], // list the svgs that you have "svg": VersionString[], // list the svgs that you have
"font": VersionString[] // list the fonts acceptable versions that you have "font": VersionString[] // list the fonts acceptable versions that you have
}, },
"color": string, // the main color of the logo. Only track 1 color "color": string, // the main color of the logo. Only track 1 color
"aliases": AliasObj[] // keeps track of the aliases "aliases": AliasObj[] // keeps track of the aliases for the font versions ONLY
} }
</code> </code>
</pre> </pre>
<p>
Here is what VersionString means:
</p>
<ol>
<li> It's the version part of an `svg` file's name</li>
<li> If you have "html5-original", the version string would be "original" </li>
<li> If you have "react-line-wordmark", the version string would be "line-wordmark" </li>
<li> See <a href="#versionNaming">naming conventions section</a> for more details </li>
</ol>
<p> <p>
Here is the AliasObj interface: Here is the AliasObj interface:
</p> </p>
@@ -110,23 +120,14 @@ Some icons are really simple (like the Apple one), so the original version can b
} }
</code> </code>
</pre> </pre>
<p>
Here is what VersionString means:
</p>
<ol>
<li> If you have "html5-original", the version string would be "original" </li>
<li> If you have "react-line-wordmark", the version string would be "line-wordmark" </li>
<li> See <a href="#iconFormat">Icon Formats and Naming Conventions</a> for more details </li>
</ol>
<hr> <hr>
<h2 id='example'>Example </h2> <h2 id='example'>Example </h2>
<p> <p>
As an example, let's assume you have created the svgs for Amazon Web Services and Redhat logos. As an example, let's assume you have created the svgs for Redhat and Amazon Web Services logos.
</p> </p>
<p>For the Amazon Web Services svgs, you have the following versions: "original", "original-wordmark", "plain-wordmark". However, the "original" version is simple enough to be a "plain" version as well. Note that we are not using the acronym AWS.</p> <p>For the Redhat svg, you have the "original", "original-wordmark", "plain", and "plain-wordmark" versions. </p>
<p>For the Redhat svg, you have the "original", "original-wordmark", "plain", "plain-wordmark" versions. </p> <p>For the Amazon Web Services svgs, you have the following versions: "original", "original-wordmark", "plain-wordmark". The "original" version is simple enough to be a "plain" version as well. Note that we are not using the acronym AWS.</p>
<ol> <ol>
<li> <li>
Put the svgs for each logo that you have into its own folders in <code>/icons</code> Put the svgs for each logo that you have into its own folders in <code>/icons</code>
@@ -138,6 +139,33 @@ As an example, let's assume you have created the svgs for Amazon Web Services an
<li> <li>
<a href="#updateDevicon">Update the <code>devicon.json</code> to include the icon (or variations)</a> <a href="#updateDevicon">Update the <code>devicon.json</code> to include the icon (or variations)</a>
<ul> <ul>
<li>For the <code>redhat</code>, you would do this
<pre>
<code>
{
"name": "redhat",
"tags": [
"server",
"linux"
],
"versions": {
"svg": [ // here are the versions that are available in svgs
"original",
"original-wordmark",
"plain",
"plain-wordmark"
],
"font": [ // here are the versions that will be used to create icons
"plain",
"plain-wordmark"
]
},
"color": "#e93442", // note the '#' character
"aliases": [] // no aliases in this case
},
</code>
</pre>
</li>
<li>For the <code>amazonwebservices</code>, you would do this <li>For the <code>amazonwebservices</code>, you would do this
<pre> <pre>
<code> <code>
@@ -155,7 +183,7 @@ As an example, let's assume you have created the svgs for Amazon Web Services an
"plain-wordmark" "plain-wordmark"
], ],
"font": [ // here are the versions that will be used to create icons "font": [ // here are the versions that will be used to create icons
"original", // original is simple enough to be used as plain "original", // "original" is simple enough to be used as the plain icon so we'll add "plain" to the aliases below
"plain-wordmark", "plain-wordmark",
// note that the alias "plain" is not listed here. It must be listed in the `aliases` attribute // note that the alias "plain" is not listed here. It must be listed in the `aliases` attribute
] ]
@@ -163,50 +191,23 @@ As an example, let's assume you have created the svgs for Amazon Web Services an
"color": "#F7A80D", // note the '#' character "color": "#F7A80D", // note the '#' character
"aliases": [ "aliases": [
{ {
"base": "original", // here is the base version aka the one that we will upload to Icomoon "base": "original", // here is the base version that we will upload to Icomoon
"alias": "plain" // this is its alias. Our script will create a reference so we can search using "original" or "plain" "alias": "plain" // this is its alias. Our script will create a reference so users can search using "original" or "plain" for this icon
// note that you don't provide aliases for the svg version. If "original" is not a font version (i.e can't be made into a font), there's no need to provide it with a plain alias
} }
] ]
} }
</code> </code>
</pre> </pre>
</li> </li>
<li>For the <code>redhat</code>, you would do this
<pre>
<code>
{
"name": "redhat",
"tags": [
"server",
"linux"
],
"versions": {
"svg": [
"original",
"original-wordmark",
"plain",
"plain-wordmark"
],
"font": [
"plain",
"plain-wordmark"
]
},
"color": "#e93442",
"aliases": [] // no aliases
},
</code>
</pre>
</li>
<li><b>Note</b>: again, don't do this in the same commits. We want to have each logo in its own PR so don't create two folders in the same commit</li> <li><b>Note</b>: again, don't do this in the same commits. We want to have each logo in its own PR so don't create two folders in the same commit</li>
</ul> </ul>
</li> </li>
<li>Create a separated pull request (PR) for each icon (no matter how many variations). <li>Create a separate pull request (PR) for each icon (no matter how many variations).
<ul> <ul>
<li>This means you would have to create two PRs</li> <li>This means you would have to create two PRs</li>
<li>For Amazon Web Services, the branch name would be icons/amazonwebservices. </li> <li>For Amazon Web Services, the branch name would be icons/amazonwebservices. </li>
<li>For Redhat, the branch name would be icons/redhat. </li> <li>For Redhat, the branch name would be icons/redhat. </li>
<li> </li>
</ul> </ul>
</li> </li>
<li> <li>

View File

@@ -523,15 +523,12 @@
"line-wordmark" "line-wordmark"
], ],
"font": [ "font": [
"line" "line",
"line-wordmark"
] ]
}, },
"color": "#000000", "color": "#000000",
"aliases": [ "aliases": [
{
"base": "original",
"alias": "original-wordmark"
},
{ {
"base": "line", "base": "line",
"alias": "plain" "alias": "plain"
@@ -2257,6 +2254,7 @@
"original" "original"
] ]
}, },
"color": "#764abc",
"aliases": [ "aliases": [
{ {
"base": "original", "base": "original",

View File

@@ -4,7 +4,9 @@
"description": "Programming related icons collection", "description": "Programming related icons collection",
"main": "devicon.min.css", "main": "devicon.min.css",
"scripts": { "scripts": {
"build-css": "gulp updateCss && gulp clean" "build-css": "gulp updateCss && gulp clean",
"build": "python ./.github/scripts/icomoon_build.py ./.github/scripts/build_assets/geckodriver-v0.27.0-win64/geckodriver.exe ./icomoon.json ./devicon.json ./icons ./ --headless",
"peek": "python ./.github/scripts/icomoon_peek.py ./.github/scripts/build_assets/geckodriver-v0.27.0-win64/geckodriver.exe ./icomoon.json ./devicon.json ./icons ./ --headless"
}, },
"repository": { "repository": {
"type": "git", "type": "git",