vectify 2.0.0
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/LICENSE +21 -0
- package/README.md +679 -0
- package/README.zh-CN.md +683 -0
- package/dist/chunk-4BWKFV7W.mjs +1311 -0
- package/dist/chunk-CIKTK6HI.mjs +96 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1483 -0
- package/dist/cli.mjs +56 -0
- package/dist/helpers-UPZEBRGK.mjs +26 -0
- package/dist/index.d.mts +281 -0
- package/dist/index.d.ts +281 -0
- package/dist/index.js +1463 -0
- package/dist/index.mjs +27 -0
- package/dist/templates/angular/component.ts.hbs +121 -0
- package/dist/templates/angular/createIcon.ts.hbs +116 -0
- package/dist/templates/astro/component.astro.hbs +110 -0
- package/dist/templates/astro/createIcon.astro.hbs +111 -0
- package/dist/templates/lit/component.js.hbs +12 -0
- package/dist/templates/lit/component.ts.hbs +19 -0
- package/dist/templates/lit/createIcon.js.hbs +98 -0
- package/dist/templates/lit/createIcon.ts.hbs +99 -0
- package/dist/templates/preact/component.jsx.hbs +8 -0
- package/dist/templates/preact/component.tsx.hbs +11 -0
- package/dist/templates/preact/createIcon.jsx.hbs +101 -0
- package/dist/templates/preact/createIcon.tsx.hbs +121 -0
- package/dist/templates/qwik/component.jsx.hbs +7 -0
- package/dist/templates/qwik/component.tsx.hbs +8 -0
- package/dist/templates/qwik/createIcon.jsx.hbs +100 -0
- package/dist/templates/qwik/createIcon.tsx.hbs +111 -0
- package/dist/templates/react/component.jsx.hbs +8 -0
- package/dist/templates/react/component.tsx.hbs +11 -0
- package/dist/templates/react/createIcon.jsx.hbs +100 -0
- package/dist/templates/react/createIcon.tsx.hbs +117 -0
- package/dist/templates/solid/component.tsx.hbs +10 -0
- package/dist/templates/solid/createIcon.jsx.hbs +127 -0
- package/dist/templates/solid/createIcon.tsx.hbs +139 -0
- package/dist/templates/svelte/component.js.svelte.hbs +9 -0
- package/dist/templates/svelte/component.ts.svelte.hbs +10 -0
- package/dist/templates/svelte/icon.js.svelte.hbs +123 -0
- package/dist/templates/svelte/icon.ts.svelte.hbs +124 -0
- package/dist/templates/template-engine.ts +107 -0
- package/dist/templates/vanilla/component.ts.hbs +8 -0
- package/dist/templates/vanilla/createIcon.js.hbs +111 -0
- package/dist/templates/vanilla/createIcon.ts.hbs +124 -0
- package/dist/templates/vue/component.js.vue.hbs +21 -0
- package/dist/templates/vue/component.ts.vue.hbs +22 -0
- package/dist/templates/vue/icon.js.vue.hbs +155 -0
- package/dist/templates/vue/icon.ts.vue.hbs +157 -0
- package/package.json +78 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// src/utils/helpers.ts
|
|
2
|
+
function toPascalCase(str) {
|
|
3
|
+
return str.replace(/[-_](.)/g, (_, char) => char.toUpperCase()).replace(/^(.)/, (char) => char.toUpperCase()).replace(/[^a-z0-9]/gi, "");
|
|
4
|
+
}
|
|
5
|
+
function toKebabCase(str) {
|
|
6
|
+
return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
7
|
+
}
|
|
8
|
+
function mergeClasses(...classes) {
|
|
9
|
+
return classes.filter(Boolean).join(" ");
|
|
10
|
+
}
|
|
11
|
+
function getComponentName(fileName, prefix = "", suffix = "", transform) {
|
|
12
|
+
const baseName = fileName.replace(/\.svg$/, "");
|
|
13
|
+
let componentName = toPascalCase(baseName);
|
|
14
|
+
if (transform) {
|
|
15
|
+
componentName = transform(componentName);
|
|
16
|
+
}
|
|
17
|
+
return `${prefix}${componentName}${suffix}`;
|
|
18
|
+
}
|
|
19
|
+
function formatAttributes(attrs) {
|
|
20
|
+
const entries = Object.entries(attrs);
|
|
21
|
+
if (entries.length === 0)
|
|
22
|
+
return "{}";
|
|
23
|
+
const formatted = entries.map(([key, value]) => {
|
|
24
|
+
if (typeof value === "number") {
|
|
25
|
+
return `${key}: ${value}`;
|
|
26
|
+
}
|
|
27
|
+
return `${key}: '${value}'`;
|
|
28
|
+
}).join(", ");
|
|
29
|
+
return `{ ${formatted} }`;
|
|
30
|
+
}
|
|
31
|
+
async function ensureDir(dirPath) {
|
|
32
|
+
const fs = await import("fs/promises");
|
|
33
|
+
try {
|
|
34
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (error.code !== "EEXIST") {
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function fileExists(filePath) {
|
|
42
|
+
const fs = await import("fs/promises");
|
|
43
|
+
try {
|
|
44
|
+
await fs.access(filePath);
|
|
45
|
+
return true;
|
|
46
|
+
} catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function readFile(filePath) {
|
|
51
|
+
const fs = await import("fs/promises");
|
|
52
|
+
return await fs.readFile(filePath, "utf-8");
|
|
53
|
+
}
|
|
54
|
+
async function writeFile(filePath, content) {
|
|
55
|
+
const fs = await import("fs/promises");
|
|
56
|
+
await fs.writeFile(filePath, content, "utf-8");
|
|
57
|
+
}
|
|
58
|
+
async function getSvgFiles(dirPath) {
|
|
59
|
+
const fs = await import("fs/promises");
|
|
60
|
+
const path = await import("path");
|
|
61
|
+
try {
|
|
62
|
+
const files = await fs.readdir(dirPath);
|
|
63
|
+
return files.filter((file) => file.endsWith(".svg")).map((file) => path.join(dirPath, file));
|
|
64
|
+
} catch {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function findProjectRoot(startDir = process.cwd()) {
|
|
69
|
+
const path = await import("path");
|
|
70
|
+
let currentDir = startDir;
|
|
71
|
+
while (true) {
|
|
72
|
+
const packageJsonPath = path.join(currentDir, "package.json");
|
|
73
|
+
if (await fileExists(packageJsonPath)) {
|
|
74
|
+
return currentDir;
|
|
75
|
+
}
|
|
76
|
+
const parentDir = path.dirname(currentDir);
|
|
77
|
+
if (parentDir === currentDir) {
|
|
78
|
+
return startDir;
|
|
79
|
+
}
|
|
80
|
+
currentDir = parentDir;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
toPascalCase,
|
|
86
|
+
toKebabCase,
|
|
87
|
+
mergeClasses,
|
|
88
|
+
getComponentName,
|
|
89
|
+
formatAttributes,
|
|
90
|
+
ensureDir,
|
|
91
|
+
fileExists,
|
|
92
|
+
readFile,
|
|
93
|
+
writeFile,
|
|
94
|
+
getSvgFiles,
|
|
95
|
+
findProjectRoot
|
|
96
|
+
};
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|