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 VictoriaMetrics #9479

Merged
merged 11 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Align svg when exporting in the beginning
  • Loading branch information
sh-cho committed Nov 21, 2023
commit 367bc5f3122fd153ba87c99d6b214c7329167594
74 changes: 37 additions & 37 deletions .svglintrc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ const htmlNamedEntitiesFile = path.join(
__dirname,
'node_modules',
'named-html-entities-json',
'index.json',
'index.json'
);
const svglintIgnoredFile = path.join(__dirname, '.svglint-ignored.json');

const data = JSON.parse(await fs.readFile(dataFile, 'utf8'));
const htmlNamedEntities = JSON.parse(
await fs.readFile(htmlNamedEntitiesFile, 'utf8'),
await fs.readFile(htmlNamedEntitiesFile, 'utf8')
);
const svglintIgnores = JSON.parse(
await fs.readFile(svglintIgnoredFile, 'utf8'),
await fs.readFile(svglintIgnoredFile, 'utf8')
);

const svgRegexp =
Expand Down Expand Up @@ -216,7 +216,7 @@ export default {

// avoid character codepoints as hexadecimal representation
const hexadecimalCodepoints = Array.from(
iconTitleText.matchAll(/&#x([A-Fa-f0-9]+);/g),
iconTitleText.matchAll(/&#x([A-Fa-f0-9]+);/g)
);
if (hexadecimalCodepoints.length > 0) {
_validCodepointsRepr = false;
Expand All @@ -240,14 +240,14 @@ export default {
reporter.error(
'Hexadecimal representation of encoded character' +
` "${match[0]}" found at index ${charHexReprIndex}:` +
` replace it with "${charRepr}".`,
` replace it with "${charRepr}".`
);
}
}

// avoid character codepoints as named entities
const namedEntitiesCodepoints = Array.from(
iconTitleText.matchAll(/&([A-Za-z0-9]+);/g),
iconTitleText.matchAll(/&([A-Za-z0-9]+);/g)
);
if (namedEntitiesCodepoints.length > 0) {
for (const match of namedEntitiesCodepoints) {
Expand Down Expand Up @@ -276,7 +276,7 @@ export default {
reporter.error(
'Named entity representation of encoded character' +
` "${match[0]}" found at index ${namedEntiyReprIndex}.` +
` Replace it with ${replacement}.`,
` Replace it with ${replacement}.`
);
}
}
Expand All @@ -285,7 +285,7 @@ export default {
if (_validCodepointsRepr) {
// compare encoded title with original title and report error if not equal
const encodingMatches = Array.from(
iconTitleText.matchAll(/&(#([0-9]+)|(amp|quot|lt|gt));/g),
iconTitleText.matchAll(/&(#([0-9]+)|(amp|quot|lt|gt));/g)
),
encodedBuf = [];

Expand All @@ -311,7 +311,7 @@ export default {
xmlNamedEntities[
xmlNamedEntitiesCodepoints.indexOf(charDecimalCode)
]
};`,
};`
);
} else {
encodedBuf.unshift(iconTitleText[i]);
Expand All @@ -324,7 +324,7 @@ export default {

reporter.error(
`Unencoded unicode characters found in title "${iconTitleText}":` +
` rewrite it as "${encodedIconTitleText}".`,
` rewrite it as "${encodedIconTitleText}".`
);
}

Expand Down Expand Up @@ -353,18 +353,18 @@ export default {
reporter.error(
`Unnecessary encoded character "${match[0]}" found` +
` at index ${decimalCodepointCharIndex}:` +
` replace it with ${replacement}.`,
` replace it with ${replacement}.`
);
}

if (_validCodepointsRepr) {
const iconName = htmlFriendlyToTitle(iconTitleText);
const iconExists = data.icons.some(
(icon) => icon.title === iconName,
(icon) => icon.title === iconName
);
if (!iconExists) {
reporter.error(
`No icon with title "${iconName}" found in simple-icons.json`,
`No icon with title "${iconName}" found in simple-icons.json`
);
}
}
Expand All @@ -384,15 +384,15 @@ export default {

if (width === 0 && height === 0) {
reporter.error(
'Path bounds were reported as 0 x 0; check if the path is valid',
'Path bounds were reported as 0 x 0; check if the path is valid'
);
if (updateIgnoreFile) {
ignoreIcon(reporter.name, iconPath, $);
}
} else if (width !== iconSize && height !== iconSize) {
reporter.error(
`Size of <path> must be exactly ${iconSize} in one dimension;` +
` the size is currently ${width} x ${height}`,
` the size is currently ${width} x ${height}`
);
if (updateIgnoreFile) {
ignoreIcon(reporter.name, iconPath, $);
Expand All @@ -407,15 +407,15 @@ export default {

for (const segment of segments) {
const precisionMax = Math.max(
...segment.params.slice(1).map(countDecimals),
...segment.params.slice(1).map(countDecimals)
);
if (precisionMax > iconMaxFloatPrecision) {
let errorMsg =
`found ${precisionMax} decimals in segment` +
` "${iconPath.substring(segment.start, segment.end)}"`;
if (segment.chained) {
const readableChain = maybeShortenedWithEllipsis(
iconPath.substring(segment.chainStart, segment.chainEnd),
iconPath.substring(segment.chainStart, segment.chainEnd)
);
errorMsg += ` of chain "${readableChain}"`;
}
Expand All @@ -424,7 +424,7 @@ export default {
}`;
reporter.error(
'Maximum precision should not be greater than' +
` ${iconMaxFloatPrecision}; ${errorMsg}`,
` ${iconMaxFloatPrecision}; ${errorMsg}`
);
}
}
Expand Down Expand Up @@ -468,7 +468,7 @@ export default {
const isInvalidSegment = (
[command, x1Coord, y1Coord, ...rest],
index,
previousSegmentIsZ,
previousSegmentIsZ
) => {
if (commands.includes(command)) {
// Relative directions (h or v) having a length of 0
Expand Down Expand Up @@ -603,7 +603,7 @@ export default {

let errorMsg = `Ineffective segment "${iconPath.substring(
segment.start,
segment.end,
segment.end
)}" found`,
resolutionTip = 'should be removed';

Expand All @@ -615,29 +615,29 @@ export default {
(x2 !== 0 || y2 !== 0)
) {
resolutionTip = `should be "l${removeLeadingZeros(
x2,
x2
)} ${removeLeadingZeros(y2)}" or removed`;
}
if (command === upperShorthandCurveCommand) {
resolutionTip = `should be "L${removeLeadingZeros(
x2,
x2
)} ${removeLeadingZeros(y2)}" or removed`;
}
if (command === lowerCurveCommand && (x !== 0 || y !== 0)) {
resolutionTip = `should be "l${removeLeadingZeros(
x,
x
)} ${removeLeadingZeros(y)}" or removed`;
}
if (command === upperCurveCommand) {
resolutionTip = `should be "L${removeLeadingZeros(
x,
x
)} ${removeLeadingZeros(y)}" or removed`;
}
}

if (segment.chained) {
const readableChain = maybeShortenedWithEllipsis(
iconPath.substring(segment.chainStart, segment.chainEnd),
iconPath.substring(segment.chainStart, segment.chainEnd)
);
errorMsg += ` in chain "${readableChain}"`;
}
Expand Down Expand Up @@ -798,11 +798,11 @@ export default {
currLine[p][0],
currLine[p][1],
currLine[p + 1][0],
currLine[p + 1][1],
currLine[p + 1][1]
);
if (_collinearCoord) {
collinearSegments.push(
segments[s - currLine.length + p + 1],
segments[s - currLine.length + p + 1]
);
}
}
Expand All @@ -823,11 +823,11 @@ export default {
for (const segment of collinearSegments) {
let errorMsg = `Collinear segment "${iconPath.substring(
segment.start,
segment.end,
segment.end
)}" found`;
if (segment.chained) {
let readableChain = maybeShortenedWithEllipsis(
iconPath.substring(segment.chainStart, segment.chainEnd),
iconPath.substring(segment.chainStart, segment.chainEnd)
);
errorMsg += ` in chain "${readableChain}"`;
}
Expand All @@ -843,12 +843,12 @@ export default {
if (!svgRegexp.test(ast.source)) {
if (ast.source.includes('\n') || ast.source.includes('\r')) {
reporter.error(
'Unexpected newline character(s) detected in SVG markup',
'Unexpected newline character(s) detected in SVG markup'
);
} else {
reporter.error(
'Unexpected character(s), most likely extraneous' +
' whitespace, detected in SVG markup',
' whitespace, detected in SVG markup'
);
}
}
Expand All @@ -860,7 +860,7 @@ export default {

// Find negative zeros inside path
const negativeZeroMatches = Array.from(
iconPath.matchAll(negativeZerosRegexp),
iconPath.matchAll(negativeZerosRegexp)
);
if (negativeZeroMatches.length) {
// Calculate the index for each match in the file
Expand All @@ -874,7 +874,7 @@ export default {
: '0';
reporter.error(
`Found "-0" at index ${negativeZeroFileIndex} (should` +
` be "${replacement}")`,
` be "${replacement}")`
);
}
}
Expand All @@ -899,7 +899,7 @@ export default {
) {
reporter.error(
`<path> must be centered at (${iconTargetCenter}, ${iconTargetCenter});` +
` the center is currently (${centerX}, ${centerY})`,
` the center is currently (${centerX}, ${centerY})`
);
if (updateIgnoreFile) {
ignoreIcon(reporter.name, iconPath, $);
Expand All @@ -925,15 +925,15 @@ export default {

const validPathCharacters = SVG_PATH_REGEX.source.replace(
/[\[\]+^$]/g,
'',
''
),
invalidCharactersMsgs = [],
pathDIndex = getPathDIndex(ast.source);

for (let [i, char] of Object.entries(iconPath)) {
if (validPathCharacters.indexOf(char) === -1) {
invalidCharactersMsgs.push(
`"${char}" at index ${pathDIndex + parseInt(i)}`,
`"${char}" at index ${pathDIndex + parseInt(i)}`
);
}
}
Expand All @@ -954,7 +954,7 @@ export default {
if (ast.source.includes('</path>')) {
const reason =
`found a closing "path" tag at index ${ast.source.indexOf(
'</path>',
'</path>'
)}. The path should be self-closing,` +
' use "/>" instead of "></path>".';
reporter.error(`Invalid SVG content format: ${reason}`);
Expand Down
2 changes: 1 addition & 1 deletion icons/victoriametrics.svg
adamrusted marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions scripts/add-icon-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const titleValidator = (text) => {
if (!text) return 'This field is required';
if (
iconsData.icons.find(
(x) => x.title === text || titleToSlug(x.title) === titleToSlug(text),
(x) => x.title === text || titleToSlug(x.title) === titleToSlug(text)
)
)
return 'This icon title or slug already exist';
Expand All @@ -40,7 +40,7 @@ const hexTransformer = (text) => {
: -1;
if (luminance === -1) return text.toUpperCase();
return chalk.bgHex(`#${color}`).hex(luminance < 0.4 ? '#fff' : '#000')(
text.toUpperCase(),
text.toUpperCase()
);
};

Expand All @@ -51,7 +51,7 @@ const aliasesTransformer = (text) =>
.join(',');

const aliasesChoices = Object.entries(
jsonSchema.definitions.brand.properties.aliases.properties,
jsonSchema.definitions.brand.properties.aliases.properties
)
.filter(([k]) => ['aka', 'old'].includes(k))
.map(([k, v]) => ({ name: `${k}: ${v.description}`, value: k }));
Expand Down
8 changes: 4 additions & 4 deletions scripts/build/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const build = async () => {
icon.guidelines ? `\n guidelines: '${escape(icon.guidelines)}',` : '',
licenseToObject(icon.license)
? `\n license: ${JSON.stringify(licenseToObject(icon.license))},`
: '',
: ''
);
};
const writeJs = async (filepath, rawJavaScript, opts = null) => {
Expand All @@ -85,7 +85,7 @@ const build = async () => {
const iconObject = iconToObject(icon);
const iconExportName = slugToVariableName(icon.slug);
return { icon, iconObject, iconExportName };
}),
})
);

const iconsBarrelDts = [];
Expand All @@ -104,15 +104,15 @@ const build = async () => {

// write our file containing the exports of all icons in CommonJS ...
const rawIndexJs = `${constantsString}module.exports={${iconsBarrelJs.join(
'',
''
)}};`;
await writeJs(indexJsFile, rawIndexJs);
// and ESM
const rawIndexMjs = constantsString + iconsBarrelMjs.join('');
await writeJs(indexMjsFile, rawIndexMjs);
// and create a type declaration file
const rawIndexDts = `import {SimpleIcon} from "./types";export {SimpleIcon};type I=SimpleIcon;${iconsBarrelDts.join(
'',
''
)}`;
await writeTs(indexDtsFile, rawIndexDts);

Expand Down
6 changes: 3 additions & 3 deletions scripts/lint/ourlint.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ const TESTS = {
...new Set(
data.icons
.flatMap((icon) => [icon.source, icon.guidelines, icon.license?.url])
.filter(Boolean),
.filter(Boolean)
),
];

const invalidUrls = allUrlFields.filter((url) =>
hasRedundantTrailingSlash(url),
hasRedundantTrailingSlash(url)
);

if (invalidUrls.length > 0) {
return `Some URLs have a redundant trailing slash:\n\n${invalidUrls.join(
'\n',
'\n'
)}`;
}
},
Expand Down
4 changes: 2 additions & 2 deletions scripts/release/strip-theme-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ await writeFile(
readmeFile,
readme.replace(
/https:\/\/cdn.simpleicons.org\/(.+)\/000\/fff/g,
`https://raw.githubusercontent.com/simple-icons/simple-icons/${LINKS_BRANCH}/icons/$1.svg`,
),
`https://raw.githubusercontent.com/simple-icons/simple-icons/${LINKS_BRANCH}/icons/$1.svg`
)
);
Loading