@wkovacs64/add-icon 1.0.0 → 1.1.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.
Files changed (3) hide show
  1. package/README.md +8 -2
  2. package/dist/index.js +27 -7
  3. package/package.json +12 -2
package/README.md CHANGED
@@ -14,19 +14,25 @@ npm install @wkovacs64/add-icon
14
14
  Or use it directly with npx without installing:
15
15
 
16
16
  ```bash
17
- npx @wkovacs64/add-icon <icon> [options]
17
+ npx @wkovacs64/add-icon <icon>... [options]
18
18
  ```
19
19
 
20
20
  ## Usage
21
21
 
22
22
  ### Basic Usage
23
23
 
24
- Download an icon to the specified directory:
24
+ Download a single icon to the specified directory:
25
25
 
26
26
  ```bash
27
27
  npx @wkovacs64/add-icon heroicons:arrow-up-circle --output-dir ./app/assets/svg-icons
28
28
  ```
29
29
 
30
+ Download multiple icons in one command:
31
+
32
+ ```bash
33
+ npx @wkovacs64/add-icon heroicons:arrow-up-circle mdi:home lucide:github --output-dir ./app/assets/svg-icons
34
+ ```
35
+
30
36
  ### Transformations
31
37
 
32
38
  The tool fetches SVG icons directly from the Iconify API with width and height attributes removed
package/dist/index.js CHANGED
@@ -16,14 +16,14 @@ const setupProgram = async () => {
16
16
  .name(name.split('/').pop() || name)
17
17
  .description(description)
18
18
  .version(version, '-v, --version', 'Output the current version')
19
- .argument('<icon>', 'Icon reference (e.g., heroicons:arrow-up-circle)')
20
- .option('-o, --output-dir <dir>', 'Directory to save icon')
19
+ .argument('<icons...>', 'Icon references (e.g., heroicons:arrow-up-circle mdi:home)')
20
+ .option('-o, --output-dir <dir>', 'Directory to save icons')
21
21
  .option('-c, --config <path>', 'Path to config file')
22
22
  .option('-t, --transform <path>', 'Path to custom transform module (.js or .ts)');
23
23
  };
24
24
  // Initialize the program
25
25
  const initializedProgram = await setupProgram();
26
- initializedProgram.action(async (icon, options) => {
26
+ initializedProgram.action(async (icons, options) => {
27
27
  try {
28
28
  // Load config (first from config file, then override with CLI options)
29
29
  const config = await loadConfig(options.config);
@@ -59,10 +59,30 @@ initializedProgram.action(async (icon, options) => {
59
59
  process.exit(1);
60
60
  }
61
61
  }
62
- // Download the icon
63
- console.log(`Downloading icon: ${icon}...`);
64
- const savedPath = await downloadIcon(icon, config);
65
- console.log(`✓ Icon saved to: ${savedPath}`);
62
+ // Download all icons
63
+ const results = [];
64
+ for (const icon of icons) {
65
+ console.log(`Downloading icon: ${icon}...`);
66
+ try {
67
+ const savedPath = await downloadIcon(icon, config);
68
+ console.log(`✓ Icon saved to: ${savedPath}`);
69
+ results.push({ icon, path: savedPath, success: true });
70
+ }
71
+ catch (iconError) {
72
+ const errorMessage = iconError instanceof Error ? iconError.message : String(iconError);
73
+ console.error(`Error downloading ${icon}: ${errorMessage}`);
74
+ results.push({ icon, error: errorMessage, success: false });
75
+ }
76
+ }
77
+ // Report summary if multiple icons
78
+ if (icons.length > 1) {
79
+ const successful = results.filter((r) => r.success).length;
80
+ console.log(`\nSummary: Downloaded ${successful}/${icons.length} icons`);
81
+ // If any failed, exit with error
82
+ if (successful < icons.length) {
83
+ process.exit(1);
84
+ }
85
+ }
66
86
  }
67
87
  catch (error) {
68
88
  const errorMessage = error instanceof Error ? error.message : String(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wkovacs64/add-icon",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "CLI tool to download and transform icons from Iconify",
5
5
  "keywords": [
6
6
  "iconify",
@@ -9,7 +9,17 @@
9
9
  "cli",
10
10
  "download"
11
11
  ],
12
- "author": "Justin R. Hall <justin.r.hall@gmail.com>",
12
+ "author": {
13
+ "name": "Justin Hall",
14
+ "email": "justin.r.hall@gmail.com"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/wKovacs64/add-icon.git"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/wKovacs64/add-icon/issues"
22
+ },
13
23
  "license": "MIT",
14
24
  "type": "module",
15
25
  "main": "dist/index.js",