@wkovacs64/add-icon 1.1.0 → 1.2.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/dist/index.js +33 -3
- package/package.json +2 -4
package/dist/index.js
CHANGED
|
@@ -15,16 +15,46 @@ const setupProgram = async () => {
|
|
|
15
15
|
return program
|
|
16
16
|
.name(name.split('/').pop() || name)
|
|
17
17
|
.description(description)
|
|
18
|
-
.
|
|
19
|
-
.argument('<icons...>', 'Icon references (e.g., heroicons:arrow-up-circle mdi:home)')
|
|
18
|
+
.option('--init', 'Generate a config file in the current directory')
|
|
20
19
|
.option('-o, --output-dir <dir>', 'Directory to save icons')
|
|
21
20
|
.option('-c, --config <path>', 'Path to config file')
|
|
22
|
-
.option('-t, --transform <path>', 'Path to custom transform module (.js or .ts)')
|
|
21
|
+
.option('-t, --transform <path>', 'Path to custom transform module (.js or .ts)')
|
|
22
|
+
.version(version, '-v, --version', 'Output the current version')
|
|
23
|
+
.argument('[icons...]', 'Icon references (e.g., heroicons:arrow-up-circle mdi:home)');
|
|
23
24
|
};
|
|
24
25
|
// Initialize the program
|
|
25
26
|
const initializedProgram = await setupProgram();
|
|
26
27
|
initializedProgram.action(async (icons, options) => {
|
|
27
28
|
try {
|
|
29
|
+
// Validate that icons are provided when not using --init
|
|
30
|
+
if (!options.init && (!icons || icons.length === 0)) {
|
|
31
|
+
console.error('Error: At least one icon reference is required.');
|
|
32
|
+
program.help();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// Handle --init flag to generate a config file
|
|
36
|
+
if (options.init) {
|
|
37
|
+
const fs = await import('node:fs/promises');
|
|
38
|
+
const configFileContent = `import type { Config } from '@wkovacs64/add-icon';
|
|
39
|
+
|
|
40
|
+
const config = {
|
|
41
|
+
outputDir: 'app/assets/svg-icons',
|
|
42
|
+
} satisfies Config;
|
|
43
|
+
|
|
44
|
+
export default config;
|
|
45
|
+
`;
|
|
46
|
+
try {
|
|
47
|
+
const configFilePath = path.resolve(process.cwd(), 'add-icon.config.ts');
|
|
48
|
+
await fs.writeFile(configFilePath, configFileContent, 'utf-8');
|
|
49
|
+
console.log(`✓ Configuration file created at: ${configFilePath}`);
|
|
50
|
+
process.exit(0);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
54
|
+
console.error(`Error creating config file: ${errorMessage}`);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
28
58
|
// Load config (first from config file, then override with CLI options)
|
|
29
59
|
const config = await loadConfig(options.config);
|
|
30
60
|
// Override output directory if specified in CLI
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wkovacs64/add-icon",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "CLI tool to download and transform icons from Iconify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"iconify",
|
|
@@ -39,8 +39,6 @@
|
|
|
39
39
|
"clean": "del-cli dist",
|
|
40
40
|
"prebuild": "npm run --silent clean",
|
|
41
41
|
"prepublishOnly": "run-p --silent lint typecheck build",
|
|
42
|
-
"start": "node dist/index.js",
|
|
43
|
-
"dev": "tsx src/index.ts",
|
|
44
42
|
"typecheck": "attw --pack --profile esm-only",
|
|
45
43
|
"lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
|
|
46
44
|
"format": "prettier --cache --write .",
|
|
@@ -61,7 +59,7 @@
|
|
|
61
59
|
"devDependencies": {
|
|
62
60
|
"@arethetypeswrong/cli": "0.17.4",
|
|
63
61
|
"@changesets/changelog-github": "0.5.1",
|
|
64
|
-
"@changesets/cli": "2.29.
|
|
62
|
+
"@changesets/cli": "2.29.1",
|
|
65
63
|
"@types/node": "22.14.1",
|
|
66
64
|
"@wkovacs64/eslint-config": "7.5.2",
|
|
67
65
|
"@wkovacs64/prettier-config": "4.1.1",
|