Skip to content

Commit

Permalink
feat(icons): drop useless comments inside svg file (#8660)
Browse files Browse the repository at this point in the history
Co-authored-by: taiga-family-bot <[email protected]>
  • Loading branch information
splincode and taiga-family-bot authored Aug 23, 2024
1 parent fb85eba commit 327f470
Show file tree
Hide file tree
Showing 5,096 changed files with 119 additions and 5,229 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
92 changes: 41 additions & 51 deletions projects/icons-fontawesome/scripts/prepare-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,58 @@ import fs from 'node:fs';
import path from 'node:path';

import {PAYMENTS_ICONS} from '../../../scripts/custom-icons';
import {prepareSvg} from '../../../scripts/prepare-svg';
import {tuiIsCI} from '../../cdk/schematics';

const verbose = !tuiIsCI();
const dest =
process.argv[2] || path.join(process.cwd(), 'projects', 'icons-fontawesome', 'src');

// 1. copy fontawesome icons
['brands', 'regular', 'solid'].forEach((type) => {
const src = path.join(
process.cwd(),
'node_modules',
'@fortawesome',
'fontawesome-free',
'svgs',
type,
);

(function main(): void {
const dest =
process.argv[2] ||
path.join(process.cwd(), 'projects', 'icons-fontawesome', 'src');

// 1. copy fontawesome icons
['brands', 'regular', 'solid'].forEach((type) => {
const src = path.join(
process.cwd(),
'node_modules',
'@fortawesome',
'fontawesome-free',
'svgs',
type,
);

// noinspection DuplicatedCode
fs.readdirSync(src).forEach((filename: string) => {
const content = fs
.readFileSync(path.join(src, filename), 'utf-8')
.replace(/class="[a-zA-Z0-9:;.\s()\-,]*"/, '')
.replaceAll(
/<(circle|ellipse|line|polygon|polyline|path|rect)/g,
'<$1 vector-effect="non-scaling-stroke"',
);

const filePath = path.join(dest, 'fa', type, filename);

fs.mkdirSync(path.dirname(filePath), {recursive: true});
fs.writeFileSync(filePath, content);

verbose && console.info('copied:', filePath);
});
});

// 2. copy flags from design tokens
// noinspection DuplicatedCode
const flagsDir = path.resolve('node_modules/@taiga-ui/design-tokens/icons/flags');

fs.readdirSync(flagsDir).forEach((filename: string) => {
const content = fs.readFileSync(path.join(flagsDir, filename), 'utf-8');
const filePath = path.join(dest, 'flags', filename);
fs.readdirSync(src).forEach((filename: string) => {
const content = prepareSvg(fs.readFileSync(path.join(src, filename), 'utf-8'));
const filePath = path.join(dest, 'fa', type, filename);

fs.mkdirSync(path.dirname(filePath), {recursive: true});
fs.writeFileSync(filePath, content);

verbose && console.info('copied:', filePath);
});
});

// 3. copy payment icons
PAYMENTS_ICONS.forEach((filename) => {
const filePath = path.join('projects/icons/src', `${filename}.svg`);
// 2. copy flags from design tokens
// noinspection DuplicatedCode
const flagsDir = path.resolve('node_modules/@taiga-ui/design-tokens/icons/flags');

fs.writeFileSync(
path.join(dest, `${filename}.svg`),
fs.readFileSync(path.join(filePath), 'utf-8'),
);
fs.readdirSync(flagsDir).forEach((filename: string) => {
const content = fs.readFileSync(path.join(flagsDir, filename), 'utf-8');
const filePath = path.join(dest, 'flags', filename);

verbose && console.info('copied:', filePath);
});
})();
fs.mkdirSync(path.dirname(filePath), {recursive: true});
fs.writeFileSync(filePath, content);

verbose && console.info('copied:', filePath);
});

// 3. copy payment icons
PAYMENTS_ICONS.forEach((filename) => {
const filePath = path.join('projects/icons/src', `${filename}.svg`);

fs.writeFileSync(
path.join(dest, `${filename}.svg`),
fs.readFileSync(path.join(filePath), 'utf-8'),
);

verbose && console.info('copied:', filePath);
});
1 change: 0 additions & 1 deletion projects/icons-fontawesome/src/fa/brands/42-group.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion projects/icons-fontawesome/src/fa/brands/500px.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion projects/icons-fontawesome/src/fa/brands/accusoft.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion projects/icons-fontawesome/src/fa/brands/adn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion projects/icons-fontawesome/src/fa/brands/adversal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion projects/icons-fontawesome/src/fa/brands/airbnb.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion projects/icons-fontawesome/src/fa/brands/algolia.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion projects/icons-fontawesome/src/fa/brands/alipay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion projects/icons-fontawesome/src/fa/brands/amazon-pay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion projects/icons-fontawesome/src/fa/brands/amazon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion projects/icons-fontawesome/src/fa/brands/amilia.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 327f470

Please sign in to comment.