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 +202 -123
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,15 @@
|
|
|
7
7
|

|
|
8
8
|

|
|
9
9
|
|
|
10
|
-
|
|
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
|
|
23
|
-
- ๐๏ธ
|
|
24
|
-
- ๐งน Detect duplicate files before they
|
|
25
|
-
- ๐ก๏ธ Catch invalid filenames before Metro, Vite, Next.js, or CI
|
|
26
|
-
- ๐
|
|
27
|
-
- โป๏ธ Clean generated files and cache whenever
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
68
|
+
Generate asset files:
|
|
58
69
|
|
|
59
70
|
```sh
|
|
60
71
|
npx assets-toolkit generate
|
|
61
72
|
```
|
|
62
73
|
|
|
63
|
-
Import
|
|
74
|
+
Import generated assets:
|
|
64
75
|
|
|
65
76
|
```ts
|
|
66
|
-
import { Assets
|
|
77
|
+
import { Assets } from "./generated-assets";
|
|
67
78
|
|
|
68
79
|
const logo = Assets.images.logo;
|
|
69
|
-
const searchIcon = svg.
|
|
70
|
-
const
|
|
80
|
+
const searchIcon = Assets.svg.images.search;
|
|
81
|
+
const font = Assets.fonts.fonts.Inter;
|
|
71
82
|
```
|
|
72
83
|
|
|
73
|
-
|
|
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
|
-
|
|
77
|
-
|
|
93
|
+
src/
|
|
94
|
+
โโโ assets/
|
|
95
|
+
โโโ generated-assets/
|
|
78
96
|
```
|
|
79
97
|
|
|
80
|
-
|
|
98
|
+
If your project does not contain a `src` folder:
|
|
81
99
|
|
|
82
100
|
```txt
|
|
83
|
-
|
|
101
|
+
assets/
|
|
102
|
+
generated-assets/
|
|
84
103
|
```
|
|
85
104
|
|
|
86
|
-
|
|
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
|
|
92
|
-
| `doctor --fix` |
|
|
93
|
-
| `reports` |
|
|
94
|
-
| `clean`, `-c` | Remove generated files
|
|
95
|
-
| `--version`, `-v` | Show
|
|
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
|
-
|
|
143
|
+
---
|
|
99
144
|
|
|
100
|
-
๐ Generate
|
|
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
|
-
|
|
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
|
-
|
|
167
|
+
The generator creates:
|
|
122
168
|
|
|
123
|
-
|
|
124
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
204
|
+
Checks:
|
|
138
205
|
|
|
139
|
-
- Missing asset
|
|
206
|
+
- Missing asset folders
|
|
140
207
|
- Invalid filenames
|
|
141
208
|
- Duplicate assets
|
|
142
|
-
- Unsupported
|
|
143
|
-
- Large files
|
|
209
|
+
- Unsupported formats
|
|
210
|
+
- Large files
|
|
211
|
+
|
|
212
|
+
---
|
|
144
213
|
|
|
145
|
-
|
|
214
|
+
# ๐ Doctor Fix
|
|
146
215
|
|
|
147
|
-
|
|
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
|
-
|
|
234
|
+
---
|
|
166
235
|
|
|
167
|
-
๐
|
|
236
|
+
# ๐ Reports
|
|
237
|
+
|
|
238
|
+
Generate an asset report:
|
|
168
239
|
|
|
169
240
|
```sh
|
|
170
241
|
npx assets-toolkit reports
|
|
171
242
|
```
|
|
172
243
|
|
|
173
|
-
|
|
244
|
+
Includes:
|
|
174
245
|
|
|
175
|
-
-
|
|
176
|
-
- Asset counts by category
|
|
246
|
+
- Asset counts
|
|
177
247
|
- Storage usage
|
|
178
|
-
- Largest
|
|
248
|
+
- Largest files
|
|
179
249
|
- Extension breakdown
|
|
180
|
-
- Generated output
|
|
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
|
-
|
|
288
|
+
# โ๏ธ Configuration
|
|
217
289
|
|
|
218
|
-
On first
|
|
290
|
+
On first run, Assets Toolkit creates:
|
|
219
291
|
|
|
220
|
-
|
|
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
|
-
|
|
318
|
+
---
|
|
241
319
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
-
|
|
343
|
+
This allows bundlers like:
|
|
344
|
+
|
|
345
|
+
- Webpack
|
|
346
|
+
- Turbopack
|
|
347
|
+
- Vite
|
|
252
348
|
|
|
253
|
-
|
|
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
|
-
|
|
351
|
+
---
|
|
263
352
|
|
|
264
|
-
|
|
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
|
-
|
|
367
|
+
my logo.png
|
|
278
368
|
bad!name.svg
|
|
279
|
-
|
|
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
|
-
|
|
372
|
+
Clean filenames produce predictable generated keys.
|
|
301
373
|
|
|
302
|
-
|
|
303
|
-
export const Assets = {
|
|
304
|
-
images,
|
|
305
|
-
svg,
|
|
306
|
-
fonts,
|
|
307
|
-
audio,
|
|
308
|
-
video,
|
|
309
|
-
lottie,
|
|
310
|
-
} as const;
|
|
311
|
-
```
|
|
374
|
+
---
|
|
312
375
|
|
|
313
|
-
|
|
376
|
+
# ๐งช Recommended Workflow
|
|
314
377
|
|
|
315
|
-
|
|
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
|
-
|
|
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
|
|
399
|
+
For CI:
|
|
339
400
|
|
|
340
401
|
```sh
|
|
341
402
|
npx assets-toolkit doctor
|
|
342
403
|
```
|
|
343
404
|
|
|
344
|
-
|
|
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
|
-
|
|
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
|
-
|
|
431
|
+
This project is licensed under the MIT License.
|
|
353
432
|
|
|
354
|
-
|
|
433
|
+
See [LICENSE](LICENSE) for details.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./rn-assets.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,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 "./
|
|
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,
|
|
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.
|
|
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",
|