svgfusion 1.0.0-beta.6 → 1.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +25 -12
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -322,29 +322,40 @@ var import_url = require("url");
|
|
|
322
322
|
var import_path2 = require("path");
|
|
323
323
|
var import_fs2 = require("fs");
|
|
324
324
|
var import_figlet = __toESM(require("figlet"));
|
|
325
|
+
var colors = {
|
|
326
|
+
cyan: "\x1B[36m",
|
|
327
|
+
blue: "\x1B[34m",
|
|
328
|
+
green: "\x1B[32m",
|
|
329
|
+
red: "\x1B[31m",
|
|
330
|
+
gray: "\x1B[90m",
|
|
331
|
+
reset: "\x1B[0m"
|
|
332
|
+
};
|
|
325
333
|
var __filename2 = (0, import_url.fileURLToPath)(importMetaUrl);
|
|
326
334
|
var __dirname = (0, import_path2.dirname)(__filename2);
|
|
327
335
|
var packageJson = JSON.parse(
|
|
328
336
|
(0, import_fs2.readFileSync)((0, import_path2.join)(__dirname, "..", "package.json"), "utf-8")
|
|
329
337
|
);
|
|
330
338
|
function createBanner() {
|
|
331
|
-
const title = import_figlet.default.textSync("
|
|
332
|
-
font: "
|
|
333
|
-
horizontalLayout: "
|
|
334
|
-
verticalLayout: "
|
|
339
|
+
const title = import_figlet.default.textSync("SVGfusion", {
|
|
340
|
+
font: "Bloody",
|
|
341
|
+
horizontalLayout: "default",
|
|
342
|
+
verticalLayout: "default",
|
|
335
343
|
width: 80,
|
|
336
344
|
whitespaceBreak: true
|
|
337
345
|
});
|
|
338
346
|
return `
|
|
339
|
-
${title}
|
|
347
|
+
${colors.cyan}${title}${colors.reset}
|
|
340
348
|
|
|
341
|
-
Transform SVG files into production-ready components
|
|
342
|
-
React \u2022 Vue 3 \u2022 TypeScript
|
|
349
|
+
${colors.gray}Transform SVG files into production-ready components${colors.reset}
|
|
350
|
+
${colors.blue}React${colors.reset} ${colors.gray}\u2022${colors.reset} ${colors.green}Vue 3${colors.reset} ${colors.gray}\u2022${colors.reset} ${colors.blue}TypeScript${colors.reset}
|
|
343
351
|
|
|
344
|
-
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
352
|
+
${colors.gray}\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500${colors.reset}
|
|
345
353
|
`;
|
|
346
354
|
}
|
|
347
355
|
var program = new import_commander.Command();
|
|
356
|
+
if (process.argv.length === 2) {
|
|
357
|
+
console.log(createBanner());
|
|
358
|
+
}
|
|
348
359
|
program.name("svgfusion").description(
|
|
349
360
|
"Transform SVG files into production-ready React and Vue 3 components"
|
|
350
361
|
).version(packageJson.version);
|
|
@@ -355,7 +366,7 @@ program.command("convert").description("Convert SVG files to React or Vue compon
|
|
|
355
366
|
).option("-t, --typescript", "Generate TypeScript files", false).option("--no-optimize", "Skip SVG optimization").action(
|
|
356
367
|
async (input, options) => {
|
|
357
368
|
console.log(createBanner());
|
|
358
|
-
console.log(
|
|
369
|
+
console.log(`${colors.blue}\u{1F504} Processing SVG files...${colors.reset}`);
|
|
359
370
|
try {
|
|
360
371
|
const { framework, output, typescript, optimize: optimize2 } = options;
|
|
361
372
|
if (framework !== "react" && framework !== "vue") {
|
|
@@ -365,7 +376,9 @@ program.command("convert").description("Convert SVG files to React or Vue compon
|
|
|
365
376
|
if (svgFiles.length === 0) {
|
|
366
377
|
throw new Error("No SVG files found in the input path");
|
|
367
378
|
}
|
|
368
|
-
console.log(
|
|
379
|
+
console.log(
|
|
380
|
+
`${colors.blue}\u{1F504} Converting ${svgFiles.length} SVG file(s)...${colors.reset}`
|
|
381
|
+
);
|
|
369
382
|
for (const filePath of svgFiles) {
|
|
370
383
|
const svgContent = await readSvgFile(filePath);
|
|
371
384
|
const optimizedSvg = optimize2 ? optimizeSvg(svgContent) : svgContent;
|
|
@@ -374,11 +387,11 @@ program.command("convert").description("Convert SVG files to React or Vue compon
|
|
|
374
387
|
await writeComponentFile(outputPath, result.code);
|
|
375
388
|
}
|
|
376
389
|
console.log(
|
|
377
|
-
|
|
390
|
+
`${colors.green}\u2705 Successfully converted ${svgFiles.length} SVG file(s) to ${framework} components${colors.reset}`
|
|
378
391
|
);
|
|
379
392
|
} catch (error) {
|
|
380
393
|
console.error(
|
|
381
|
-
|
|
394
|
+
`${colors.red}\u274C Error: ${error instanceof Error ? error.message : "Unknown error"}${colors.reset}`
|
|
382
395
|
);
|
|
383
396
|
process.exit(1);
|
|
384
397
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svgfusion",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.7",
|
|
4
4
|
"description": "A powerful CLI tool and library that converts SVG files into production-ready React and Vue 3 components with TypeScript support and automatic optimization.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|