assets-tracker 1.0.0 → 1.0.1

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
@@ -3,20 +3,21 @@
3
3
  [![npm version](https://img.shields.io/npm/v/assets-tracker.svg)](https://www.npmjs.com/package/assets-tracker)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- **Clean up your codebase and shrink your bundle size with the ultimate unused assets detector.**
6
+ **The ultimate unused assets detector for React, React Native, Web, and Mobile apps.**
7
7
 
8
- `assets-tracker` is a modern, high-performance CLI tool designed to identify and remove unreferenced assets from your project. Whether it's a forgotten hero image, an unused font file, or a legacy video asset, this tool helps you keep your repository lean and efficient.
8
+ `assets-tracker` is a modern, high-performance CLI tool designed to identify and remove unreferenced assets from your project. Whether you're building a **React Web App**, a **React Native Mobile App (iOS/Android)**, or an **Expo** project, this tool helps you keep your repository lean and efficient.
9
9
 
10
10
  ---
11
11
 
12
12
  ## ✨ Features
13
13
 
14
+ - ⚛️ **React & React Native Optimized**: Built-in support for common patterns in modern frontend and mobile frameworks.
15
+ - 📱 **Cross-Platform**: perfect for Web, Mobile (iOS/Android), and Desktop applications.
14
16
  - 🔍 **Deep Scan**: Identifies unused images, videos, fonts, and more across your entire project.
15
- - 🛠️ **Smart Analysis**: Scans your source files (JS, TS, HTML, CSS, etc.) to detect asset references.
17
+ - 🛠️ **Smart Analysis**: Scans your source files (JS, TS, JSX, TSX, HTML, CSS, etc.) to detect asset references.
16
18
  - 🏢 **Modern CLI**: Beautiful, interactive terminal interface with progress indicators and formatted reports.
17
19
  - 🧹 **Interactive Cleanup**: Choose to delete all unused assets at once or select specific files to remove safely.
18
- - 📦 **Dev-Friendly**: Zero configuration needed. Works out of the box with standard project structures.
19
- - 📉 **Size Reports**: View exactly how much space you can save.
20
+ - ⚙️ **Fully Configurable**: Customize extensions and ignore patterns via `.assettracker.json`.
20
21
 
21
22
  ---
22
23
 
@@ -52,6 +53,33 @@ npx assets-tracker clean
52
53
 
53
54
  ---
54
55
 
56
+ ## ⚙️ Configuration
57
+
58
+ Create a `.assettracker.json` in your project root to customize the behavior:
59
+
60
+ ```json
61
+ {
62
+ "assetExtensions": ["png", "jpg", "svg", "webp", "gif"],
63
+ "sourceExtensions": ["js", "jsx", "ts", "tsx", "html", "css"],
64
+ "ignorePatterns": [
65
+ "**/node_modules/**",
66
+ "**/dist/**",
67
+ "**/.expo/**",
68
+ "**/ios/build/**",
69
+ "**/android/app/build/**"
70
+ ]
71
+ }
72
+ ```
73
+
74
+ ### Options
75
+ | Option | Description | Default |
76
+ | :--- | :--- | :--- |
77
+ | `assetExtensions` | Array of file extensions to treat as assets. | `["png", "jpg", ...]` |
78
+ | `sourceExtensions` | Array of file extensions to scan for references. | `["js", "ts", "jsx", "tsx", ...]` |
79
+ | `ignorePatterns` | Glob patterns of directories/files to ignore. | `["node_modules", "dist", ...]` |
80
+
81
+ ---
82
+
55
83
  ## 📂 Supported Asset Types
56
84
 
57
85
  - **Images**: `.png`, `.jpg`, `.jpeg`, `.gif`, `.svg`, `.webp`, `.ico`
@@ -62,21 +90,10 @@ npx assets-tracker clean
62
90
 
63
91
  ## 🧠 How It Works
64
92
 
65
- 1. **Discovery**: The tool builds a list of all asset files in your project (excluding `node_modules`, `dist`, `.git`, etc.).
66
- 2. **Analysis**: It then parses your source code files to search for any mention of the asset's filename or relative path.
93
+ 1. **Discovery**: The tool builds a list of all asset files in your project (excluding ignored paths).
94
+ 2. **Analysis**: It parses your source code files (including JSX/TSX) to search for any mention of the asset's filename or relative path.
67
95
  3. **Reporting**: Assets that aren't mentioned anywhere are marked as "unused".
68
- 4. **Action**: You get a detailed report and the option to delete them securely.
69
-
70
- ---
71
-
72
- ## 🛠️ Configuration (Coming Soon)
73
-
74
- We are working on adding a `.assettracker.json` config file to allow:
75
- - Custom asset extensions.
76
- - Custom source directories.
77
- - Exclusion patterns.
78
-
79
- ---
96
+ 4. **Action**: You get a detailed report and the interactive option to delete them safely.
80
97
 
81
98
  ---
82
99
 
@@ -0,0 +1,7 @@
1
+ export interface Config {
2
+ assetExtensions?: string[];
3
+ sourceExtensions?: string[];
4
+ ignorePatterns?: string[];
5
+ }
6
+ export declare const DEFAULT_CONFIG: Config;
7
+ export declare function loadConfig(cwd: string): Promise<Config>;
package/dist/config.js ADDED
@@ -0,0 +1,26 @@
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
3
+ import { DEFAULT_ASSET_EXTENSIONS, DEFAULT_SOURCE_EXTENSIONS, DEFAULT_IGNORE } from './scanner.js';
4
+ export const DEFAULT_CONFIG = {
5
+ assetExtensions: DEFAULT_ASSET_EXTENSIONS,
6
+ sourceExtensions: DEFAULT_SOURCE_EXTENSIONS,
7
+ ignorePatterns: DEFAULT_IGNORE
8
+ };
9
+ export async function loadConfig(cwd) {
10
+ const configPath = path.join(cwd, '.assettracker.json');
11
+ if (!(await fs.pathExists(configPath))) {
12
+ return DEFAULT_CONFIG;
13
+ }
14
+ try {
15
+ const userConfig = await fs.readJson(configPath);
16
+ return {
17
+ assetExtensions: userConfig.assetExtensions || DEFAULT_ASSET_EXTENSIONS,
18
+ sourceExtensions: userConfig.sourceExtensions || DEFAULT_SOURCE_EXTENSIONS,
19
+ ignorePatterns: userConfig.ignorePatterns || DEFAULT_IGNORE
20
+ };
21
+ }
22
+ catch (error) {
23
+ console.warn(`\x1b[33m⚠ Warning: Failed to parse .assettracker.json: ${error.message}. Using defaults.\x1b[0m`);
24
+ return DEFAULT_CONFIG;
25
+ }
26
+ }