svger-cli 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/dist/cli.js +0 -0
- package/dist/core/error-handler.d.ts +63 -0
- package/dist/core/error-handler.js +224 -0
- package/dist/core/framework-templates.d.ts +17 -0
- package/{src/core/framework-templates.ts → dist/core/framework-templates.js} +100 -137
- package/dist/core/logger.d.ts +22 -0
- package/dist/core/logger.js +85 -0
- package/dist/core/performance-engine.d.ts +67 -0
- package/dist/core/performance-engine.js +251 -0
- package/dist/core/plugin-manager.d.ts +56 -0
- package/dist/core/plugin-manager.js +189 -0
- package/dist/core/style-compiler.d.ts +88 -0
- package/dist/core/style-compiler.js +466 -0
- package/dist/core/template-manager.d.ts +64 -0
- package/{src/core/template-manager.ts → dist/core/template-manager.js} +172 -255
- package/dist/index.d.ts +151 -0
- package/{src/index.ts → dist/index.js} +30 -108
- package/dist/processors/svg-processor.d.ts +67 -0
- package/dist/processors/svg-processor.js +225 -0
- package/dist/services/config.d.ts +55 -0
- package/dist/services/config.js +209 -0
- package/dist/services/file-watcher.d.ts +54 -0
- package/dist/services/file-watcher.js +180 -0
- package/dist/services/svg-service.d.ts +81 -0
- package/dist/services/svg-service.js +383 -0
- package/dist/types/index.d.ts +140 -0
- package/dist/types/index.js +4 -0
- package/dist/utils/native.d.ts +74 -0
- package/dist/utils/native.js +305 -0
- package/package.json +9 -3
- package/.svgconfig.json +0 -3
- package/CODE_OF_CONDUCT.md +0 -79
- package/CONTRIBUTING.md +0 -146
- package/TESTING.md +0 -143
- package/cli-framework.test.js +0 -16
- package/cli-test-angular/Arrowbenddownleft.component.ts +0 -27
- package/cli-test-angular/Vite.component.ts +0 -27
- package/cli-test-angular/index.ts +0 -25
- package/cli-test-output/Arrowbenddownleft.vue +0 -33
- package/cli-test-output/Vite.vue +0 -33
- package/cli-test-output/index.ts +0 -25
- package/cli-test-react/Arrowbenddownleft.tsx +0 -39
- package/cli-test-react/Vite.tsx +0 -39
- package/cli-test-react/index.ts +0 -25
- package/cli-test-svelte/Arrowbenddownleft.svelte +0 -22
- package/cli-test-svelte/Vite.svelte +0 -22
- package/cli-test-svelte/index.ts +0 -25
- package/docs/ADR-SVG-INTRGRATION-METHODS-001.adr.md +0 -157
- package/docs/ADR-SVG-INTRGRATION-METHODS-002.adr.md +0 -550
- package/docs/FRAMEWORK-GUIDE.md +0 -768
- package/docs/IMPLEMENTATION-SUMMARY.md +0 -376
- package/docs/TDR-SVG-INTRGRATION-METHODS-001.tdr.md +0 -115
- package/frameworks.test.js +0 -170
- package/my-svgs/ArrowBendDownLeft.svg +0 -6
- package/my-svgs/vite.svg +0 -1
- package/src/builder.ts +0 -104
- package/src/clean.ts +0 -21
- package/src/cli.ts +0 -221
- package/src/config.ts +0 -81
- package/src/core/error-handler.ts +0 -303
- package/src/core/logger.ts +0 -104
- package/src/core/performance-engine.ts +0 -327
- package/src/core/plugin-manager.ts +0 -228
- package/src/core/style-compiler.ts +0 -605
- package/src/lock.ts +0 -74
- package/src/processors/svg-processor.ts +0 -288
- package/src/services/config.ts +0 -241
- package/src/services/file-watcher.ts +0 -218
- package/src/services/svg-service.ts +0 -468
- package/src/templates/ComponentTemplate.ts +0 -57
- package/src/types/index.ts +0 -169
- package/src/utils/native.ts +0 -352
- package/src/watch.ts +0 -88
- package/test-output-mulit/TestIcon-angular-module.component.ts +0 -26
- package/test-output-mulit/TestIcon-angular-standalone.component.ts +0 -27
- package/test-output-mulit/TestIcon-lit.ts +0 -35
- package/test-output-mulit/TestIcon-preact.tsx +0 -38
- package/test-output-mulit/TestIcon-react.tsx +0 -35
- package/test-output-mulit/TestIcon-solid.tsx +0 -27
- package/test-output-mulit/TestIcon-svelte.svelte +0 -22
- package/test-output-mulit/TestIcon-vanilla.ts +0 -37
- package/test-output-mulit/TestIcon-vue-composition.vue +0 -33
- package/test-output-mulit/TestIcon-vue-options.vue +0 -31
- package/tsconfig.json +0 -18
package/src/builder.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { toPascalCase, FileSystem } from "./utils/native.js";
|
|
3
|
-
import { isLocked } from "./lock.js";
|
|
4
|
-
import { readConfig } from "./config.js";
|
|
5
|
-
import { reactTemplate } from "./templates/ComponentTemplate.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Converts all SVG files from a source directory into React components and writes them to an output directory.
|
|
9
|
-
*
|
|
10
|
-
* @param {Object} config - Configuration object.
|
|
11
|
-
* @param {string} config.src - Path to the source folder containing SVG files.
|
|
12
|
-
* @param {string} config.out - Path to the output folder where React components will be generated.
|
|
13
|
-
* @returns {Promise<void>} Resolves when all SVGs have been processed.
|
|
14
|
-
*/
|
|
15
|
-
export async function buildAll(config: { src: string; out: string }) {
|
|
16
|
-
const svgConfig = readConfig();
|
|
17
|
-
const srcDir = path.resolve(config.src);
|
|
18
|
-
const outDir = path.resolve(config.out);
|
|
19
|
-
|
|
20
|
-
if (!(await FileSystem.exists(srcDir))) {
|
|
21
|
-
console.error("❌ Source folder not found:", srcDir);
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
await FileSystem.ensureDir(outDir);
|
|
26
|
-
const files = (await FileSystem.readDir(srcDir)).filter((f: string) => f.endsWith(".svg"));
|
|
27
|
-
|
|
28
|
-
if (!files.length) {
|
|
29
|
-
console.log("⚠️ No SVG files found in", srcDir);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
for (const file of files) {
|
|
34
|
-
const svgPath = path.join(srcDir, file);
|
|
35
|
-
|
|
36
|
-
if (isLocked(svgPath)) {
|
|
37
|
-
console.log(`⚠️ Skipped locked file: ${file}`);
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const svgContent = await FileSystem.readFile(svgPath, "utf-8");
|
|
42
|
-
const componentName = toPascalCase(file.replace(".svg", ""));
|
|
43
|
-
const componentCode = reactTemplate({
|
|
44
|
-
componentName,
|
|
45
|
-
svgContent,
|
|
46
|
-
defaultWidth: svgConfig.defaultWidth,
|
|
47
|
-
defaultHeight: svgConfig.defaultHeight,
|
|
48
|
-
defaultFill: svgConfig.defaultFill,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const outFile = path.join(outDir, `${componentName}.tsx`);
|
|
52
|
-
await FileSystem.writeFile(outFile, componentCode, "utf-8");
|
|
53
|
-
console.log(`✅ Generated: ${componentName}.tsx`);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
console.log("🎉 All SVGs have been converted successfully!");
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Generates a single React component from an SVG file.
|
|
61
|
-
*
|
|
62
|
-
* @param {Object} params - Parameters object.
|
|
63
|
-
* @param {string} params.svgFile - Path to the SVG file to be converted.
|
|
64
|
-
* @param {string} params.outDir - Path to the output folder for the generated component.
|
|
65
|
-
* @returns {Promise<void>} Resolves when the SVG has been converted.
|
|
66
|
-
*/
|
|
67
|
-
export async function generateSVG({
|
|
68
|
-
svgFile,
|
|
69
|
-
outDir,
|
|
70
|
-
}: {
|
|
71
|
-
svgFile: string;
|
|
72
|
-
outDir: string;
|
|
73
|
-
}) {
|
|
74
|
-
const svgConfig = readConfig();
|
|
75
|
-
const filePath = path.resolve(svgFile);
|
|
76
|
-
|
|
77
|
-
if (isLocked(filePath)) {
|
|
78
|
-
console.log(`⚠️ Skipped locked file: ${path.basename(svgFile)}`);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (!(await FileSystem.exists(filePath))) {
|
|
83
|
-
console.error("❌ SVG file not found:", filePath);
|
|
84
|
-
process.exit(1);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const svgContent = await FileSystem.readFile(filePath, "utf-8");
|
|
88
|
-
const componentName = toPascalCase(path.basename(svgFile, ".svg"));
|
|
89
|
-
const componentCode = reactTemplate({
|
|
90
|
-
componentName,
|
|
91
|
-
svgContent,
|
|
92
|
-
defaultWidth: svgConfig.defaultWidth,
|
|
93
|
-
defaultHeight: svgConfig.defaultHeight,
|
|
94
|
-
defaultFill: svgConfig.defaultFill,
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const outputFolder = path.resolve(outDir);
|
|
98
|
-
await FileSystem.ensureDir(outputFolder);
|
|
99
|
-
|
|
100
|
-
const outFile = path.join(outputFolder, `${componentName}.tsx`);
|
|
101
|
-
await FileSystem.writeFile(outFile, componentCode, "utf-8");
|
|
102
|
-
|
|
103
|
-
console.log(`✅ Generated: ${componentName}.tsx`);
|
|
104
|
-
}
|
package/src/clean.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { FileSystem } from "./utils/native.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Cleans the specified output directory by removing all files and folders inside it.
|
|
6
|
-
* Typically used to clear previously generated SVG React components before a new build.
|
|
7
|
-
*
|
|
8
|
-
* @param {string} outDir - Path to the output directory to be cleaned.
|
|
9
|
-
* @returns {Promise<void>} Resolves when the directory has been emptied.
|
|
10
|
-
*/
|
|
11
|
-
export async function clean(outDir: string) {
|
|
12
|
-
const targetDir = path.resolve(outDir);
|
|
13
|
-
|
|
14
|
-
if (!(await FileSystem.exists(targetDir))) {
|
|
15
|
-
console.log(`⚠️ Directory not found: ${targetDir}`);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
await FileSystem.emptyDir(targetDir);
|
|
20
|
-
console.log(`🧹 Cleaned all generated SVG components in: ${targetDir}`);
|
|
21
|
-
}
|
package/src/cli.ts
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { CLI } from "./utils/native.js";
|
|
3
|
-
import { svgService } from "./services/svg-service.js";
|
|
4
|
-
import { configService } from "./services/config.js";
|
|
5
|
-
import { logger } from "./core/logger.js";
|
|
6
|
-
|
|
7
|
-
const program = new CLI();
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* svger-cli CLI
|
|
11
|
-
* Custom SVG to Angular, React, Vue, Svelte, Solid, and other component converter.
|
|
12
|
-
*/
|
|
13
|
-
program
|
|
14
|
-
.name("svger-cli")
|
|
15
|
-
.description("Custom SVG to Angular, React, Vue, Svelte, Solid, and other component converter")
|
|
16
|
-
.version("2.0.0");
|
|
17
|
-
|
|
18
|
-
// -------- Build Command --------
|
|
19
|
-
/**
|
|
20
|
-
* Build all SVGs from a source folder to an output folder.
|
|
21
|
-
*/
|
|
22
|
-
program
|
|
23
|
-
.command("build <src> <out>")
|
|
24
|
-
.description("Build all SVGs from source to output")
|
|
25
|
-
.option("--framework <type>", "Target framework (react|vue|svelte|angular|solid|preact|lit|vanilla)")
|
|
26
|
-
.option("--typescript", "Generate TypeScript components (default: true)")
|
|
27
|
-
.option("--no-typescript", "Generate JavaScript components")
|
|
28
|
-
.option("--composition", "Use Vue Composition API with <script setup>")
|
|
29
|
-
.option("--standalone", "Generate Angular standalone components")
|
|
30
|
-
.option("--signals", "Use Angular signals for reactive state")
|
|
31
|
-
.action(async (args: string[], opts: Record<string, any>) => {
|
|
32
|
-
try {
|
|
33
|
-
const [src, out] = args;
|
|
34
|
-
|
|
35
|
-
// Build config from CLI options
|
|
36
|
-
const buildConfig: any = { src, out };
|
|
37
|
-
|
|
38
|
-
if (opts.framework) {
|
|
39
|
-
buildConfig.framework = opts.framework;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (opts.typescript !== undefined) {
|
|
43
|
-
buildConfig.typescript = opts.typescript;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Framework-specific options
|
|
47
|
-
const frameworkOptions: any = {};
|
|
48
|
-
|
|
49
|
-
if (opts.composition !== undefined) {
|
|
50
|
-
frameworkOptions.scriptSetup = opts.composition;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (opts.standalone !== undefined) {
|
|
54
|
-
frameworkOptions.standalone = opts.standalone;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (opts.signals !== undefined) {
|
|
58
|
-
frameworkOptions.signals = opts.signals;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (Object.keys(frameworkOptions).length > 0) {
|
|
62
|
-
buildConfig.frameworkOptions = frameworkOptions;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
await svgService.buildAll(buildConfig);
|
|
66
|
-
} catch (error) {
|
|
67
|
-
logger.error('Build failed:', error);
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// -------- Watch Command --------
|
|
73
|
-
/**
|
|
74
|
-
* Watch a source folder and rebuild SVGs automatically on changes.
|
|
75
|
-
*/
|
|
76
|
-
program
|
|
77
|
-
.command("watch <src> <out>")
|
|
78
|
-
.description("Watch source folder and rebuild SVGs automatically")
|
|
79
|
-
.action(async (args: string[]) => {
|
|
80
|
-
try {
|
|
81
|
-
const [src, out] = args;
|
|
82
|
-
await svgService.startWatching({ src, out });
|
|
83
|
-
|
|
84
|
-
// Keep the process running
|
|
85
|
-
process.on('SIGINT', () => {
|
|
86
|
-
logger.info('Shutting down watch mode...');
|
|
87
|
-
svgService.shutdown();
|
|
88
|
-
process.exit(0);
|
|
89
|
-
});
|
|
90
|
-
} catch (error) {
|
|
91
|
-
logger.error('Watch mode failed:', error);
|
|
92
|
-
process.exit(1);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// -------- Generate Single SVG --------
|
|
97
|
-
/**
|
|
98
|
-
* Generate a component from a single SVG file.
|
|
99
|
-
*/
|
|
100
|
-
program
|
|
101
|
-
.command("generate <svgFile> <out>")
|
|
102
|
-
.description("Convert a single SVG file into a component")
|
|
103
|
-
.option("--framework <type>", "Target framework (react|vue|svelte|angular|solid|preact|lit|vanilla)")
|
|
104
|
-
.option("--typescript", "Generate TypeScript component (default: true)")
|
|
105
|
-
.option("--no-typescript", "Generate JavaScript component")
|
|
106
|
-
.option("--composition", "Use Vue Composition API with <script setup>")
|
|
107
|
-
.option("--standalone", "Generate Angular standalone component")
|
|
108
|
-
.action(async (args: string[], opts: Record<string, any>) => {
|
|
109
|
-
try {
|
|
110
|
-
const [svgFile, out] = args;
|
|
111
|
-
|
|
112
|
-
const generateConfig: any = { svgFile, outDir: out };
|
|
113
|
-
|
|
114
|
-
if (opts.framework) {
|
|
115
|
-
generateConfig.framework = opts.framework;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (opts.typescript !== undefined) {
|
|
119
|
-
generateConfig.typescript = opts.typescript;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const frameworkOptions: any = {};
|
|
123
|
-
|
|
124
|
-
if (opts.composition !== undefined) {
|
|
125
|
-
frameworkOptions.scriptSetup = opts.composition;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (opts.standalone !== undefined) {
|
|
129
|
-
frameworkOptions.standalone = opts.standalone;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (Object.keys(frameworkOptions).length > 0) {
|
|
133
|
-
generateConfig.frameworkOptions = frameworkOptions;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
await svgService.generateSingle(generateConfig);
|
|
137
|
-
} catch (error) {
|
|
138
|
-
logger.error('Generation failed:', error);
|
|
139
|
-
process.exit(1);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
// -------- Lock / Unlock --------
|
|
144
|
-
/**
|
|
145
|
-
* Lock one or more SVG files to prevent accidental overwrites.
|
|
146
|
-
*/
|
|
147
|
-
program
|
|
148
|
-
.command("lock <files...>")
|
|
149
|
-
.description("Lock one or more SVG files")
|
|
150
|
-
.action((args: string[]) => {
|
|
151
|
-
try {
|
|
152
|
-
svgService.lockService.lockFiles(args);
|
|
153
|
-
} catch (error) {
|
|
154
|
-
logger.error('Lock operation failed:', error);
|
|
155
|
-
process.exit(1);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Unlock one or more SVG files to allow modifications.
|
|
161
|
-
*/
|
|
162
|
-
program
|
|
163
|
-
.command("unlock <files...>")
|
|
164
|
-
.description("Unlock one or more SVG files")
|
|
165
|
-
.action((args: string[]) => {
|
|
166
|
-
try {
|
|
167
|
-
svgService.lockService.unlockFiles(args);
|
|
168
|
-
} catch (error) {
|
|
169
|
-
logger.error('Unlock operation failed:', error);
|
|
170
|
-
process.exit(1);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
// -------- Config --------
|
|
175
|
-
/**
|
|
176
|
-
* Manage svger-cli configuration.
|
|
177
|
-
*/
|
|
178
|
-
program
|
|
179
|
-
.command("config")
|
|
180
|
-
.description("Manage svger-cli configuration")
|
|
181
|
-
.option("--init", "Create default .svgconfig.json")
|
|
182
|
-
.option("--set <keyValue>", "Set config key=value")
|
|
183
|
-
.option("--show", "Show current config")
|
|
184
|
-
.action(async (args: string[], opts: Record<string, any>) => {
|
|
185
|
-
try {
|
|
186
|
-
if (opts.init) return await configService.initConfig();
|
|
187
|
-
if (opts.set) {
|
|
188
|
-
const [key, value] = opts.set.split("=");
|
|
189
|
-
if (!key || value === undefined) {
|
|
190
|
-
logger.error("Invalid format. Use key=value");
|
|
191
|
-
process.exit(1);
|
|
192
|
-
}
|
|
193
|
-
const parsedValue = !isNaN(Number(value)) ? Number(value) : value;
|
|
194
|
-
return configService.setConfig(key, parsedValue);
|
|
195
|
-
}
|
|
196
|
-
if (opts.show) return configService.showConfig();
|
|
197
|
-
logger.error("No option provided. Use --init, --set, or --show");
|
|
198
|
-
} catch (error) {
|
|
199
|
-
logger.error('Config operation failed:', error);
|
|
200
|
-
process.exit(1);
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
// -------- Clean Command --------
|
|
205
|
-
/**
|
|
206
|
-
* Remove all generated SVG React components from an output folder.
|
|
207
|
-
*/
|
|
208
|
-
program
|
|
209
|
-
.command("clean <out>")
|
|
210
|
-
.description("Remove all generated SVG React components from output folder")
|
|
211
|
-
.action(async (args: string[]) => {
|
|
212
|
-
try {
|
|
213
|
-
const [out] = args;
|
|
214
|
-
await svgService.clean(out);
|
|
215
|
-
} catch (error) {
|
|
216
|
-
logger.error('Clean operation failed:', error);
|
|
217
|
-
process.exit(1);
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
program.parse();
|
package/src/config.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { FileSystem } from "./utils/native.js";
|
|
3
|
-
|
|
4
|
-
const CONFIG_FILE = ".svgconfig.json";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Get the absolute path to the configuration file.
|
|
8
|
-
*
|
|
9
|
-
* @returns {string} Absolute path to .svgconfig.json
|
|
10
|
-
*/
|
|
11
|
-
function getConfigPath(): string {
|
|
12
|
-
return path.resolve(CONFIG_FILE);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Read the current svger-cli configuration.
|
|
17
|
-
*
|
|
18
|
-
* @returns {Record<string, any>} Configuration object. Returns an empty object if no config file exists.
|
|
19
|
-
*/
|
|
20
|
-
export function readConfig(): Record<string, any> {
|
|
21
|
-
return FileSystem.readJSONSync(getConfigPath());
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Write a configuration object to the config file.
|
|
26
|
-
*
|
|
27
|
-
* @param {Record<string, any>} config - Configuration object to write.
|
|
28
|
-
*/
|
|
29
|
-
export function writeConfig(config: Record<string, any>) {
|
|
30
|
-
FileSystem.writeJSONSync(getConfigPath(), config, { spaces: 2 });
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Initialize the svger-cli configuration with default values.
|
|
35
|
-
* If a config file already exists, this function will not overwrite it.
|
|
36
|
-
*/
|
|
37
|
-
export async function initConfig() {
|
|
38
|
-
if (await FileSystem.exists(getConfigPath())) {
|
|
39
|
-
console.log("⚠️ Config file already exists:", getConfigPath());
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const defaultConfig = {
|
|
44
|
-
source: "./src/assets/svg",
|
|
45
|
-
output: "./src/components/icons",
|
|
46
|
-
watch: false,
|
|
47
|
-
defaultWidth: 24,
|
|
48
|
-
defaultHeight: 24,
|
|
49
|
-
defaultFill: "currentColor",
|
|
50
|
-
exclude: [] as string[],
|
|
51
|
-
styleRules: {
|
|
52
|
-
fill: "inherit",
|
|
53
|
-
stroke: "none",
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
writeConfig(defaultConfig);
|
|
58
|
-
console.log("✅ Config file created:", getConfigPath());
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Set a specific configuration key to a new value.
|
|
63
|
-
*
|
|
64
|
-
* @param {string} key - The config key to set.
|
|
65
|
-
* @param {any} value - The value to assign to the key.
|
|
66
|
-
*/
|
|
67
|
-
export function setConfig(key: string, value: any) {
|
|
68
|
-
const config = readConfig();
|
|
69
|
-
config[key] = value;
|
|
70
|
-
writeConfig(config);
|
|
71
|
-
console.log(`✅ Set config ${key}=${value}`);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Display the current configuration in the console.
|
|
76
|
-
*/
|
|
77
|
-
export function showConfig() {
|
|
78
|
-
const config = readConfig();
|
|
79
|
-
console.log("📄 Current Config:");
|
|
80
|
-
console.log(JSON.stringify(config, null, 2));
|
|
81
|
-
}
|