Lucide Svelte Package! (#476)

* init svelte project

* Add export script for lucide-svelte

* make lucide-svelte wokring

* make ready for first release

* update lock file

* bump version

* some fixes in the build

* Add tests

* Finish tests

* Update Readme

* update lock file

* Add svelte to gh actions

* Add svetle to website docs

* Add test ci script

* adjust action

* add on PR trigger

* remove dep

* fix tests

* Add svelte entry in package.json

* update snapshots
This commit is contained in:
Eric Fennis
2022-02-17 17:46:55 +01:00
committed by GitHub
parent 7f03a8195a
commit f964dff64d
36 changed files with 3239 additions and 1755 deletions
+4 -2
View File
@@ -2,7 +2,7 @@ import path from 'path';
import { toPascalCase, resetFile, appendFile } from '../helpers';
export default function(inputEntry, outputDirectory, iconNodes) {
export default function(inputEntry, outputDirectory, iconNodes, iconFileExtention = '') {
const fileName = path.basename(inputEntry);
// Reset file
@@ -10,10 +10,12 @@ export default function(inputEntry, outputDirectory, iconNodes) {
const icons = Object.keys(iconNodes);
const fileExtention = iconFileExtention === '.ts' || iconFileExtention === '.js' ? '' : iconFileExtention
// Generate Import for Icon VNodes
icons.forEach(iconName => {
const componentName = toPascalCase(iconName);
const importString = `export { default as ${componentName} } from './${iconName}';\n`;
const importString = `export { default as ${componentName} } from './${iconName}${fileExtention}';\n`;
appendFile(importString, fileName, outputDirectory);
});
+18 -10
View File
@@ -5,7 +5,7 @@ import prettier from 'prettier';
import { promises } from 'stream';
import { toPascalCase } from '../helpers';
export default function({ iconNodes, outputDirectory, template, showLog = true, iconFileExtention = '.js' }) {
export default function({ iconNodes, outputDirectory, template, showLog = true, iconFileExtention = '.js', pretty = true }) {
const icons = Object.keys(iconNodes);
const iconsDistDirectory = path.join(outputDirectory, `icons`);
@@ -21,17 +21,25 @@ export default function({ iconNodes, outputDirectory, template, showLog = true,
children = children.map(({name, attributes}) => ([name, attributes]))
const elementTemplate = template({ componentName, iconName, children });
const output =
pretty
? prettier.format(elementTemplate, {
singleQuote: true,
trailingComma: 'all',
parser: 'babel',
})
: elementTemplate
await fs.promises.writeFile(location, prettier.format(elementTemplate, { singleQuote: true, trailingComma: 'all', parser: 'babel' }), 'utf-8');
await fs.promises.writeFile(location, output, 'utf-8');
});
Promise.all(writeIconFiles)
.then(() => {
if(showLog) {
console.log('Successfully built', icons.length, 'icons.');
}
})
.catch((error) => {
throw new Error(`Something went wrong generating icon files,\n ${error}`)
})
.then(() => {
if(showLog) {
console.log('Successfully built', icons.length, 'icons.');
}
})
.catch((error) => {
throw new Error(`Something went wrong generating icon files,\n ${error}`)
})
}
+3
View File
@@ -23,6 +23,7 @@ const {
silent = false,
iconFileExtention = '.js',
exportFileName = 'index.js',
pretty = true,
} = cliArguments;
const svgFiles = readSvgDirectory(ICONS_DIR);
@@ -39,6 +40,7 @@ generateIconFiles({
template: iconFileTemplate,
showLog: !silent,
iconFileExtention,
pretty: JSON.parse(pretty),
});
// Generates entry files for the compiler filled with icons exports
@@ -46,4 +48,5 @@ generateExportsFile(
path.join(OUTPUT_DIR, 'icons', exportFileName),
path.join(OUTPUT_DIR, 'icons'),
icons,
iconFileExtention,
);