Skip to content

Add devicon icons #69

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 26 additions & 1 deletion scripts/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const basename = filepath => path.basename(filepath, path.extname(filepath));
const sanitizeName = s => s.replace(/[^a-zA-Z0-9_$-]/g, '').replace(/-+/, '-');

const mkdir = async dir => fs.promises.mkdir(dir, {recursive: true});
const rmdir = async dir => fs.promises.rmdir(dir, {recursive: true, maxRetries: 10});
const rmdir = async dir => fs.promises.rm(dir, {recursive: true, force: true, maxRetries: 10});

// download a file onto a temporary directory
const downloadFile = async url => {
Expand Down Expand Up @@ -152,6 +152,7 @@ const Azure = 'azure';
const K8s = 'k8s';
const GCP = 'gcp';
const Generic = 'generic';
const DevIcon = 'devicon';

// the following patterns in the form [regex, string replacement] allow for
// customisation of asset names for each provider.
Expand Down Expand Up @@ -217,6 +218,7 @@ const gcpPatterns = [
[/GKEOn/i, 'gke-on'],
];
const genericPatterns = [];
const devIconPatterns = [[/-original\./, '.']];

// custom provider functions to compute the name of the group a
// service should belong from the name of the SVG file
Expand Down Expand Up @@ -260,6 +262,11 @@ const genericComputeGroup = ({source, ...rest}) => ({
source,
group: 'Generic',
});
const devIconComputeGroup = ({source, ...rest}) => ({
...rest,
source,
group: 'DevIcon',
});

// providers configs
// each provider object contains the following:
Expand Down Expand Up @@ -287,6 +294,7 @@ const config = {
.then(readContent)
.then(resizeContent),
},

[Azure]: {
fetch: targetDir =>
fromRemoteZip('https://arch-center.azureedge.net/icons/Azure_Public_Service_Icons_V2.zip', targetDir),
Expand All @@ -301,6 +309,7 @@ const config = {
.then(readContent)
.then(resizeContent),
},

[K8s]: {
fetch: targetDir => fromRemoteZip('https://github.com/kubernetes/community/archive/master.zip', targetDir),
filter: filepath => filepath.match(/.*unlabeled\/.*\.svg$/i),
Expand All @@ -314,6 +323,7 @@ const config = {
.then(readContent)
.then(resizeContent),
},

[GCP]: {
fetch: targetDir =>
fromRemoteZip('https://cloud.google.com/icons/files/google-cloud-icons.zip', targetDir).then(() =>
Expand All @@ -330,6 +340,7 @@ const config = {
.then(readContent)
.then(resizeContent),
},

[Generic]: {
fetch: targetDir => copyFromDir(path.join(assetsOverrideDir, 'generic'), targetDir),
filter: () => true, // keep all svg
Expand All @@ -343,6 +354,20 @@ const config = {
.then(readContent)
.then(resizeContent),
},

[DevIcon]: {
fetch: targetDir => fromRemoteZip('https://github.com/devicons/devicon/archive/refs/tags/v2.15.1.zip', targetDir),
filter: filepath => filepath.match(/.*icons.*.svg$/i),
prepare: filepath =>
Promise.resolve({provider: DevIcon, source: filepath})
.then(extractFilename)
.then(devIconComputeGroup)
.then(replacePatterns(devIconPatterns))
.then(addTarget)
.then(addImportName)
.then(readContent)
.then(resizeContent),
},
};

// define the entire processing pipeline for a provider
Expand Down
2 changes: 1 addition & 1 deletion src/grammar_diagram.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
"name": "provider",
"label": "provider",
"idx": 0,
"pattern": "(aws|k8s|azure|gcp|generic)"
"pattern": "(aws|k8s|azure|gcp|generic|devicon)"
},
{
"type": "Terminal",
Expand Down
14 changes: 14 additions & 0 deletions src/images/devicon/aarch64-plain.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading