mirror of
https://github.com/konpa/devicon.git
synced 2025-08-14 18:44:17 +02:00
Added __pycache__ to gitignore. Documented geckodriver. Invalid path now throws error
This commit is contained in:
@@ -78,7 +78,7 @@ class SeleniumRunner:
|
||||
|
||||
def upload_icomoon(self):
|
||||
"""
|
||||
Upload the icomoon_test.json to icomoon.io.
|
||||
Upload the icomoon.json to icomoon.io.
|
||||
:raises TimeoutException: happens when elements are not found.
|
||||
"""
|
||||
print("Uploading JSON file...")
|
||||
@@ -89,7 +89,6 @@ class SeleniumRunner:
|
||||
)
|
||||
import_btn.send_keys(self.icomoon_json_path)
|
||||
except Exception as e:
|
||||
print("hi")
|
||||
self.close()
|
||||
raise e
|
||||
|
||||
@@ -100,8 +99,8 @@ class SeleniumRunner:
|
||||
confirm_btn.click()
|
||||
except SeleniumTimeoutException as e:
|
||||
print(e.stacktrace)
|
||||
print("Cannot find the confirm button when uploading the icomoon_test.json",
|
||||
"Ensure that the icomoon_test.json is in the correct format for Icomoon.io",
|
||||
print("Cannot find the confirm button when uploading the icomoon.json",
|
||||
"Ensure that the icomoon.json is in the correct format for Icomoon.io",
|
||||
sep='\n')
|
||||
self.close()
|
||||
|
||||
|
7
.github/scripts/build_assets/filehandler.py
vendored
7
.github/scripts/build_assets/filehandler.py
vendored
@@ -56,9 +56,8 @@ def get_svgs_paths(new_icons: List[dict], icons_folder_path: str) -> List[str]:
|
||||
for icon_info in new_icons:
|
||||
folder_path = Path(icons_folder_path, icon_info['name'])
|
||||
|
||||
if not (folder_path.exists() and folder_path.is_dir()):
|
||||
print(f"Invalid path. This is not a directory: {folder_path}\nSkipping entry...")
|
||||
continue
|
||||
if not folder_path.is_dir():
|
||||
raise ValueError(f"Invalid path. This is not a directory: {folder_path}.")
|
||||
|
||||
try:
|
||||
aliases = icon_info["aliases"]
|
||||
@@ -74,6 +73,8 @@ def get_svgs_paths(new_icons: List[dict], icons_folder_path: str) -> List[str]:
|
||||
|
||||
if path.exists():
|
||||
file_paths.append(str(path))
|
||||
else:
|
||||
raise ValueError(f"This path doesn't exist: {path}")
|
||||
|
||||
return file_paths
|
||||
|
||||
|
1
.github/scripts/build_assets/geckodriver-v0.27.0-win64/README.md
vendored
Normal file
1
.github/scripts/build_assets/geckodriver-v0.27.0-win64/README.md
vendored
Normal file
@@ -0,0 +1 @@
|
||||
This folder was taken from: https://github.com/mozilla/geckodriver/releases/tag/v0.27.0
|
BIN
.github/scripts/build_assets/geckodriver-v0.27.0-win64/geckodriver.exe
vendored
Normal file
BIN
.github/scripts/build_assets/geckodriver-v0.27.0-win64/geckodriver.exe
vendored
Normal file
Binary file not shown.
BIN
.github/scripts/build_assets/geckodriver.exe
vendored
BIN
.github/scripts/build_assets/geckodriver.exe
vendored
Binary file not shown.
14
.github/workflows/build_icons.yml
vendored
14
.github/workflows/build_icons.yml
vendored
@@ -1,14 +1,5 @@
|
||||
name: Build Icons
|
||||
on:
|
||||
# Trigger the workflow on push or pull request,
|
||||
# but only for the master branch
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
on: push
|
||||
jobs:
|
||||
build:
|
||||
name: Get Fonts From Icomoon
|
||||
@@ -25,7 +16,8 @@ jobs:
|
||||
pip install -r ./.github/scripts/requirements.txt
|
||||
- name: Run icomoon_upload.py
|
||||
run: >
|
||||
python ./.github/scripts/icomoon_upload.py ./.github/scripts/build_assets/geckodriver.exe
|
||||
python ./.github/scripts/icomoon_upload.py
|
||||
./.github/scripts/build_assets/geckodriver-v0.27.0-win64/geckodriver.exe
|
||||
./icomoon.json ./devicon.json ./icons ./built_files --headless
|
||||
- name: Commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
node_modules
|
||||
.DS_Store
|
||||
.idea
|
||||
geckodriver.log
|
||||
geckodriver.log
|
||||
__pycache__
|
@@ -1,39 +0,0 @@
|
||||
/* Parse the devicon-colors.css and convert it to devicon-colors.json*/
|
||||
const fs = require("fs");
|
||||
const path = require('path');
|
||||
|
||||
function main() {
|
||||
let filePath = path.join(__dirname, "..", "css", "devicon-colors.css");
|
||||
fs.readFile(filePath, "utf8", (err, css) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
|
||||
let key = null;
|
||||
let deviconColors = {};
|
||||
css.split("\n").forEach(line => {
|
||||
if (key) {
|
||||
// since have key, now look for line
|
||||
// that contains color: ###
|
||||
if (line.match(/color: /)) {
|
||||
deviconColors[key] = line.match(/#\w+/)[0];
|
||||
key = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (line.match(/devicon/)) {
|
||||
key = line.match(/-\w+/)[0].slice(1);
|
||||
}
|
||||
});
|
||||
|
||||
let deviconColorsFile = path.join(__dirname, "deviconColors.json");
|
||||
fs.writeFile(deviconColorsFile, JSON.stringify(deviconColors), err => {
|
||||
console.log(err ? err : "File successfully created");
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
main();
|
@@ -1,74 +0,0 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
|
||||
/**
|
||||
* Parse through the input.json and get all the
|
||||
* svg files within the new folder(s) as listed.
|
||||
* @param {{
|
||||
* folderName: string,
|
||||
* "originalSameAsPlain": boolean,
|
||||
"color": string
|
||||
}[]} input, an array of icon objects
|
||||
*/
|
||||
async function parseInput(input) {
|
||||
let svgFontFilePaths = [];
|
||||
let colors = [];
|
||||
|
||||
input.forEach(async iconObj => {
|
||||
let {folderName, originalSameAsPlain, color} = iconObj;
|
||||
colors.push(color);
|
||||
|
||||
// if original is same as plain (aka true), we use
|
||||
// the original version. else, we use plain.
|
||||
let allowedFontVers = [
|
||||
parseInt(originalSameAsPlain) ? "original" : "plain",
|
||||
"line",
|
||||
];
|
||||
|
||||
await getFolderFontFiles(folderName, allowedFontVers, svgFontFilePaths)
|
||||
})
|
||||
|
||||
return {
|
||||
svgFontFilePaths,
|
||||
colors
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the eligible SVG files from the folder.
|
||||
* @param {String} folderName, the name of the folder
|
||||
* @param {String[]} allowedFontVers, an array of allowed
|
||||
* font version. This makes sure that we only add the
|
||||
* appropriate files to the svgFilePaths.
|
||||
* @param {String[]} svgFilePaths, an array of filepaths
|
||||
* to eligible svg files that can be used as fonts.
|
||||
*/
|
||||
async function getFolderFontFiles(folderName, allowedFontVers, svgFilePaths) {
|
||||
// the new folder(s) must be in the icons folder
|
||||
let folderPath = path.join(__dirname, "icons", folderName);
|
||||
let dir = await new Promise((resolve, reject) => {
|
||||
fs.opendir(folderPath, (err, dir) => {
|
||||
if (err) reject(err);
|
||||
else resolve(dir);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
let dirEntry;
|
||||
while (dirEntry = await dir.read()) {
|
||||
// check if it's an SVG file
|
||||
let entryName = dirEntry.name;
|
||||
if (dirEntry.isFile() && entryName.match(/\.svg$/)) {
|
||||
// check if it has the correct type to use as a font
|
||||
if (allowedFontVers.some(allowedVer =>
|
||||
entryName.match(new RegExp(allowedVer)))) {
|
||||
|
||||
svgFilePaths.push(path.join(folderPath, dirEntry.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = parseInput;
|
Reference in New Issue
Block a user