chore(scripts): Refactor scripts to typescript (#3316)

* Adjust typescript types

* adjust types

* fix types in all helper files

* Fix types

* Migrate js files to ts files

* Refactor to TS files

* Rename extentions

* Adjust imports

* Fix builds

* Update lockfile

* Fix last typescript migration

* Fix entry path @lucide/outline-svg

* Fix types

* add checkout step

* format files

* Format files
This commit is contained in:
Eric Fennis
2025-06-18 15:47:24 +02:00
committed by GitHub
parent 7517894f2d
commit 3e644fda2d
111 changed files with 833 additions and 527 deletions
@@ -8,7 +8,7 @@ import DEFAULT_ATTRS from '../../tools/build-icons/render/default-attrs.json' wi
* @param {string} svg - An SVG string.
* @returns {Promise<string>} An optimized svg
*/
async function optimizeSvg(svg, path) {
async function optimizeSvg(svg: string, path: string) {
const result = optimize(svg, {
path,
plugins: [
@@ -38,10 +38,16 @@ async function optimizeSvg(svg, path) {
* @param {string} svg - An SVG string.
* @returns {string} An SVG string, included with the default attributes.
*/
function setAttrs(svg) {
function setAttrs(svg: string) {
const contents = parseSync(svg);
contents.attributes = DEFAULT_ATTRS;
contents.attributes = {
...DEFAULT_ATTRS,
width: String(DEFAULT_ATTRS.width),
height: String(DEFAULT_ATTRS.height),
"stroke-width": String(DEFAULT_ATTRS['stroke-width']),
...contents.attributes,
};
return stringify(contents);
}
@@ -51,7 +57,7 @@ function setAttrs(svg) {
* @param {string} svg An SVG string.
* @returns {Promise<string>} An optimized svg
*/
function processSvg(svg, path) {
function processSvg(svg: string, path: string) {
return (
optimizeSvg(svg, path)
.then(setAttrs)