torch-it 2.6.0 โ 2.6.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 +123 -201
- package/dist/torch-it.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,171 +5,65 @@
|
|
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
|
6
6
|
[](https://www.npmjs.com/package/torch-it)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
> **One command to nuke caches, dependencies, and Docker environments โ then rebuild from scratch.**
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Project stopped working for no obvious reason ๐ ?
|
|
13
|
-
|
|
14
|
-
You'd like to kick it ๐ฅพ?
|
|
15
|
-
Hit it with a hammer ๐จ?
|
|
16
|
-
Turn it off and on again ๐บ?
|
|
17
|
-
|
|
18
|
-
Well better still - try torching it ๐ฅ๐ฅ๐ฅ๐ฅ๐ฅ๐ฅ
|
|
19
|
-
|
|
20
|
-
## What does `torch-it` do?
|
|
21
|
-
|
|
22
|
-
Intelligently nukes your local caches, dependencies, and Docker environment depending on your framework and package manager โ then rebuilds everything from a clean slate, **with a single command**.
|
|
23
|
-
|
|
24
|
-
It's surprising how often this just fixes things. ๐ค
|
|
25
|
-
|
|
26
|
-
## Features
|
|
27
|
-
|
|
28
|
-
- **One command** to clean up 50+ build artifacts, cache directories, log files, and reinstall dependencies
|
|
29
|
-
- **Comprehensive framework support** โ handles React, Next.js, Vue, Vite, SvelteKit, Remix, Qwik, Nuxt, Astro, Angular, Solid, and 40+ more
|
|
30
|
-
- **Smart file pattern matching** โ removes `*.log`, `*.tgz`, `*.tar.gz`, and other temporary files automatically
|
|
31
|
-
- **Fully customizable** โ specify any directories or files to delete via `torchrc.json`
|
|
32
|
-
- **Docker support** โ optional Docker teardown, rebuild, and launch when you enable Docker mode ๐ณ
|
|
33
|
-
- **Cross-platform** โ works on Windows, Linux, and macOS
|
|
34
|
-
- **Zero-dependency** โ lightweight and no additional packages required
|
|
35
|
-
|
|
36
|
-
## Supported Frameworks
|
|
37
|
-
|
|
38
|
-
React, Next.js, Vue, Vite, SvelteKit, React Native, Expo, Remix, Qwik, Nuxt, Astro, Angular, Solid, Docusaurus, and 40+ more frameworks and tools.
|
|
39
|
-
|
|
40
|
-
## Comprehensive Cleanup Targets
|
|
41
|
-
|
|
42
|
-
`torch-it` cleans up 50+ common build artifacts, cache directories, and temporary files:
|
|
43
|
-
|
|
44
|
-
### Framework Build Outputs
|
|
45
|
-
- `dist`, `build`, `out`, `.output` - Standard build directories
|
|
46
|
-
- `.next` - Next.js build cache
|
|
47
|
-
- `.nuxt` - Nuxt.js build output
|
|
48
|
-
- `.svelte-kit`, `.svelte` - Svelte/SvelteKit builds
|
|
49
|
-
- `.remix` - Remix framework build output
|
|
50
|
-
- `.qwik` - Qwik framework build output
|
|
51
|
-
- `.astro` - Astro framework build output
|
|
52
|
-
- `.angular`, `.angular/cache` - Angular build artifacts
|
|
53
|
-
- `.solid` - Solid.js build output
|
|
54
|
-
- `.docusaurus` - Docusaurus static site output
|
|
55
|
-
- `.nitro` - Nuxt Nitro server output
|
|
56
|
-
|
|
57
|
-
### Development Tool Caches
|
|
58
|
-
- `.cache`, `.parcel-cache`, `.webpack`, `.rollup.cache` - Build tool caches
|
|
59
|
-
- `.vite` - Vite build tool cache
|
|
60
|
-
- `.swc`, `.rpt2_cache` - JavaScript transpiler caches
|
|
61
|
-
- `.eslintcache`, `.stylelintcache`, `.sass-cache` - Linter/preprocessor caches
|
|
62
|
-
- `.babel-cache`, `.cache-loader` - Babel and webpack loader caches
|
|
63
|
-
|
|
64
|
-
### Package Manager Caches
|
|
65
|
-
- `node_modules/.cache` - npm package cache
|
|
66
|
-
- `.npm` - npm global cache
|
|
67
|
-
- `.pnpm-store`, `.pnpm-debug.log` - pnpm caches
|
|
68
|
-
- `.yarn/cache`, `.yarn/unplugged`, `.yarn/install-state.gz` - Yarn caches
|
|
69
|
-
|
|
70
|
-
### Monorepo & Build Tools
|
|
71
|
-
- `.turbo` - Turborepo cache
|
|
72
|
-
- `.nx/cache` - Nx build system cache
|
|
73
|
-
- `.lerna` - Lerna monorepo cache
|
|
74
|
-
- `.rush` - Rush monorepo cache
|
|
75
|
-
- `.yalc` - Yalc local package manager
|
|
76
|
-
|
|
77
|
-
### Blockchain & Web3 Tools
|
|
78
|
-
- `.hardhat` - Hardhat Ethereum development
|
|
79
|
-
- `.foundry` - Foundry Ethereum development
|
|
80
|
-
- `.anchor` - Anchor Solana development
|
|
81
|
-
|
|
82
|
-
### Deployment & Platform Files
|
|
83
|
-
- `.vercel` - Vercel deployment cache
|
|
84
|
-
- `.netlify` - Netlify build cache
|
|
85
|
-
- `.wrangler` - Cloudflare Workers
|
|
86
|
-
- `.amplify` - AWS Amplify
|
|
87
|
-
- `.sst` - SST framework
|
|
88
|
-
- `.firebase` - Firebase hosting files
|
|
89
|
-
- `.serverless` - Serverless framework
|
|
10
|
+
Project stopped working for no obvious reason? `torch-it` cleans up 50+ build artifacts, cache directories, and temporary files, then reinstalls your dependencies fresh. It's surprising how often this just fixes things. ๐ค
|
|
90
11
|
|
|
91
|
-
|
|
92
|
-
- `android/.gradle`, `android/build`, `android/app/build` - Android builds
|
|
93
|
-
- `ios/Pods`, `ios/build` - iOS builds
|
|
94
|
-
- `.expo`, `.expo-shared` - Expo React Native
|
|
95
|
-
|
|
96
|
-
### File Patterns
|
|
97
|
-
- `*.log` - All log files
|
|
98
|
-
- `*.tgz`, `*.tar.gz` - Compressed archives
|
|
99
|
-
- `tsconfig.tsbuildinfo` - TypeScript incremental build info
|
|
100
|
-
- `coverage`, `.nyc_output` - Test coverage reports
|
|
101
|
-
- `storybook-static`, `.storybook-out` - Storybook builds
|
|
102
|
-
|
|
103
|
-
### Temporary Files
|
|
104
|
-
- `.tmp`, `tmp`, `temp` - Temporary directories
|
|
105
|
-
- `lib`, `es`, `cjs`, `umd` - Compiled JavaScript outputs
|
|
106
|
-
- `jspm_packages`, `.typings` - Package manager files
|
|
12
|
+
---
|
|
107
13
|
|
|
108
|
-
##
|
|
14
|
+
## Quick Start
|
|
109
15
|
|
|
110
|
-
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g torch-it # install globally (recommended)
|
|
18
|
+
cd your-project
|
|
19
|
+
torch-it # clean and rebuild
|
|
20
|
+
```
|
|
111
21
|
|
|
112
|
-
|
|
22
|
+
`torch-it` will show you a preview of what it's about to delete and ask for confirmation before doing anything destructive.
|
|
113
23
|
|
|
114
|
-
|
|
115
|
-
- **Removes log files and temporary artifacts** including `*.log`, `*.tgz`, `*.tar.gz`, and build info files.
|
|
116
|
-
- **Removes custom directories/paths** that you define in `torchrc.json`.
|
|
117
|
-
- **Cleans package manager caches** for npm, yarn, and pnpm.
|
|
118
|
-
- **Reinstalls dependencies** using your preferred package manager (npm, yarn, or pnpm).
|
|
24
|
+
---
|
|
119
25
|
|
|
120
|
-
|
|
26
|
+
## What It Does
|
|
121
27
|
|
|
122
|
-
|
|
28
|
+
### Always runs
|
|
123
29
|
|
|
124
|
-
|
|
30
|
+
1. Removes build artifacts and cache directories (50+ targets โ `node_modules`, `dist`, `.next`, `.cache`, `.vite`, etc.)
|
|
31
|
+
2. Removes log files and temporary files (`*.log`, `*.tgz`, `*.tar.gz`, etc.)
|
|
32
|
+
3. Removes any custom paths you define in `torchrc.json`
|
|
33
|
+
4. Cleans your package manager's cache (npm, yarn, or pnpm)
|
|
34
|
+
5. Reinstalls all dependencies
|
|
125
35
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
| When | What |
|
|
129
|
-
|------|------|
|
|
130
|
-
| **Start of run** | Checks `docker`, daemon (`docker info`), and `docker compose ps`. If those pass, runs **`docker compose down --rmi all --volumes`** โ stops the stack and removes images and volumes tied to those services. Happens **before** local file/cache cleanup. |
|
|
131
|
-
| **After dependency reinstall** | If **rebuild** is enabled: **`docker-compose build --pull --no-cache`**. This uses the **`docker-compose`** binary (with a hyphen); it is separate from **`docker compose`**. |
|
|
132
|
-
| **If rebuild succeeded** | **`docker compose up -d`** โ starts the stack in the background. |
|
|
36
|
+
### Optionally runs (Docker mode)
|
|
133
37
|
|
|
134
|
-
|
|
38
|
+
When `dockerMode: true` and a `docker-compose.yml` or `Dockerfile` is present:
|
|
135
39
|
|
|
136
|
-
|
|
40
|
+
| Step | When | Command |
|
|
41
|
+
|------|------|---------|
|
|
42
|
+
| Teardown | Before cleanup | `docker compose down --rmi all --volumes` |
|
|
43
|
+
| Rebuild | After dependency install | `docker compose build --pull --no-cache` |
|
|
44
|
+
| Start | After successful rebuild | `docker compose up -d` |
|
|
137
45
|
|
|
138
|
-
**
|
|
46
|
+
> **Note:** All Docker operations use `docker compose` (plugin). Ensure Docker Compose plugin is installed and on your PATH.
|
|
139
47
|
|
|
140
48
|
---
|
|
141
49
|
|
|
142
|
-
##
|
|
50
|
+
## Installation
|
|
143
51
|
|
|
144
|
-
### Global
|
|
52
|
+
### Global (recommended)
|
|
145
53
|
|
|
146
|
-
Install
|
|
54
|
+
Install once, use in any project:
|
|
147
55
|
|
|
148
56
|
```bash
|
|
149
57
|
npm install -g torch-it
|
|
150
58
|
```
|
|
151
59
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
```bash
|
|
155
|
-
torch-it
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
In an interactive terminal, `torch-it` prints the same cleanup preview as `--config` and asks you to confirm (**Yes** / **No**, or **y** / **n**) before it removes anything or touches Docker. Non-interactive environments (no TTY), `--test` dry runs, and **`--yes`** or **`-y`** skip that prompt.
|
|
159
|
-
|
|
160
|
-
For per-project customisation, create a `torchrc.json` file in your project root (see Customization section below) or use command line flags (see Command Line Options section below).
|
|
161
|
-
|
|
162
|
-
### Per-Project Installation (Alternative)
|
|
163
|
-
|
|
164
|
-
If you prefer to install torch-it per project:
|
|
60
|
+
### Per-project
|
|
165
61
|
|
|
166
62
|
```bash
|
|
167
63
|
npm install torch-it --save-dev
|
|
168
64
|
```
|
|
169
65
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
Add to package.json scripts:
|
|
66
|
+
Add a script to `package.json`:
|
|
173
67
|
|
|
174
68
|
```json
|
|
175
69
|
{
|
|
@@ -179,124 +73,152 @@ Add to package.json scripts:
|
|
|
179
73
|
}
|
|
180
74
|
```
|
|
181
75
|
|
|
182
|
-
|
|
183
|
-
npm run torch
|
|
184
|
-
```
|
|
76
|
+
Then run with `npm run torch` or `npx torch-it`.
|
|
185
77
|
|
|
186
|
-
|
|
78
|
+
---
|
|
187
79
|
|
|
188
|
-
|
|
189
|
-
npx torch-it
|
|
190
|
-
```
|
|
80
|
+
## Usage
|
|
191
81
|
|
|
192
|
-
###
|
|
82
|
+
### Basic run
|
|
193
83
|
|
|
194
|
-
|
|
84
|
+
```bash
|
|
85
|
+
torch-it
|
|
86
|
+
```
|
|
195
87
|
|
|
196
|
-
|
|
88
|
+
Shows a preview of what will be deleted, then prompts: **Continue? Type Yes or No (y/n)**.
|
|
197
89
|
|
|
198
|
-
|
|
199
|
-
- You use **`--test`** (dry run; nothing is changed).
|
|
200
|
-
- Standard input is **not a TTY** (for example some CI runners), so the tool proceeds without blocking.
|
|
90
|
+
### Skip confirmation (CI / automation)
|
|
201
91
|
|
|
202
|
-
|
|
92
|
+
```bash
|
|
93
|
+
torch-it --yes # or -y
|
|
94
|
+
```
|
|
203
95
|
|
|
204
|
-
|
|
96
|
+
### Dry run (preview only, no changes)
|
|
205
97
|
|
|
206
98
|
```bash
|
|
207
99
|
torch-it --test
|
|
208
100
|
```
|
|
209
101
|
|
|
210
|
-
###
|
|
211
|
-
|
|
212
|
-
Use `--config` to display the current torch-it configuration, including all files and directories that will be targeted for deletion during a torch-it run. This is useful for verifying your setup before performing actual cleanup operations.
|
|
102
|
+
### Show current configuration
|
|
213
103
|
|
|
214
104
|
```bash
|
|
215
105
|
torch-it --config
|
|
216
106
|
```
|
|
217
107
|
|
|
218
|
-
|
|
219
|
-
- Current settings from `torchrc.json` (if present) or defaults
|
|
220
|
-
- All built-in cleanup targets
|
|
221
|
-
- Custom paths that will be removed
|
|
222
|
-
- Protected paths that will be preserved
|
|
223
|
-
- Docker and rebuild operation settings
|
|
224
|
-
|
|
225
|
-
This helps you understand exactly what will be affected before running torch-it, making it easier to verify your configuration is correct.
|
|
108
|
+
Displays all active settings, every cleanup target, custom paths, protected paths, and Docker settings. Useful for verifying your setup before running.
|
|
226
109
|
|
|
227
110
|
---
|
|
228
|
-
## Customization
|
|
229
111
|
|
|
230
|
-
|
|
112
|
+
## Configuration
|
|
113
|
+
|
|
114
|
+
Create a `torchrc.json` file in your project root to customise behaviour. Everything is optional โ `torch-it` works with sensible defaults out of the box.
|
|
231
115
|
|
|
232
116
|
```json
|
|
233
117
|
{
|
|
234
|
-
"customPaths": ["apps/web/.next", "services/api/tmp", "
|
|
118
|
+
"customPaths": ["apps/web/.next", "services/api/tmp", "coverage-final.json"],
|
|
235
119
|
"protectedPaths": ["important-data/", "config/production.json"],
|
|
236
120
|
"dockerMode": false,
|
|
237
121
|
"rebuild": true,
|
|
238
|
-
"logfile":
|
|
122
|
+
"logfile": false
|
|
239
123
|
}
|
|
240
124
|
```
|
|
241
125
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
126
|
+
| Option | Type | Default | Description |
|
|
127
|
+
|--------|------|---------|-------------|
|
|
128
|
+
| `customPaths` | `string[]` | `[]` | Extra directories or files to delete during cleanup |
|
|
129
|
+
| `protectedPaths` | `string[]` | `[]` | Paths to skip โ preserved even if they match built-in targets |
|
|
130
|
+
| `dockerMode` | `boolean` | `false` | Enable Docker teardown, rebuild, and launch |
|
|
131
|
+
| `rebuild` | `boolean` | `true` | Set to `false` to skip dependency reinstall and Docker rebuild (cleanup still runs) |
|
|
132
|
+
| `logfile` | `boolean` | `false` | Write runtime output to `torch-it.log` in the project root |
|
|
247
133
|
|
|
248
|
-
|
|
134
|
+
### Command line overrides
|
|
249
135
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
You can override `torchrc.json` settings directly from the command line using flags. This is useful for one-off runs or CI/CD pipelines.
|
|
136
|
+
Any config option can be overridden with a flag. Flags take precedence over `torchrc.json`.
|
|
253
137
|
|
|
254
138
|
```bash
|
|
255
139
|
torch-it --yes --rebuild=false --customPaths=["temp/","logs/"]
|
|
140
|
+
torch-it --dockerMode=true --logfile=true
|
|
256
141
|
```
|
|
257
142
|
|
|
258
|
-
All
|
|
143
|
+
**All flags:**
|
|
144
|
+
|
|
145
|
+
| Flag | Description |
|
|
146
|
+
|------|-------------|
|
|
147
|
+
| `--help` | Show help and available options |
|
|
148
|
+
| `--version`, `-v` | Show version and exit |
|
|
149
|
+
| `--config` | Show current configuration and exit |
|
|
150
|
+
| `--test` | Dry run โ preview changes without executing |
|
|
151
|
+
| `--yes`, `-y` | Skip confirmation prompt |
|
|
152
|
+
| `--customPaths=[...]` | Extra paths to delete |
|
|
153
|
+
| `--protectedPaths=[...]` | Paths to preserve |
|
|
154
|
+
| `--dockerMode=true\|false` | Enable/disable Docker steps |
|
|
155
|
+
| `--rebuild=true\|false` | Enable/disable dependency reinstall and Docker rebuild |
|
|
156
|
+
| `--logfile=true\|false` | Enable/disable log file output |
|
|
157
|
+
|
|
158
|
+
---
|
|
259
159
|
|
|
260
|
-
|
|
261
|
-
- `--version, -v` - Show version information and exit
|
|
262
|
-
- `--config` - Show current configuration and exit
|
|
263
|
-
- `--test` - Run in dry-run mode (preview changes without executing)
|
|
264
|
-
- `--yes`, `-y` - Skip the interactive confirmation prompt (auto-confirm)
|
|
265
|
-
- `--customPaths=["path1","path2"]`
|
|
266
|
-
- `--dockerMode=true` - Enable Docker steps when Docker files are present (`false` is the default)
|
|
267
|
-
- `--rebuild=false`
|
|
268
|
-
- `--logfile=true`
|
|
160
|
+
## Supported Frameworks & Tools
|
|
269
161
|
|
|
270
|
-
|
|
162
|
+
React, Next.js, Vue, Vite, SvelteKit, React Native, Expo, Remix, Qwik, Nuxt, Astro, Angular, Solid, Docusaurus, and 40+ more.
|
|
271
163
|
|
|
272
|
-
|
|
164
|
+
**Package managers:** npm ยท yarn ยท pnpm
|
|
273
165
|
|
|
166
|
+
<details>
|
|
167
|
+
<summary>Full list of cleanup targets</summary>
|
|
274
168
|
|
|
169
|
+
### Framework build outputs
|
|
170
|
+
`dist`, `build`, `out`, `.output`, `.next`, `.nuxt`, `.svelte-kit`, `.svelte`, `.remix`, `.qwik`, `.astro`, `.angular`, `.angular/cache`, `.solid`, `.docusaurus`, `.nitro`
|
|
275
171
|
|
|
276
|
-
|
|
172
|
+
### Build tool caches
|
|
173
|
+
`.cache`, `.parcel-cache`, `.webpack`, `.rollup.cache`, `.vite`, `.swc`, `.rpt2_cache`, `.eslintcache`, `.stylelintcache`, `.sass-cache`, `.babel-cache`, `.cache-loader`
|
|
277
174
|
|
|
278
|
-
|
|
175
|
+
### Package manager caches
|
|
176
|
+
`node_modules/.cache`, `.npm`, `.pnpm-store`, `.pnpm-debug.log`, `.yarn/cache`, `.yarn/unplugged`, `.yarn/install-state.gz`
|
|
279
177
|
|
|
280
|
-
|
|
178
|
+
### Monorepo & build tools
|
|
179
|
+
`.turbo`, `.nx/cache`, `.lerna`, `.rush`, `.yalc`
|
|
281
180
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
```
|
|
181
|
+
### Blockchain & Web3
|
|
182
|
+
`.hardhat`, `.foundry`, `.anchor`
|
|
285
183
|
|
|
184
|
+
### Deployment & platform
|
|
185
|
+
`.vercel`, `.netlify`, `.wrangler`, `.amplify`, `.sst`, `.firebase`, `.serverless`
|
|
286
186
|
|
|
287
|
-
|
|
187
|
+
### Mobile development
|
|
188
|
+
`android/.gradle`, `android/build`, `android/app/build`, `ios/Pods`, `ios/build`, `.expo`, `.expo-shared`
|
|
288
189
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
- For detailed information about any failures, check the `torch-it.log` file.
|
|
190
|
+
### File patterns
|
|
191
|
+
`*.log`, `*.tgz`, `*.tar.gz`, `tsconfig.tsbuildinfo`, `coverage`, `.nyc_output`, `storybook-static`, `.storybook-out`
|
|
292
192
|
|
|
193
|
+
### Temporary files
|
|
194
|
+
`.tmp`, `tmp`, `temp`, `lib`, `es`, `cjs`, `umd`, `jspm_packages`, `.typings`
|
|
195
|
+
|
|
196
|
+
</details>
|
|
293
197
|
|
|
294
198
|
---
|
|
295
199
|
|
|
296
|
-
##
|
|
200
|
+
## Logging
|
|
201
|
+
|
|
202
|
+
By default, output goes to the console only. To save a log file for troubleshooting, set `logfile: true` in `torchrc.json` or pass `--logfile=true`.
|
|
203
|
+
|
|
204
|
+
The log is written to `torch-it.log` in your project root. Add it to `.gitignore`:
|
|
205
|
+
|
|
206
|
+
```gitignore
|
|
207
|
+
torch-it.log
|
|
208
|
+
```
|
|
297
209
|
|
|
298
|
-
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Troubleshooting
|
|
213
|
+
|
|
214
|
+
**Docker issues:** Run `docker compose ps` from the project root to check if Compose is working. For rebuilds, confirm `docker compose` is on your PATH. Check that the Docker daemon is running with `docker info`.
|
|
215
|
+
|
|
216
|
+
**Missing `package.json`:** Run `npm init -y` to initialise a project, or make sure you're in the right directory.
|
|
217
|
+
|
|
218
|
+
**Not sure what will be deleted?** Run `torch-it --config` to see the full list of targets, or `torch-it --test` for a dry run.
|
|
299
219
|
|
|
300
220
|
---
|
|
301
221
|
|
|
302
|
-
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
MIT โ **Happy torching!** ๐ฅโจ
|
package/dist/torch-it.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var Se=Object.create;var q=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var ve=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty;var $e=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ae=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of xe(t))!Pe.call(e,s)&&s!==n&&q(e,s,{get:()=>t[s],enumerable:!(r=Oe(t,s))||r.enumerable});return e};var m=(e,t,n)=>(n=e!=null?Se(ve(e)):{},Ae(t||!e||!e.__esModule?q(n,"default",{value:e,enumerable:!0}):n,e));var pe=$e((ho,Me)=>{Me.exports={name:"torch-it",version:"2.6.
|
|
2
|
+
"use strict";var Se=Object.create;var q=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var ve=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty;var $e=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ae=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of xe(t))!Pe.call(e,s)&&s!==n&&q(e,s,{get:()=>t[s],enumerable:!(r=Oe(t,s))||r.enumerable});return e};var m=(e,t,n)=>(n=e!=null?Se(ve(e)):{},Ae(t||!e||!e.__esModule?q(n,"default",{value:e,enumerable:!0}):n,e));var pe=$e((ho,Me)=>{Me.exports={name:"torch-it",version:"2.6.1",description:"CLI to reset, clean, and rebuild Node.js project environments.",keywords:["cleanup","cli","docker","node"],homepage:"https://github.com/piyook/torch-it#readme",bugs:{url:"https://github.com/piyook/torch-it/issues"},license:"ISC",author:"",repository:{type:"git",url:"git+https://github.com/piyook/torch-it.git"},bin:{"torch-it":"dist/torch-it.js"},files:["dist","README.md"],type:"commonjs",main:"dist/torch-it.js",scripts:{build:'esbuild src/torch.ts --bundle --outfile=dist/torch-it.js --platform=node --format=cjs --minify --banner:js="#!/usr/bin/env node"',"torch-it":"npm run build && node dist/torch-it.js","torch-it:ts":"ts-node src/torch.ts",lint:"oxlint .","lint:fix":"oxlint . --fix",format:"prettier --check src/**/*.{ts,js,json} tests/**/*.{ts,js,json} package.json package-lock.json .commitlintrc.json","format:write":"prettier --write src/**/*.{ts,js,json} tests/**/*.{ts,js,json} package.json package-lock.json .commitlintrc.json",quality:"npm run lint && npm run format && npm test","validate-branch-name":"validate-branch-name",prepare:"husky",prepublishOnly:"npm run build",test:"tsc --noEmit && vitest run","test:watch":"vitest"},dependencies:{},devDependencies:{"@commitlint/cli":"^20.5.0","@commitlint/config-conventional":"^20.5.0","@types/node":"^25.6.0",esbuild:"^0.28.0",husky:"^9.1.7","lint-staged":"^16.4.0",oxlint:"^1.61.0",prettier:"^3.8.3","ts-node":"^10.9.2",typescript:"^6.0.3","validate-branch-name":"^1.3.2",vitest:"^4.1.5"},"lint-staged":{"*.{ts,tsx,js,jsx,mjs,cjs,json}":["oxlint --fix","prettier --write"]},"validate-branch-name":{pattern:"^(main|dev){1}$|^(feat|fix|hotfix|release|chore)/.+$",errorMsg:"INVALID BRANCH NAME: use format 'feat|fix|hotfix|release|core/your-branch-name'"}}});var T=(e,t)=>n=>`\x1B[${e}m${n}\x1B[${t}m`,f={BOLD:T("1","22"),CYAN:T("36","39"),GREEN:T("32","39"),RED:T("31","39"),YELLOW:T("33","39"),PURPLE:T("35","39"),RESET:e=>`\x1B[0m${e}`},a={INFO:"\u{1F525}",SUCCESS:"\u2705",FAIL:"\u274C",EXCLAMATION:"\u2757",WARN:"\u26A0\uFE0F",ROCKET:"\u{1F525}",CLEAN:"\u{1F525}",PHOENIX:"\u{1F525}",BUILD:"\u{1F528}",TARGET:"\u{1F525}",CELEBRATE:"\u{1F525}",STARS:"\u2728",BOX:"\u{1F4E6}",CLIPBOARD:"\u{1F4CB}",DOCKER:"\u{1F433}"};var H=m(require("fs")),B=!0;function Ie(e){let t=new RegExp("\x1B\\[[0-9;]*m","g");return e.replace(t,"")}var E=e=>{B=e},X=()=>{B&&H.default.writeFileSync("torch-it.log","")},P=e=>{if(!B)return;let t=Ie(e).replace(/^\n/,""),n=new Date().toISOString();H.default.appendFileSync("torch-it.log",`[${n}] ${t}
|
|
3
3
|
`)};function o(e,t){let n;switch(t){case"info":n=`${f.CYAN(a.INFO)} ${f.BOLD(e)}${f.RESET("")}`;break;case"success":n=`${f.GREEN(a.SUCCESS)} ${e}${f.RESET("")}`;break;case"warn":n=`${f.YELLOW(a.WARN)} ${e}${f.RESET("")}`;break;case"fail":n=`${f.RED(a.FAIL)} ${e}${f.RESET("")}`;break;case"step":n=`
|
|
4
4
|
${f.PURPLE("\u25B6")} ${f.BOLD(e)}${f.RESET("")}`;break;default:n=e}console.log(n),P(n)}function J(){$([` ${a.TARGET} TORCH LIT ${a.ROCKET}`],f.PURPLE);let e=`
|
|
5
5
|
) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )
|
|
@@ -61,6 +61,6 @@ FILES/DIRECTORIES THAT WILL BE DELETED:`,"info");let k=[...new Set([...A,...N,..
|
|
|
61
61
|
PROTECTED PATHS (will NOT be deleted):`,"info"),s.forEach(i=>{let l=p.existsSync(i),C=l&&p.statSync(i).isDirectory()?"DIR":"FILE",v=l?`(${C})`:"(not found)";o(` ${i} ${v}`,"info")})):o(`
|
|
62
62
|
PROTECTED PATHS: None`,"info"),r.length>0&&(o(`
|
|
63
63
|
CUSTOM PATHS:`,"info"),r.forEach(i=>{let l=p.existsSync(i),C=l&&p.statSync(i).isDirectory()?"DIR":"FILE",v=l?`(${C})`:"(not found)";o(` ${i} ${v}`,"info")})),o(`
|
|
64
|
-
`+"=".repeat(60),"info"),n&&(o("Use 'torch-it --help' for available options","info"),o("=".repeat(60),"info"))}var fe=()=>{G(_())};function ue(e){let t=e.includes("--help"),n=e.includes("--version")||e.includes("-v"),r=e.includes("--config"),s=e.includes("--test"),c=e.includes("--yes")||e.includes("-y"),R=e.filter(d=>d!=="--test"&&d!=="--help"&&d!=="--version"&&d!=="-v"&&d!=="--config"&&d!=="--yes"&&d!=="-y");return{isHelp:t,isVersion:n,isConfig:r,isDryRun:s,assumeYes:c,filteredArgs:R}}function de(e){if(e.isHelp&&(E(!1),le(),process.exit(0)),e.isVersion){E(!1);let t=pe();o(`torch-it v${t.version}`,"info"),process.exit(0)}e.isConfig&&(E(!1),fe(),process.exit(0)),e.isDryRun&&(process.env.TORCH_DRY_RUN="1")}var j=m(require("fs"));function me(){return j.existsSync("Dockerfile")||j.existsSync("docker-compose.yml")||j.existsSync("docker-compose.yaml")}function ge(e){if(e.dockerMode===!1)return o("Docker mode disabled - skipping Docker operations","info"),"NO_DOCKER";let t=process.env.TORCH_DRY_RUN==="1";return me()?(o("Stopping Docker services and removing all resources...","info"),u("docker")?h("docker info",{silent:!0})?h("docker compose ps",{silent:!0})?t?(o("Dry-run: would run 'docker compose down --rmi all --volumes'","info"),"OK"):h("docker compose down --rmi all --volumes")?(o("Docker services stopped and resources cleaned","success"),"OK"):(o("Docker cleanup encountered issues","warn"),o("Continuing with the rest of the script...","info"),"DOCKER_FAIL"):(o("No Docker Compose services found - skipping Docker cleanup","warn"),o("This is normal if no services were previously running","info"),"DOCKER_FAIL"):(o("Docker daemon is not running - skipping Docker cleanup","warn"),o("You may need to start Docker manually and run cleanup later","info"),"NO_DOCKER"):(o("Docker is not installed - skipping Docker cleanup","warn"),"NO_DOCKER")):(o("No Docker configuration found - skipping Docker operations","info"),"NO_DOCKER")}function he(e){if(e.dockerMode===!1)return!1;if(e.rebuild===!1)return o("Rebuild disabled - skipping Docker rebuild","info"),!1;let t=process.env.TORCH_DRY_RUN==="1";return me()?u("docker")?h("docker info",{silent:!0})?(o("Building Docker resources (this may take a while...)...","step"),console.log(` ${f.YELLOW("\u23F3 Please be patient - pulling fresh images and building...")}`),t?(o("Dry-run: would run 'docker
|
|
64
|
+
`+"=".repeat(60),"info"),n&&(o("Use 'torch-it --help' for available options","info"),o("=".repeat(60),"info"))}var fe=()=>{G(_())};function ue(e){let t=e.includes("--help"),n=e.includes("--version")||e.includes("-v"),r=e.includes("--config"),s=e.includes("--test"),c=e.includes("--yes")||e.includes("-y"),R=e.filter(d=>d!=="--test"&&d!=="--help"&&d!=="--version"&&d!=="-v"&&d!=="--config"&&d!=="--yes"&&d!=="-y");return{isHelp:t,isVersion:n,isConfig:r,isDryRun:s,assumeYes:c,filteredArgs:R}}function de(e){if(e.isHelp&&(E(!1),le(),process.exit(0)),e.isVersion){E(!1);let t=pe();o(`torch-it v${t.version}`,"info"),process.exit(0)}e.isConfig&&(E(!1),fe(),process.exit(0)),e.isDryRun&&(process.env.TORCH_DRY_RUN="1")}var j=m(require("fs"));function me(){return j.existsSync("Dockerfile")||j.existsSync("docker-compose.yml")||j.existsSync("docker-compose.yaml")}function ge(e){if(e.dockerMode===!1)return o("Docker mode disabled - skipping Docker operations","info"),"NO_DOCKER";let t=process.env.TORCH_DRY_RUN==="1";return me()?(o("Stopping Docker services and removing all resources...","info"),u("docker")?h("docker info",{silent:!0})?h("docker compose ps",{silent:!0})?t?(o("Dry-run: would run 'docker compose down --rmi all --volumes'","info"),"OK"):h("docker compose down --rmi all --volumes")?(o("Docker services stopped and resources cleaned","success"),"OK"):(o("Docker cleanup encountered issues","warn"),o("Continuing with the rest of the script...","info"),"DOCKER_FAIL"):(o("No Docker Compose services found - skipping Docker cleanup","warn"),o("This is normal if no services were previously running","info"),"DOCKER_FAIL"):(o("Docker daemon is not running - skipping Docker cleanup","warn"),o("You may need to start Docker manually and run cleanup later","info"),"NO_DOCKER"):(o("Docker is not installed - skipping Docker cleanup","warn"),"NO_DOCKER")):(o("No Docker configuration found - skipping Docker operations","info"),"NO_DOCKER")}function he(e){if(e.dockerMode===!1)return!1;if(e.rebuild===!1)return o("Rebuild disabled - skipping Docker rebuild","info"),!1;let t=process.env.TORCH_DRY_RUN==="1";return me()?u("docker")?h("docker info",{silent:!0})?(o("Building Docker resources (this may take a while...)...","step"),console.log(` ${f.YELLOW("\u23F3 Please be patient - pulling fresh images and building...")}`),t?(o("Dry-run: would run 'docker compose build --pull --no-cache'","info"),!0):h("docker compose build --pull --no-cache")?!0:(o("Docker build encountered issues - check torch-it.log for details","fail"),!1)):(o("Docker daemon is not running - skipping Docker rebuild","warn"),o("Start Docker manually and run 'docker compose build --pull --no-cache' later","info"),!1):(o("Docker is not installed - skipping Docker rebuild","warn"),!1):!1}function Ce(e){if(e.dockerMode===!1)return!1;let t=process.env.TORCH_DRY_RUN==="1";return o("Starting Docker services in detached mode...","step"),t?(o("Dry-run: would run 'docker compose up -d'","info"),!0):h("docker compose up -d")?!0:(o("Failed to start Docker services - check torch-it.log for details","fail"),!1)}var ke=()=>{o("Detecting package manager and installing dependencies...","step");let e=K();return e?ee(e):(o("No package manager found (npm/yarn/pnpm). Please install dependencies manually.","fail"),!1)};var ye=e=>{let t="",n="",r="";e.dockerClean==="NO_DOCKER"?t=`${a.DOCKER} No Docker containers found`:e.dockerClean==="DOCKER_FAIL"&&(t=`${a.FAIL} Failed to remove Docker containers`),e.dockerClean==="OK"&&(e.dockerRebuild?n=`${a.DOCKER} Docker containers rebuilt from scratch`:n=`${a.FAIL} Failed to rebuild Docker containers`,e.dockerLaunch&&e.dockerRebuild?r=`${a.ROCKET} Services running in detached mode`:r=`${a.FAIL} Failed to start Docker containers`);let s=e.buildAndCacheClean&&e.packageManagerClean?`${a.CLEAN} All build artifacts & caches removed`:`${a.FAIL} Build artifacts or cache directories not found`,c=e.dependencyInstall?`${a.BOX} Dependencies freshly installed`:`${a.FAIL} Failed to install dependencies`;console.log(""),$(["\u{1F525} PROJECT SUCCESSFULLY TORCHED! \u{1F525}","",`${s}`,`${c}`,`${t}`,`${n}`,`${r}`,"",e.logfile===!1?`${a.CLIPBOARD} Logging to torch-it.log is disabled; set "logfile": true in torchrc.json to enable it`:`${a.CLIPBOARD} Check torch-it.log for detailed logs`])};var Re=m(require("readline"));function be(e){let t=Re.createInterface({input:process.stdin,output:process.stdout});return new Promise(n=>{t.question(e,r=>{t.close();let s=r.trim().toLowerCase();n(s==="y"||s==="yes")})})}async function De(e,t={}){t.assumeYes===!0||process.env.TORCH_DRY_RUN==="1"||process.stdin.isTTY!==!0||(o(`
|
|
65
65
|
Review the cleanup below. Matching paths and Docker actions (if enabled) will run next.`,"warn"),G(e,{includeHelpFooter:!1}),o(`
|
|
66
66
|
These targets will be removed where they exist. Package caches may be cleared and dependencies reinstalled per your settings.`,"warn"),await be("Continue? Type Yes or No (y/n): ")||(o("Aborted.","info"),process.exit(0)));let r={dockerClean:"NO_DOCKER",buildAndCacheClean:!1,packageManagerClean:!1,dependencyInstall:!1,dockerRebuild:!1,dockerLaunch:!1,logfile:e.logfile};return o(`${a.CLEAN} DOCKER CLEANUP`,"step"),r.dockerClean=ge(e),o(`${a.CLEAN} BUILD ARTIFACTS & CACHE CLEANUP`,"step"),r.buildAndCacheClean=ae(),o("Cleaning package manager caches...","step"),r.packageManagerClean=ce(),e.rebuild!==!1?(z(),o(`${a.BUILD} DEPENDENCY INSTALLATION`,"step"),r.dependencyInstall=ke()):(o("Rebuild disabled - skipping dependency installation","info"),r.dependencyInstall=!1),r.dockerClean!=="NO_DOCKER"&&e.rebuild!==!1?(o(`${a.BUILD} DOCKER REBUILD`,"step"),r.dockerRebuild=he(e)):r.dockerClean!=="NO_DOCKER"&&e.rebuild===!1&&(o("Rebuild disabled - skipping Docker rebuild","info"),r.dockerRebuild=!1),r.dockerRebuild&&(r.dockerLaunch=Ce(e),o(`${a.ROCKET} LAUNCH`,"step")),ye(r),r}var Te=m(require("fs")),Ee=m(require("path"));function je(){return["package.json","yarn.lock","pnpm-lock.yaml","npm-shrinkwrap.json"].some(t=>Te.existsSync(Ee.join(process.cwd(),t)))}function _e(){je()||(o("This directory does not contain a Node.js project.","fail"),o("Please create a Node.js project (with package.json) before using torch-it.","info"),process.exit(1))}var Ue=process.argv.slice(2),U=ue(Ue);de(U);var W=ie(U.filteredArgs);E(W.logfile);W.logfile&&X();J();_e();U.isDryRun&&o("Running in --test dry-run mode (no files or services will be changed)","warn");(async()=>{await De(W,{assumeYes:U.assumeYes})})().catch(e=>{console.error(e),process.exit(1)});
|