vectify 2.0.0 → 2.0.2
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/README.md +67 -0
- package/README.zh-CN.md +67 -0
- package/dist/{chunk-4BWKFV7W.mjs → chunk-XHYCGABW.mjs} +125 -23
- package/dist/cli.js +135 -32
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +37 -1
- package/dist/index.d.ts +37 -1
- package/dist/index.js +131 -28
- package/dist/index.mjs +1 -1
- package/dist/templates/react/component.jsx.hbs +2 -0
- package/dist/templates/react/component.tsx.hbs +3 -1
- package/dist/templates/react/createIcon.jsx.hbs +2 -0
- package/dist/templates/react/createIcon.tsx.hbs +18 -14
- package/package.json +13 -11
package/dist/index.js
CHANGED
|
@@ -103,23 +103,23 @@ async function writeFile(filePath, content) {
|
|
|
103
103
|
}
|
|
104
104
|
async function getSvgFiles(dirPath) {
|
|
105
105
|
const fs2 = await import("fs/promises");
|
|
106
|
-
const
|
|
106
|
+
const path7 = await import("path");
|
|
107
107
|
try {
|
|
108
108
|
const files = await fs2.readdir(dirPath);
|
|
109
|
-
return files.filter((file) => file.endsWith(".svg")).map((file) =>
|
|
109
|
+
return files.filter((file) => file.endsWith(".svg")).map((file) => path7.join(dirPath, file));
|
|
110
110
|
} catch {
|
|
111
111
|
return [];
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
async function findProjectRoot(startDir = process.cwd()) {
|
|
115
|
-
const
|
|
115
|
+
const path7 = await import("path");
|
|
116
116
|
let currentDir = startDir;
|
|
117
117
|
while (true) {
|
|
118
|
-
const packageJsonPath =
|
|
118
|
+
const packageJsonPath = path7.join(currentDir, "package.json");
|
|
119
119
|
if (await fileExists(packageJsonPath)) {
|
|
120
120
|
return currentDir;
|
|
121
121
|
}
|
|
122
|
-
const parentDir =
|
|
122
|
+
const parentDir = path7.dirname(currentDir);
|
|
123
123
|
if (parentDir === currentDir) {
|
|
124
124
|
return startDir;
|
|
125
125
|
}
|
|
@@ -785,7 +785,7 @@ async function findConfig() {
|
|
|
785
785
|
}
|
|
786
786
|
|
|
787
787
|
// src/generators/index.ts
|
|
788
|
-
var
|
|
788
|
+
var import_node_path4 = __toESM(require("path"));
|
|
789
789
|
|
|
790
790
|
// src/parsers/optimizer.ts
|
|
791
791
|
var import_svgo = require("svgo");
|
|
@@ -819,6 +819,101 @@ async function optimizeSvg(svgContent, config) {
|
|
|
819
819
|
}
|
|
820
820
|
}
|
|
821
821
|
|
|
822
|
+
// src/utils/formatter.ts
|
|
823
|
+
var import_node_child_process = require("child_process");
|
|
824
|
+
var import_node_path3 = __toESM(require("path"));
|
|
825
|
+
var import_node_process2 = __toESM(require("process"));
|
|
826
|
+
var import_node_util = require("util");
|
|
827
|
+
init_helpers();
|
|
828
|
+
var execAsync = (0, import_node_util.promisify)(import_node_child_process.exec);
|
|
829
|
+
var FORMATTER_PATTERNS = {
|
|
830
|
+
biome: ["biome.json", "biome.jsonc"],
|
|
831
|
+
prettier: [
|
|
832
|
+
".prettierrc",
|
|
833
|
+
".prettierrc.json",
|
|
834
|
+
".prettierrc.yml",
|
|
835
|
+
".prettierrc.yaml",
|
|
836
|
+
".prettierrc.js",
|
|
837
|
+
".prettierrc.cjs",
|
|
838
|
+
".prettierrc.mjs",
|
|
839
|
+
"prettier.config.js",
|
|
840
|
+
"prettier.config.cjs",
|
|
841
|
+
"prettier.config.mjs"
|
|
842
|
+
],
|
|
843
|
+
eslint: [
|
|
844
|
+
"eslint.config.js",
|
|
845
|
+
"eslint.config.mjs",
|
|
846
|
+
"eslint.config.cjs",
|
|
847
|
+
"eslint.config.ts",
|
|
848
|
+
".eslintrc",
|
|
849
|
+
".eslintrc.js",
|
|
850
|
+
".eslintrc.cjs",
|
|
851
|
+
".eslintrc.json",
|
|
852
|
+
".eslintrc.yml",
|
|
853
|
+
".eslintrc.yaml"
|
|
854
|
+
]
|
|
855
|
+
};
|
|
856
|
+
var FORMATTER_COMMANDS = {
|
|
857
|
+
biome: (outputDir, args) => `npx @biomejs/biome format --write ${args || ""} "${outputDir}"`.trim(),
|
|
858
|
+
prettier: (outputDir, args) => `npx prettier --write ${args || ""} "${outputDir}"`.trim(),
|
|
859
|
+
eslint: (outputDir, args) => `npx eslint --fix ${args || ""} "${outputDir}"`.trim()
|
|
860
|
+
};
|
|
861
|
+
function normalizeFormatOption(format) {
|
|
862
|
+
if (format === false) {
|
|
863
|
+
return null;
|
|
864
|
+
}
|
|
865
|
+
if (format === true) {
|
|
866
|
+
return { tool: "auto" };
|
|
867
|
+
}
|
|
868
|
+
if (typeof format === "string") {
|
|
869
|
+
return { tool: format };
|
|
870
|
+
}
|
|
871
|
+
return format;
|
|
872
|
+
}
|
|
873
|
+
async function detectFormatter() {
|
|
874
|
+
const cwd = import_node_process2.default.cwd();
|
|
875
|
+
const priority = ["biome", "prettier", "eslint"];
|
|
876
|
+
for (const tool of priority) {
|
|
877
|
+
const patterns = FORMATTER_PATTERNS[tool];
|
|
878
|
+
for (const pattern of patterns) {
|
|
879
|
+
const configPath = import_node_path3.default.join(cwd, pattern);
|
|
880
|
+
if (await fileExists(configPath)) {
|
|
881
|
+
return tool;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
return null;
|
|
886
|
+
}
|
|
887
|
+
async function formatOutput(outputDir, format) {
|
|
888
|
+
const config = normalizeFormatOption(format);
|
|
889
|
+
if (!config) {
|
|
890
|
+
return { success: true };
|
|
891
|
+
}
|
|
892
|
+
let tool = null;
|
|
893
|
+
if (config.tool === "auto") {
|
|
894
|
+
tool = await detectFormatter();
|
|
895
|
+
if (!tool) {
|
|
896
|
+
return {
|
|
897
|
+
success: true,
|
|
898
|
+
error: "No formatter detected. Install prettier, eslint, or biome to enable auto-formatting."
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
} else {
|
|
902
|
+
tool = config.tool || "prettier";
|
|
903
|
+
}
|
|
904
|
+
const command = FORMATTER_COMMANDS[tool](outputDir, config.args);
|
|
905
|
+
try {
|
|
906
|
+
await execAsync(command, { cwd: import_node_process2.default.cwd() });
|
|
907
|
+
return { success: true, tool };
|
|
908
|
+
} catch (error) {
|
|
909
|
+
return {
|
|
910
|
+
success: false,
|
|
911
|
+
tool,
|
|
912
|
+
error: `Format failed with ${tool}: ${error.message}`
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
|
|
822
917
|
// src/generators/index.ts
|
|
823
918
|
init_helpers();
|
|
824
919
|
async function generateIcons(config, dryRun = false) {
|
|
@@ -861,6 +956,14 @@ async function generateIcons(config, dryRun = false) {
|
|
|
861
956
|
if (config.generateOptions?.preview && !dryRun) {
|
|
862
957
|
await generatePreviewHtml(svgFiles, config);
|
|
863
958
|
}
|
|
959
|
+
if (config.format && !dryRun) {
|
|
960
|
+
const formatResult = await formatOutput(config.output, config.format);
|
|
961
|
+
if (formatResult.success && formatResult.tool) {
|
|
962
|
+
console.log(`Formatted with ${formatResult.tool}`);
|
|
963
|
+
} else if (formatResult.error) {
|
|
964
|
+
console.warn(formatResult.error);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
864
967
|
if (config.hooks?.onComplete) {
|
|
865
968
|
await config.hooks.onComplete(stats);
|
|
866
969
|
}
|
|
@@ -871,7 +974,7 @@ async function generateIcons(config, dryRun = false) {
|
|
|
871
974
|
}
|
|
872
975
|
async function generateIconComponent(svgFile, config, dryRun = false) {
|
|
873
976
|
let svgContent = await readFile(svgFile);
|
|
874
|
-
const fileName =
|
|
977
|
+
const fileName = import_node_path4.default.basename(svgFile);
|
|
875
978
|
if (config.hooks?.beforeParse) {
|
|
876
979
|
svgContent = await config.hooks.beforeParse(svgContent, fileName);
|
|
877
980
|
}
|
|
@@ -895,7 +998,7 @@ async function generateIconComponent(svgFile, config, dryRun = false) {
|
|
|
895
998
|
code = await config.hooks.afterGenerate(code, componentName);
|
|
896
999
|
}
|
|
897
1000
|
const fileExt = strategy.getComponentExtension(typescript);
|
|
898
|
-
const outputPath =
|
|
1001
|
+
const outputPath = import_node_path4.default.join(config.output, `${componentName}.${fileExt}`);
|
|
899
1002
|
if (dryRun) {
|
|
900
1003
|
console.log(` ${componentName}.${fileExt}`);
|
|
901
1004
|
} else {
|
|
@@ -906,7 +1009,7 @@ async function generateBaseComponent(config, dryRun = false) {
|
|
|
906
1009
|
const typescript = config.typescript ?? true;
|
|
907
1010
|
const strategy = getFrameworkStrategy(config.framework);
|
|
908
1011
|
const { code, fileName } = strategy.generateBaseComponent(typescript);
|
|
909
|
-
const outputPath =
|
|
1012
|
+
const outputPath = import_node_path4.default.join(config.output, fileName);
|
|
910
1013
|
if (dryRun) {
|
|
911
1014
|
console.log(` ${fileName}`);
|
|
912
1015
|
} else {
|
|
@@ -917,9 +1020,9 @@ async function generateIndexFile(svgFiles, config, dryRun = false) {
|
|
|
917
1020
|
const typescript = config.typescript ?? true;
|
|
918
1021
|
const strategy = getFrameworkStrategy(config.framework);
|
|
919
1022
|
const ext = strategy.getIndexExtension(typescript);
|
|
920
|
-
const usesDefaultExport =
|
|
1023
|
+
const usesDefaultExport = ["vue", "svelte", "react", "preact"].includes(config.framework);
|
|
921
1024
|
const exports2 = svgFiles.map((svgFile) => {
|
|
922
|
-
const fileName =
|
|
1025
|
+
const fileName = import_node_path4.default.basename(svgFile);
|
|
923
1026
|
const componentName = getComponentName(
|
|
924
1027
|
fileName,
|
|
925
1028
|
config.prefix,
|
|
@@ -932,7 +1035,7 @@ async function generateIndexFile(svgFiles, config, dryRun = false) {
|
|
|
932
1035
|
return `export { ${componentName} } from './${componentName}'`;
|
|
933
1036
|
}
|
|
934
1037
|
}).join("\n");
|
|
935
|
-
const indexPath =
|
|
1038
|
+
const indexPath = import_node_path4.default.join(config.output, `index.${ext}`);
|
|
936
1039
|
if (dryRun) {
|
|
937
1040
|
console.log(` index.${ext}`);
|
|
938
1041
|
} else {
|
|
@@ -942,7 +1045,7 @@ async function generateIndexFile(svgFiles, config, dryRun = false) {
|
|
|
942
1045
|
}
|
|
943
1046
|
async function generatePreviewHtml(svgFiles, config) {
|
|
944
1047
|
const componentNames = svgFiles.map((svgFile) => {
|
|
945
|
-
const fileName =
|
|
1048
|
+
const fileName = import_node_path4.default.basename(svgFile);
|
|
946
1049
|
return getComponentName(
|
|
947
1050
|
fileName,
|
|
948
1051
|
config.prefix,
|
|
@@ -1114,7 +1217,7 @@ async function generatePreviewHtml(svgFiles, config) {
|
|
|
1114
1217
|
</script>
|
|
1115
1218
|
</body>
|
|
1116
1219
|
</html>`;
|
|
1117
|
-
const previewPath =
|
|
1220
|
+
const previewPath = import_node_path4.default.join(config.output, "preview.html");
|
|
1118
1221
|
await writeFile(previewPath, html);
|
|
1119
1222
|
}
|
|
1120
1223
|
async function cleanOutputDirectory(svgFiles, config) {
|
|
@@ -1123,7 +1226,7 @@ async function cleanOutputDirectory(svgFiles, config) {
|
|
|
1123
1226
|
const fileExt = strategy.getComponentExtension(config.typescript ?? true);
|
|
1124
1227
|
const expectedComponents = new Set(
|
|
1125
1228
|
svgFiles.map((svgFile) => {
|
|
1126
|
-
const fileName =
|
|
1229
|
+
const fileName = import_node_path4.default.basename(svgFile, ".svg");
|
|
1127
1230
|
const componentName = getComponentName(
|
|
1128
1231
|
fileName,
|
|
1129
1232
|
config.prefix,
|
|
@@ -1150,7 +1253,7 @@ async function cleanOutputDirectory(svgFiles, config) {
|
|
|
1150
1253
|
continue;
|
|
1151
1254
|
}
|
|
1152
1255
|
if (!expectedComponents.has(file)) {
|
|
1153
|
-
const filePath =
|
|
1256
|
+
const filePath = import_node_path4.default.join(config.output, file);
|
|
1154
1257
|
await unlink(filePath);
|
|
1155
1258
|
console.log(`Deleted orphaned component: ${file}`);
|
|
1156
1259
|
}
|
|
@@ -1217,8 +1320,8 @@ ${import_chalk.default.bold("Output:")} ${import_chalk.default.cyan(config.outpu
|
|
|
1217
1320
|
}
|
|
1218
1321
|
|
|
1219
1322
|
// src/commands/init.ts
|
|
1220
|
-
var
|
|
1221
|
-
var
|
|
1323
|
+
var import_node_path5 = __toESM(require("path"));
|
|
1324
|
+
var import_node_process3 = __toESM(require("process"));
|
|
1222
1325
|
var import_chalk2 = __toESM(require("chalk"));
|
|
1223
1326
|
var import_inquirer = __toESM(require("inquirer"));
|
|
1224
1327
|
var import_ora2 = __toESM(require("ora"));
|
|
@@ -1226,7 +1329,7 @@ init_helpers();
|
|
|
1226
1329
|
async function init(options = {}) {
|
|
1227
1330
|
try {
|
|
1228
1331
|
const projectRoot = await findProjectRoot();
|
|
1229
|
-
const currentDir =
|
|
1332
|
+
const currentDir = import_node_process3.default.cwd();
|
|
1230
1333
|
if (currentDir !== projectRoot) {
|
|
1231
1334
|
console.log(import_chalk2.default.yellow(`
|
|
1232
1335
|
Note: Project root detected at ${import_chalk2.default.cyan(projectRoot)}`));
|
|
@@ -1247,8 +1350,8 @@ Note: Project root detected at ${import_chalk2.default.cyan(projectRoot)}`));
|
|
|
1247
1350
|
}
|
|
1248
1351
|
}
|
|
1249
1352
|
]);
|
|
1250
|
-
const configPath =
|
|
1251
|
-
const configDir =
|
|
1353
|
+
const configPath = import_node_path5.default.resolve(projectRoot, pathAnswers.configPath);
|
|
1354
|
+
const configDir = import_node_path5.default.dirname(configPath);
|
|
1252
1355
|
if (!options.force && await fileExists(configPath)) {
|
|
1253
1356
|
const { overwrite } = await import_inquirer.default.prompt([
|
|
1254
1357
|
{
|
|
@@ -1312,14 +1415,14 @@ Note: Project root detected at ${import_chalk2.default.cyan(projectRoot)}`));
|
|
|
1312
1415
|
default: ""
|
|
1313
1416
|
}
|
|
1314
1417
|
]);
|
|
1315
|
-
const inputPath =
|
|
1316
|
-
const outputPath =
|
|
1418
|
+
const inputPath = import_node_path5.default.resolve(projectRoot, answers.input);
|
|
1419
|
+
const outputPath = import_node_path5.default.resolve(projectRoot, answers.output);
|
|
1317
1420
|
const spinner = (0, import_ora2.default)("Setting up directories...").start();
|
|
1318
1421
|
await ensureDir(inputPath);
|
|
1319
1422
|
spinner.text = `Created input directory: ${import_chalk2.default.cyan(answers.input)}`;
|
|
1320
1423
|
await ensureDir(outputPath);
|
|
1321
1424
|
spinner.succeed(`Created output directory: ${import_chalk2.default.cyan(answers.output)}`);
|
|
1322
|
-
const relativeConfigDir =
|
|
1425
|
+
const relativeConfigDir = import_node_path5.default.relative(configDir, projectRoot) || ".";
|
|
1323
1426
|
const configContent = generateConfigContent(answers, relativeConfigDir);
|
|
1324
1427
|
spinner.start("Creating config file...");
|
|
1325
1428
|
await writeFile(configPath, configContent);
|
|
@@ -1362,7 +1465,7 @@ export default defineConfig({
|
|
|
1362
1465
|
}
|
|
1363
1466
|
|
|
1364
1467
|
// src/commands/watch.ts
|
|
1365
|
-
var
|
|
1468
|
+
var import_node_path6 = __toESM(require("path"));
|
|
1366
1469
|
var import_chalk3 = __toESM(require("chalk"));
|
|
1367
1470
|
var import_chokidar = __toESM(require("chokidar"));
|
|
1368
1471
|
var import_ora3 = __toESM(require("ora"));
|
|
@@ -1384,7 +1487,7 @@ async function watch(options = {}) {
|
|
|
1384
1487
|
spinner.start("Generating icon components...");
|
|
1385
1488
|
const initialStats = await generateIcons(config);
|
|
1386
1489
|
spinner.succeed(`Generated ${import_chalk3.default.green(initialStats.success)} icon components`);
|
|
1387
|
-
const watchPath =
|
|
1490
|
+
const watchPath = import_node_path6.default.join(config.input, "**/*.svg");
|
|
1388
1491
|
const debounce = config.watch?.debounce ?? 300;
|
|
1389
1492
|
const ignore = config.watch?.ignore ?? ["**/node_modules/**", "**/.git/**"];
|
|
1390
1493
|
console.log(import_chalk3.default.bold("\nWatching for changes..."));
|
|
@@ -1402,7 +1505,7 @@ async function watch(options = {}) {
|
|
|
1402
1505
|
}).on("change", (filePath) => {
|
|
1403
1506
|
handleChange("changed", filePath, config, debounce, debounceTimer);
|
|
1404
1507
|
}).on("unlink", (filePath) => {
|
|
1405
|
-
console.log(import_chalk3.default.yellow(`SVG file removed: ${
|
|
1508
|
+
console.log(import_chalk3.default.yellow(`SVG file removed: ${import_node_path6.default.basename(filePath)}`));
|
|
1406
1509
|
handleChange("removed", filePath, config, debounce, debounceTimer);
|
|
1407
1510
|
}).on("error", (error) => {
|
|
1408
1511
|
console.error(import_chalk3.default.red(`Watcher error: ${error.message}`));
|
|
@@ -1421,7 +1524,7 @@ ${import_chalk3.default.yellow("Stopping watch mode...")}`);
|
|
|
1421
1524
|
}
|
|
1422
1525
|
}
|
|
1423
1526
|
function handleChange(event, filePath, config, debounce, timer) {
|
|
1424
|
-
const fileName =
|
|
1527
|
+
const fileName = import_node_path6.default.basename(filePath);
|
|
1425
1528
|
if (timer) {
|
|
1426
1529
|
clearTimeout(timer);
|
|
1427
1530
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
1
3
|
{{#if typescript}}
|
|
2
4
|
import type { IconNode } from 'vectify'
|
|
3
5
|
{{/if}}
|
|
4
6
|
import { createIcon } from './createIcon'
|
|
5
7
|
|
|
6
8
|
export const iconNode{{#if typescript}}: IconNode[]{{/if}} = [
|
|
7
|
-
{{{formattedNodes}}}
|
|
9
|
+
{{{formattedNodes}}},
|
|
8
10
|
]
|
|
9
11
|
|
|
10
12
|
const {{componentName}} = createIcon('{{componentName}}', iconNode, {{keepColors}})
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import type { ForwardRefExoticComponent, ReactNode, RefAttributes, SVGProps } from 'react'
|
|
2
4
|
import type { IconNode, IconProps } from 'vectify'
|
|
3
|
-
import
|
|
5
|
+
import { createElement, forwardRef } from 'react'
|
|
4
6
|
|
|
5
7
|
export interface CreateIconProps extends IconProps, Omit<SVGProps<SVGSVGElement>, keyof IconProps> {
|
|
6
|
-
size?: number | string
|
|
7
|
-
color?: string
|
|
8
|
-
strokeWidth?: number | string
|
|
9
|
-
className?: string
|
|
10
|
-
title?: string
|
|
8
|
+
'size'?: number | string
|
|
9
|
+
'color'?: string
|
|
10
|
+
'strokeWidth'?: number | string
|
|
11
|
+
'className'?: string
|
|
12
|
+
'title'?: string
|
|
11
13
|
'aria-label'?: string
|
|
12
14
|
'aria-hidden'?: boolean | 'true' | 'false'
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
export function createIcon(name: string, iconNode: IconNode[], keepColors = false) {
|
|
17
|
+
export function createIcon(name: string, iconNode: IconNode[], keepColors = false): ForwardRefExoticComponent<CreateIconProps & RefAttributes<SVGSVGElement>> {
|
|
16
18
|
const Icon = forwardRef<SVGSVGElement, CreateIconProps>(({
|
|
17
19
|
size = 24,
|
|
18
20
|
color = 'currentColor',
|
|
@@ -56,7 +58,7 @@ function renderIconNode(
|
|
|
56
58
|
nodes: IconNode[],
|
|
57
59
|
keepColors: boolean,
|
|
58
60
|
color: string,
|
|
59
|
-
strokeWidth: number | string
|
|
61
|
+
strokeWidth: number | string,
|
|
60
62
|
): ReactNode {
|
|
61
63
|
return nodes.map((node, index) => {
|
|
62
64
|
const [type, attrs, children] = node
|
|
@@ -65,7 +67,8 @@ function renderIconNode(
|
|
|
65
67
|
|
|
66
68
|
if (keepColors) {
|
|
67
69
|
cleanedAttrs = attrs
|
|
68
|
-
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
69
72
|
// Track color attributes to determine icon type
|
|
70
73
|
let hasFill = false
|
|
71
74
|
let hasStroke = false
|
|
@@ -86,14 +89,15 @@ function renderIconNode(
|
|
|
86
89
|
// Keep non-color attributes
|
|
87
90
|
cleanedAttrs = Object.fromEntries(
|
|
88
91
|
Object.entries(attrs).filter(([key]) =>
|
|
89
|
-
!['stroke', 'fill', 'strokeWidth', 'stroke-width'].includes(key)
|
|
90
|
-
)
|
|
92
|
+
!['stroke', 'fill', 'strokeWidth', 'stroke-width'].includes(key),
|
|
93
|
+
),
|
|
91
94
|
)
|
|
92
95
|
|
|
93
96
|
// Apply color based on original attributes
|
|
94
97
|
if (hasFill) {
|
|
95
98
|
cleanedAttrs.fill = color
|
|
96
|
-
}
|
|
99
|
+
}
|
|
100
|
+
else if (hasStroke) {
|
|
97
101
|
cleanedAttrs.fill = 'none'
|
|
98
102
|
cleanedAttrs.stroke = color
|
|
99
103
|
cleanedAttrs.strokeWidth = originalStrokeWidth ?? strokeWidth
|
|
@@ -108,7 +112,7 @@ function renderIconNode(
|
|
|
108
112
|
return createElement(
|
|
109
113
|
type,
|
|
110
114
|
props,
|
|
111
|
-
renderIconNode(children, keepColors, color, strokeWidth)
|
|
115
|
+
renderIconNode(children, keepColors, color, strokeWidth),
|
|
112
116
|
)
|
|
113
117
|
}
|
|
114
118
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vectify",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
|
+
"packageManager": "pnpm@9.15.9",
|
|
4
5
|
"description": "A powerful command-line tool to generate React, Vue, and Svelte icon components from SVG files",
|
|
5
6
|
"author": "Xiaobing Zhu <hellozxb252@gmail.com>",
|
|
6
7
|
"license": "MIT",
|
|
@@ -44,6 +45,16 @@
|
|
|
44
45
|
"engines": {
|
|
45
46
|
"node": ">=18.0.0"
|
|
46
47
|
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsup",
|
|
50
|
+
"dev": "tsup --watch",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"test:watch": "vitest",
|
|
53
|
+
"lint": "eslint .",
|
|
54
|
+
"lint:fix": "eslint . --fix",
|
|
55
|
+
"prepublishOnly": "pnpm build",
|
|
56
|
+
"clean": "rm -rf dist"
|
|
57
|
+
},
|
|
47
58
|
"dependencies": {
|
|
48
59
|
"chalk": "^5.3.0",
|
|
49
60
|
"cheerio": "^1.1.2",
|
|
@@ -65,14 +76,5 @@
|
|
|
65
76
|
"tsup": "^8.5.1",
|
|
66
77
|
"typescript": "^5.9.3",
|
|
67
78
|
"vitest": "^4.0.17"
|
|
68
|
-
},
|
|
69
|
-
"scripts": {
|
|
70
|
-
"build": "tsup",
|
|
71
|
-
"dev": "tsup --watch",
|
|
72
|
-
"test": "vitest run",
|
|
73
|
-
"test:watch": "vitest",
|
|
74
|
-
"lint": "eslint .",
|
|
75
|
-
"lint:fix": "eslint . --fix",
|
|
76
|
-
"clean": "rm -rf dist"
|
|
77
79
|
}
|
|
78
|
-
}
|
|
80
|
+
}
|