assets-toolkit 1.0.2 โ†’ 1.0.3

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 CHANGED
@@ -7,7 +7,15 @@
7
7
  ![typescript](https://img.shields.io/badge/TypeScript-ready-3178c6)
8
8
  ![platforms](https://img.shields.io/badge/platforms-RN%20%7C%20Expo%20%7C%20React%20%7C%20Next%20%7C%20Vite-7c3aed)
9
9
 
10
- Assets Toolkit scans your project assets, validates them, detects duplicates and risky files, then generates a typed asset map you can import from your app code. It is built for teams that want asset access to feel boring in the best way: consistent names, stable imports, and fewer surprises during release.
10
+ ssets Toolkit scans your project assets, validates them, detects duplicates and risky files, then generates a typed asset map you can import from your app code. It is built for teams that want asset access to feel boring in the best way: consistent names, stable imports, and fewer surprises during release.
11
+
12
+ It helps teams keep asset management predictable with:
13
+
14
+ - Consistent asset names
15
+ - Type-safe imports
16
+ - Duplicate detection
17
+ - Platform compatibility checks
18
+ - Cleaner release builds
11
19
 
12
20
  ```txt
13
21
  assets/ generated-assets/
@@ -19,14 +27,16 @@ assets/ generated-assets/
19
27
 
20
28
  ## โœจ Why Use It?
21
29
 
22
- - ๐Ÿš€ Generate one tidy `Assets` object from images, SVGs, fonts, audio, video, and Lottie files.
23
- - ๐Ÿ—‚๏ธ Keep nested folder structure in the generated output.
24
- - ๐Ÿงน Detect duplicate files before they bloat your app.
25
- - ๐Ÿ›ก๏ธ Catch invalid filenames before Metro, Vite, Next.js, or CI complains.
26
- - ๐Ÿ“Š Check large assets and platform support from one simple command.
27
- - โ™ป๏ธ Clean generated files and cache whenever you want a fresh build.
30
+ - ๐Ÿš€ Generate one typed `Assets` object from images, SVGs, fonts, audio, video, and Lottie files.
31
+ - ๐Ÿ—‚๏ธ Preserve nested asset folder structures.
32
+ - ๐Ÿงน Detect duplicate files before they increase app size.
33
+ - ๐Ÿ›ก๏ธ Catch invalid filenames before Metro, Vite, Next.js, or CI builds fail.
34
+ - ๐Ÿ“Š Analyze asset usage and platform compatibility.
35
+ - โ™ป๏ธ Clean generated files and cache whenever required.
36
+
37
+ ---
28
38
 
29
- ## ๐Ÿ“ฆ Installation
39
+ # ๐Ÿ“ฆ Installation
30
40
 
31
41
  Install it as a development dependency:
32
42
 
@@ -40,64 +50,101 @@ Or run it directly with `npx`:
40
50
  npx assets-toolkit help
41
51
  ```
42
52
 
43
- ## โšก Quick Start
53
+ ---
54
+
55
+ # โšก Quick Start
44
56
 
45
57
  Put assets in one of the default folders:
46
58
 
47
59
  ```txt
48
60
  assets/
49
61
  logo.png
50
- home@2x.png
51
62
  icons/
52
63
  search.svg
53
64
  fonts/
54
65
  Inter.ttf
55
66
  ```
56
67
 
57
- Generate the asset files:
68
+ Generate asset files:
58
69
 
59
70
  ```sh
60
71
  npx assets-toolkit generate
61
72
  ```
62
73
 
63
- Import the generated output in your app:
74
+ Import generated assets:
64
75
 
65
76
  ```ts
66
- import { Assets, images, svg, fonts } from "./generated-assets";
77
+ import { Assets } from "./generated-assets";
67
78
 
68
79
  const logo = Assets.images.logo;
69
- const searchIcon = svg.icons.search;
70
- const interFont = fonts.fonts.Inter;
80
+ const searchIcon = Assets.svg.images.search;
81
+ const font = Assets.fonts.fonts.Inter;
71
82
  ```
72
83
 
73
- By default, Assets Toolkit looks in:
84
+ ---
85
+
86
+ # ๐Ÿ“ Generated Location
87
+
88
+ Assets Toolkit automatically detects your project structure.
89
+
90
+ If your project contains a `src` folder:
74
91
 
75
92
  ```txt
76
- ./src/assets
77
- ./assets
93
+ src/
94
+ โ”œโ”€โ”€ assets/
95
+ โ””โ”€โ”€ generated-assets/
78
96
  ```
79
97
 
80
- And writes generated files to:
98
+ If your project does not contain a `src` folder:
81
99
 
82
100
  ```txt
83
- ./generated-assets
101
+ assets/
102
+ generated-assets/
84
103
  ```
85
104
 
86
- ## ๐Ÿงญ CLI Commands
105
+ You can always override this using:
106
+
107
+ ```json
108
+ {
109
+ "output": "custom/generated/path"
110
+ }
111
+ ```
112
+
113
+ ---
114
+
115
+ # ๐ŸŒ Platform Support
116
+
117
+ Assets Toolkit automatically detects your project platform.
118
+
119
+ | Platform | Images | SVG | Fonts | Audio | Video | Lottie |
120
+ | ------------ | ------ | --- | ----- | ----- | ----- | ------ |
121
+ | React Native | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… |
122
+ | Expo | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… |
123
+ | React | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… |
124
+ | Next.js | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… |
125
+ | Vite | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… |
126
+
127
+ Unsupported formats are reported during generation.
128
+
129
+ ---
130
+
131
+ # ๐Ÿงญ CLI Commands
87
132
 
88
- | Command | Purpose |
89
- | ----------------- | -------------------------------------------------------------- |
90
- | `generate`, `-g` | Generate typed asset files. |
91
- | `doctor` | Validate assets and detect common problems. |
92
- | `doctor --fix` | Rename invalid files and remove duplicates after confirmation. |
93
- | `reports` | Print asset statistics and project insights. |
94
- | `clean`, `-c` | Remove generated files and cache. |
95
- | `--version`, `-v` | Show installed package version. |
96
- | `help`, `-h` | Show CLI help. |
133
+ | Command | Purpose |
134
+ | ----------------- | --------------------------------- |
135
+ | `generate`, `-g` | Generate typed asset files |
136
+ | `doctor` | Validate assets and detect issues |
137
+ | `doctor --fix` | Fix invalid filenames |
138
+ | `reports` | Generate asset reports |
139
+ | `clean`, `-c` | Remove generated files |
140
+ | `--version`, `-v` | Show package version |
141
+ | `help`, `-h` | Show CLI help |
97
142
 
98
- ### `generate`
143
+ ---
99
144
 
100
- ๐Ÿš€ Generate asset maps from your project assets.
145
+ # ๐Ÿš€ Generate
146
+
147
+ Generate asset maps:
101
148
 
102
149
  ```sh
103
150
  npx assets-toolkit generate
@@ -109,42 +156,64 @@ Alias:
109
156
  npx assets-toolkit -g
110
157
  ```
111
158
 
112
- Useful options:
159
+ Options:
113
160
 
114
161
  ```sh
115
162
  npx assets-toolkit generate --outDir src/generated-assets
116
- npx assets-toolkit generate -o src/generated-assets
117
163
  npx assets-toolkit generate --assetsDir assets
118
164
  npx assets-toolkit generate --assetsDirs assets,src/shared/assets
119
165
  ```
120
166
 
121
- What it does:
167
+ The generator creates:
122
168
 
123
- - Creates generated category files like `images-generate.ts`, `svg-generate.ts`, and `fonts-generate.ts`.
124
- - Creates a generated `index.ts` that exports `Assets` plus each category.
125
- - Preserves nested folders as nested object keys.
126
- - Skips invalid asset filenames.
127
- - Reports duplicate files and validation warnings.
169
+ ```txt
170
+ generated-assets/
128
171
 
129
- ### `doctor`
172
+ index.ts
173
+ images-generate.ts
174
+ svg-generate.ts
175
+ fonts-generate.ts
176
+ audio-generate.ts
177
+ video-generate.ts
178
+ lottie-generate.ts
179
+ ```
130
180
 
131
- ๐Ÿฉบ Inspect your asset setup and find issues before they become runtime problems.
181
+ Generated output:
182
+
183
+ ```ts
184
+ export const Assets = {
185
+ images,
186
+ svg,
187
+ fonts,
188
+ audio,
189
+ video,
190
+ lottie,
191
+ } as const;
192
+ ```
193
+
194
+ ---
195
+
196
+ # ๐Ÿฉบ Doctor
197
+
198
+ Check your asset setup:
132
199
 
133
200
  ```sh
134
201
  npx assets-toolkit doctor
135
202
  ```
136
203
 
137
- Checks include:
204
+ Checks:
138
205
 
139
- - Missing asset directories
206
+ - Missing asset folders
140
207
  - Invalid filenames
141
208
  - Duplicate assets
142
- - Unsupported platform assets
143
- - Large files over the recommended threshold
209
+ - Unsupported formats
210
+ - Large files
211
+
212
+ ---
144
213
 
145
- ### `doctor --fix`
214
+ # ๐Ÿ›  Doctor Fix
146
215
 
147
- ๐Ÿ› ๏ธ Preview and fix invalid asset filenames.
216
+ Preview fixes:
148
217
 
149
218
  ```sh
150
219
  npx assets-toolkit doctor --fix
@@ -162,22 +231,25 @@ This command can:
162
231
  - Avoid collisions with files that already exist.
163
232
  - Remove duplicate asset files after confirmation.
164
233
 
165
- ### `reports`
234
+ ---
166
235
 
167
- ๐Ÿ“Š Show a project asset report.
236
+ # ๐Ÿ“Š Reports
237
+
238
+ Generate an asset report:
168
239
 
169
240
  ```sh
170
241
  npx assets-toolkit reports
171
242
  ```
172
243
 
173
- The report includes:
244
+ Includes:
174
245
 
175
- - Current configuration
176
- - Asset counts by category
246
+ - Asset counts
177
247
  - Storage usage
178
- - Largest assets
248
+ - Largest files
179
249
  - Extension breakdown
180
- - Generated output status
250
+ - Generated output information
251
+
252
+ ---
181
253
 
182
254
  ### `clean`
183
255
 
@@ -213,11 +285,15 @@ npx assets-toolkit help
213
285
  npx assets-toolkit -h
214
286
  ```
215
287
 
216
- ## โš™๏ธ Configuration
288
+ # โš™๏ธ Configuration
217
289
 
218
- On first use, Assets Toolkit creates `assets-toolkit.config.json` if it does not already exist.
290
+ On first run, Assets Toolkit creates:
219
291
 
220
- Default config:
292
+ ```txt
293
+ assets-toolkit.config.json
294
+ ```
295
+
296
+ Default:
221
297
 
222
298
  ```json
223
299
  {
@@ -228,6 +304,8 @@ Default config:
228
304
  }
229
305
  ```
230
306
 
307
+ ---
308
+
231
309
  ### Config Options
232
310
 
233
311
  | Option | Type | Description |
@@ -237,84 +315,67 @@ Default config:
237
315
  | `target` | `string` | Valid target value: `auto`, `react-native`, `expo`, `react`, `next`, `vite`, or `unknown`. The CLI auto-detects the active platform from package dependencies. |
238
316
  | `duplicates` | `string` | Duplicate preference value: `ignore`, `warn`, or `error`. Duplicate files are surfaced by `generate`, `doctor`, and `doctor --fix`. |
239
317
 
240
- Example:
318
+ ---
241
319
 
242
- ```json
243
- {
244
- "assets": ["./assets", "./src/shared/assets"],
245
- "output": "src/generated-assets",
246
- "target": "react-native",
247
- "duplicates": "warn"
248
- }
320
+ # ๐Ÿงฉ Supported Assets
321
+
322
+ | Category | Extensions |
323
+ | -------- | ------------------------------------------------------------------ |
324
+ | Images | `.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.avif`, `.heic`, `.ico` |
325
+ | SVG | `.svg` |
326
+ | Fonts | `.ttf`, `.otf`, `.woff`, `.woff2` |
327
+ | Audio | `.mp3`, `.wav`, `.aac`, `.m4a`, `.ogg`, `.flac`, `.opus` |
328
+ | Video | `.mp4`, `.mov`, `.webm`, `.m4v` |
329
+ | Lottie | `.lottie`, valid Lottie `.json` |
330
+
331
+ ---
332
+
333
+ # ๐ŸŒ Web Asset Handling
334
+
335
+ For React, Next.js, and Vite projects, generated assets use native ESM asset resolution:
336
+
337
+ ```ts
338
+ export const images = {
339
+ logo: new URL("../assets/images/logo.png", import.meta.url).href,
340
+ };
249
341
  ```
250
342
 
251
- ## ๐Ÿงฉ Supported Assets
343
+ This allows bundlers like:
344
+
345
+ - Webpack
346
+ - Turbopack
347
+ - Vite
252
348
 
253
- | Category | Extensions |
254
- | -------- | ---------------------------------------------------------------------------------------------------- |
255
- | Images | `.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.bmp`, `.heic`, `.heif`, `.avif`, `.tiff`, `.tif`, `.ico` |
256
- | SVG | `.svg` |
257
- | Fonts | `.ttf`, `.otf`, `.woff`, `.woff2` |
258
- | Audio | `.mp3`, `.wav`, `.aac`, `.m4a`, `.ogg`, `.flac`, `.amr`, `.opus`, `.caf`, `.aiff` |
259
- | Video | `.mp4`, `.mov`, `.m4v`, `.avi`, `.mkv`, `.webm`, `.3gp`, `.mpeg`, `.mpg` |
260
- | Lottie | `.lottie`, plus valid Lottie `.json` files |
349
+ to correctly resolve assets.
261
350
 
262
- ## โœ… Filename Rules
351
+ ---
263
352
 
264
- Use simple, portable filenames:
353
+ # โœ… Filename Rules
354
+
355
+ Recommended:
265
356
 
266
357
  ```txt
267
358
  logo.png
268
359
  logo-dark.svg
269
360
  home@2x.png
270
- home@3x.png
271
361
  Inter.ttf
272
362
  ```
273
363
 
274
364
  Avoid:
275
365
 
276
366
  ```txt
277
- bad name.png
367
+ my logo.png
278
368
  bad!name.svg
279
- logo.PNG
280
- ___.png
281
- ```
282
-
283
- Safe filenames make generated keys cleaner and reduce cross-platform build issues.
284
-
285
- ## ๐Ÿ—๏ธ Generated Output
286
-
287
- After running `generate`, you will get output similar to:
288
-
289
- ```txt
290
- generated-assets/
291
- index.ts
292
- images-generate.ts
293
- svg-generate.ts
294
- fonts-generate.ts
295
- audio-generate.ts
296
- video-generate.ts
297
- lottie-generate.ts
369
+ LOGO.PNG
298
370
  ```
299
371
 
300
- Example generated shape:
372
+ Clean filenames produce predictable generated keys.
301
373
 
302
- ```ts
303
- export const Assets = {
304
- images,
305
- svg,
306
- fonts,
307
- audio,
308
- video,
309
- lottie,
310
- } as const;
311
- ```
374
+ ---
312
375
 
313
- Nested folders become nested object keys, so your file layout stays readable in code.
376
+ # ๐Ÿงช Recommended Workflow
314
377
 
315
- ## ๐Ÿงช Recommended Workflow
316
-
317
- Add these scripts to your project:
378
+ Add scripts:
318
379
 
319
380
  ```json
320
381
  {
@@ -328,27 +389,45 @@ Add these scripts to your project:
328
389
  }
329
390
  ```
330
391
 
331
- Then run:
392
+ Run:
332
393
 
333
394
  ```sh
334
395
  npm run assets:check
335
396
  npm run assets
336
397
  ```
337
398
 
338
- For CI, a simple check is often enough:
399
+ For CI:
339
400
 
340
401
  ```sh
341
402
  npx assets-toolkit doctor
342
403
  ```
343
404
 
344
- ## ๐Ÿ’Ž Practical Tips
405
+ ---
406
+
407
+ # ๐Ÿ’Ž Practical Tips
408
+
409
+ - ๐Ÿ“ Keep assets inside `assets` or `src/assets`.
410
+ - ๐Ÿงช Run `doctor` before production builds.
411
+ - ๐Ÿ›  Use `doctor --fix` after adding assets from designers.
412
+ - ๐Ÿ“Œ Commit generated files if your team wants stable imports.
413
+ - โ™ป๏ธ Run `clean` when switching branches.
414
+
415
+ ---
416
+
417
+ # ๐Ÿ”— Repository
418
+
419
+ GitHub:
420
+
421
+ https://github.com/YOUR_USERNAME/assets-toolkit
422
+
423
+ Report issues:
424
+
425
+ https://github.com/YOUR_USERNAME/assets-toolkit/issues
426
+
427
+ ---
345
428
 
346
- - ๐Ÿ“ Keep app assets in `assets` or `src/assets` for zero-config usage.
347
- - ๐Ÿงช Run `doctor` before release builds to catch large, duplicate, or unsupported files.
348
- - ๐Ÿ› ๏ธ Use `doctor --fix` when designers or teammates add files with spaces or special characters.
349
- - ๐Ÿ“Œ Commit generated assets only if your team wants stable generated files in source control.
350
- - โ™ป๏ธ Run `clean` when switching branches if generated output looks stale.
429
+ # ๐Ÿ“„ License
351
430
 
352
- ## ๐Ÿ“„ License
431
+ This project is licensed under the MIT License.
353
432
 
354
- This project is licensed under the [MIT License](LICENSE).
433
+ See [LICENSE](LICENSE) for details.
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./runtime.js";
1
+ export * from "./rn-assets.js";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./runtime.js";
1
+ export * from "./rn-assets.js";
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assets-toolkit",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Type-safe asset management CLI for React Native, Expo, React, Next.js and Vite. Automatically scans, validates and generates typed asset imports.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",