mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
🛠️ Update registry command & logs
This commit is contained in:
+2
-34
@@ -13,7 +13,6 @@ import { parseReactSvgContent } from "./src/utils/parseReactSvgContent";
|
|||||||
const execAsync = promisify(exec);
|
const execAsync = promisify(exec);
|
||||||
|
|
||||||
// ⚙️ Settings:
|
// ⚙️ Settings:
|
||||||
const MINIFY_TSX = false;
|
|
||||||
const REGENERATE_ALL = true;
|
const REGENERATE_ALL = true;
|
||||||
const SVGS_DATA = svgs;
|
const SVGS_DATA = svgs;
|
||||||
const PUBLIC_FOLDER = "static";
|
const PUBLIC_FOLDER = "static";
|
||||||
@@ -188,29 +187,6 @@ function convertToFilesystemPath(svgPath: string): string {
|
|||||||
return `./${PUBLIC_FOLDER}/${cleanPath}`;
|
return `./${PUBLIC_FOLDER}/${cleanPath}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSpinner() {
|
|
||||||
const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
||||||
let current = 0;
|
|
||||||
let interval;
|
|
||||||
|
|
||||||
return {
|
|
||||||
start(getMessage) {
|
|
||||||
interval = setInterval(() => {
|
|
||||||
const message =
|
|
||||||
typeof getMessage === "function" ? getMessage() : getMessage;
|
|
||||||
process.stdout.write(`\r${frames[current]} ${message}`);
|
|
||||||
current = (current + 1) % frames.length;
|
|
||||||
}, 100);
|
|
||||||
},
|
|
||||||
stop() {
|
|
||||||
if (interval) {
|
|
||||||
clearInterval(interval);
|
|
||||||
process.stdout.write("\r");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function convertSvgToReact(svgPath: string): Promise<string> {
|
async function convertSvgToReact(svgPath: string): Promise<string> {
|
||||||
const rawSvg = await fs.promises.readFile(svgPath, "utf-8");
|
const rawSvg = await fs.promises.readFile(svgPath, "utf-8");
|
||||||
const optimizedSvg = optimizeSvg({ svgCode: rawSvg });
|
const optimizedSvg = optimizeSvg({ svgCode: rawSvg });
|
||||||
@@ -222,7 +198,6 @@ async function convertSvgToReact(svgPath: string): Promise<string> {
|
|||||||
componentName,
|
componentName,
|
||||||
svgCode: optimizedSvg,
|
svgCode: optimizedSvg,
|
||||||
typescript: true,
|
typescript: true,
|
||||||
minify: MINIFY_TSX,
|
|
||||||
});
|
});
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
@@ -264,7 +239,6 @@ async function runShadcnBuild() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
const spinner = createSpinner();
|
|
||||||
let convertedCount = 0;
|
let convertedCount = 0;
|
||||||
let totalCount = 0;
|
let totalCount = 0;
|
||||||
|
|
||||||
@@ -287,9 +261,7 @@ async function run() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
spinner.start(
|
console.log(`[📦] Converting ${totalCount} SVGs converted to TSX...`);
|
||||||
() => `[📦] ${convertedCount}/${totalCount} SVGs converted to TSX`,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Process files
|
// Process files
|
||||||
for (const svgFile of svgFiles) {
|
for (const svgFile of svgFiles) {
|
||||||
@@ -319,11 +291,8 @@ async function run() {
|
|||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spinner.stop();
|
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`\n[✅] Conversion completed: ${convertedCount}/${totalCount} SVGs processed`,
|
`\n[📦] ✨ Conversion completed: ${convertedCount}/${totalCount} SVGs processed`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (convertedCount < totalCount) {
|
if (convertedCount < totalCount) {
|
||||||
@@ -335,7 +304,6 @@ async function run() {
|
|||||||
await runShadcnBuild();
|
await runShadcnBuild();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
spinner.stop();
|
|
||||||
console.error("[❌] Error:", error);
|
console.error("[❌] Error:", error);
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@
|
|||||||
"lint": "eslint ./src",
|
"lint": "eslint ./src",
|
||||||
"lint:fix": "eslint ./src --fix",
|
"lint:fix": "eslint ./src --fix",
|
||||||
"build:shadcn": "shadcn build --output ./static/r",
|
"build:shadcn": "shadcn build --output ./static/r",
|
||||||
"build:prod": "vite build && pnpm build:registry",
|
"build:prod": "pnpm build:registry && vite build",
|
||||||
"build:registry": "tsx ./generate-registry.ts"
|
"build:registry": "tsx ./generate-registry.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user