-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init package files; add TS, formatting; create manifest generator script
- Loading branch information
1 parent
2bdf218
commit 516ad46
Showing
7 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
.DS_Store | ||
node_modules | ||
manifest.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "flowbite-icons", | ||
"description": "Official Flowbite Icons library", | ||
"keywords": [ | ||
"flowbite", | ||
"icons", | ||
"svg" | ||
], | ||
"homepage": "https://github.com/themesberg/flowbite-icons#readme", | ||
"bugs": "https://github.com/themesberg/flowbite-icons/issues", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/themesberg/flowbite-icons.git" | ||
}, | ||
"license": "MIT", | ||
"type": "module", | ||
"scripts": { | ||
"format": "prettier . --write", | ||
"format:check": "prettier .", | ||
"generate-manifest": "bun run scripts/generate-manifest.ts", | ||
"typecheck": "tsc" | ||
}, | ||
"devDependencies": { | ||
"@ianvs/prettier-plugin-sort-imports": "4.1.1", | ||
"@types/bun": "^1.0.6", | ||
"prettier": "3.2.5", | ||
"prettier-plugin-packagejson": "2.4.11", | ||
"typescript": "5.3.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** @type {import('prettier').Config} */ | ||
module.exports = { | ||
plugins: [ | ||
"prettier-plugin-packagejson", | ||
"@ianvs/prettier-plugin-sort-imports", | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import fs from "node:fs/promises"; | ||
import path from "path"; | ||
|
||
async function readFiles( | ||
directoryPath: string, | ||
onReadFile: (filePath: string) => Promise<void>, | ||
) { | ||
const files = await fs.readdir(directoryPath); | ||
|
||
for (const file of files) { | ||
const filePath = path.join(directoryPath, file); | ||
const stat = await fs.stat(filePath); | ||
|
||
if (stat.isDirectory()) { | ||
await readFiles(filePath, onReadFile); | ||
} else { | ||
await onReadFile(filePath); | ||
} | ||
} | ||
} | ||
|
||
const SVGS_PATH = "src"; | ||
const MANIFEST_PATH = "manifest.json"; | ||
|
||
const manifest: { | ||
name: string; | ||
style: string; | ||
category: string; | ||
svg: string; | ||
}[] = []; | ||
|
||
await readFiles(SVGS_PATH, async (filePath) => { | ||
if (!filePath.endsWith(".svg")) return; | ||
|
||
const relativePath = filePath.replace(`${SVGS_PATH}/`, ""); | ||
|
||
let [style, category, name] = relativePath.split("/"); | ||
name = name.split(".")[0]; | ||
|
||
const svg = await Bun.file(filePath).text(); | ||
|
||
manifest.push({ name, style, category, svg }); | ||
}); | ||
|
||
manifest.sort((a, b) => { | ||
const x = a.name.toLowerCase(); | ||
const y = b.name.toLowerCase(); | ||
return x < y ? -1 : x > y ? 1 : 0; | ||
}); | ||
|
||
await Bun.write(MANIFEST_PATH, JSON.stringify(manifest, null, 2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["ESNext"], | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleDetection": "force", | ||
"allowJs": true, | ||
|
||
/* Bundler mode */ | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"verbatimModuleSyntax": true, | ||
"noEmit": true, | ||
|
||
/* Linting */ | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"noFallthroughCasesInSwitch": true | ||
} | ||
} |