torch-it 0.2.1 โ 1.0.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.
- package/README.md +32 -27
- package/dist/torch.js +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,12 +8,38 @@ A powerful, all-in-one TypeScript tool to **reset, clean, and rebuild** your Nod
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Project stopped working for no obvious reason ๐ ?
|
|
12
|
+
|
|
13
|
+
You'd like to kick it ๐ฅพ?
|
|
14
|
+
Hit it with a hammer ๐จ?
|
|
15
|
+
Turn it off and on again ๐บ?
|
|
16
|
+
|
|
17
|
+
Well better still - try torching it instead ๐ฅ๐ฅ๐ฅ๐ฅ๐ฅ๐ฅ.
|
|
18
|
+
|
|
19
|
+
## What does `torch-it` do?
|
|
20
|
+
|
|
21
|
+
Nuke your local caches, dependencies, and Docker environment โ then rebuild everything from a clean slate, **with a single command**.
|
|
22
|
+
|
|
23
|
+
It's surprising how often this just fixes things. ๐ค
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- **One command** to clear all local caches, delete `node_modules`, and reinstall dependencies
|
|
28
|
+
- **Fully customizable** โ specify any directories or files to delete
|
|
29
|
+
- **Docker support** โ removes containers, images, and volumes and rebuilds from scratch ๐ณ
|
|
30
|
+
|
|
31
|
+
## Supported Frameworks
|
|
32
|
+
|
|
33
|
+
React, Next.js, Vue, Vite, SvelteKit, React Native, Expo, and more.
|
|
34
|
+
|
|
35
|
+
## Supported Package Managers
|
|
36
|
+
|
|
37
|
+
`npm` ยท `yarn` ยท `pnpm`
|
|
12
38
|
|
|
13
39
|
### Core Operations (Always Performed)
|
|
14
40
|
|
|
15
41
|
- **Removes build artifacts and cache directories** for common JavaScript/Node.js frameworks (e.g., `node_modules`, `dist`, `.next`, `.cache`, etc.).
|
|
16
|
-
- **Removes custom directories/paths** that you define in `
|
|
42
|
+
- **Removes custom directories/paths** that you define in `torchrc.json`.
|
|
17
43
|
- **Cleans package manager caches** for npm, yarn, and pnpm.
|
|
18
44
|
- **Reinstalls dependencies** using your preferred package manager (npm, yarn, or pnpm).
|
|
19
45
|
|
|
@@ -97,32 +123,10 @@ For project-level customization (recommended), create `torchrc.json` in your pro
|
|
|
97
123
|
|
|
98
124
|
`customPaths` supports both directories and files. Torch will remove these in the same cleanup pass as the built-in targets.
|
|
99
125
|
|
|
100
|
-
If you're working on this repo directly, you can also edit cleanup arrays in `src/constants/config.ts`:
|
|
101
126
|
|
|
102
|
-
|
|
103
|
-
- `CACHE_DIRS`: Cache directories for package managers and tooling
|
|
104
|
-
- `CUSTOM_DIRS`: Project-specific files/directories you want deleted during torch
|
|
127
|
+
## Logging
|
|
105
128
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
```ts
|
|
109
|
-
export const CUSTOM_DIRS = [
|
|
110
|
-
"apps/web/.next",
|
|
111
|
-
"services/api/tmp",
|
|
112
|
-
"generated",
|
|
113
|
-
] as const;
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
When `CUSTOM_DIRS` contains paths, `torch` will attempt to remove them in the same cleanup pass as build/cache directories.
|
|
117
|
-
|
|
118
|
-
---
|
|
119
|
-
|
|
120
|
-
## Commit & Branch Rules
|
|
121
|
-
|
|
122
|
-
- Branch names are validated and must match: `main`, `dev`, or `<type>/<name>` where `<type>` is `feat`, `fix`, `hotfix`, `release`, or `chore`.
|
|
123
|
-
- Commit messages use Conventional Commits via commitlint, e.g. `feat: add docker dry-run messaging`, `fix: handle missing package manager`.
|
|
124
|
-
|
|
125
|
-
---
|
|
129
|
+
`torch` outputs information to the console and writes logs to `torch.log` in your project root so you can troubleshoot any issues and see what was removed and reinstalled.
|
|
126
130
|
|
|
127
131
|
## Troubleshooting
|
|
128
132
|
|
|
@@ -132,7 +136,8 @@ When `CUSTOM_DIRS` contains paths, `torch` will attempt to remove them in the sa
|
|
|
132
136
|
3. Are your Docker configuration files valid?
|
|
133
137
|
- If you see errors about missing `package.json`, initialize your project with `npm init -y` or add your project files.
|
|
134
138
|
- For detailed information about any failures, check the `torch.log` file.
|
|
135
|
-
- `torch.log` is generated during runs and should be ignored by git to avoid accidental commits. Add this to your `.gitignore`:
|
|
139
|
+
- `torch.log` is generated during runs and should be ignored by git to avoid accidental commits. Add this to your `.gitignore`:
|
|
140
|
+
|
|
136
141
|
```gitignore
|
|
137
142
|
torch.log
|
|
138
143
|
```
|
package/dist/torch.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var de=Object.create;var M=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var he=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty;var Ce=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of me(r))!ge.call(e,s)&&s!==n&&M(e,s,{get:()=>r[s],enumerable:!(o=pe(r,s))||o.enumerable});return e};var C=(e,r,n)=>(n=e!=null?de(he(e)):{},Ce(r||!e||!e.__esModule?M(n,"default",{value:e,enumerable:!0}):n,e));var I=C(require("fs"));var P=(e=0)=>r=>`\x1B[${r+e}m`,U=(e=0)=>r=>`\x1B[${38+e};5;${r}m`,Y=(e=0)=>(r,n,o)=>`\x1B[${38+e};2;${r};${n};${o}m`,a={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Be=Object.keys(a.modifier),be=Object.keys(a.color),Re=Object.keys(a.bgColor),Fe=[...be,...Re];function ye(){let e=new Map;for(let[r,n]of Object.entries(a)){for(let[o,s]of Object.entries(n))a[o]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[o]=a[o],e.set(s[0],s[1]);Object.defineProperty(a,r,{value:n,enumerable:!1})}return Object.defineProperty(a,"codes",{value:e,enumerable:!1}),a.color.close="\x1B[39m",a.bgColor.close="\x1B[49m",a.color.ansi=P(),a.color.ansi256=U(),a.color.ansi16m=Y(),a.bgColor.ansi=P(10),a.bgColor.ansi256=U(10),a.bgColor.ansi16m=Y(10),Object.defineProperties(a,{rgbToAnsi256:{value(r,n,o){return r===n&&n===o?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(n/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(r){let n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(r.toString(16));if(!n)return[0,0,0];let[o]=n;o.length===3&&(o=[...o].map(i=>i+i).join(""));let s=Number.parseInt(o,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:r=>a.rgbToAnsi256(...a.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value(r){if(r<8)return 30+r;if(r<16)return 90+(r-8);let n,o,s;if(r>=232)n=((r-232)*10+8)/255,o=n,s=n;else{r-=16;let F=r%36;n=Math.floor(r/36)/5,o=Math.floor(F/6)/5,s=F%6/5}let i=Math.max(n,o,s)*2;if(i===0)return 30;let c=30+(Math.round(s)<<2|Math.round(o)<<1|Math.round(n));return i===2&&(c+=60),c},enumerable:!1},rgbToAnsi:{value:(r,n,o)=>a.ansi256ToAnsi(a.rgbToAnsi256(r,n,o)),enumerable:!1},hexToAnsi:{value:r=>a.ansi256ToAnsi(a.hexToAnsi256(r)),enumerable:!1}}),a}var Oe=ye(),h=Oe;var T=C(require("node:process"),1),K=C(require("node:os"),1),L=C(require("node:tty"),1);function m(e,r=globalThis.Deno?globalThis.Deno.args:T.default.argv){let n=e.startsWith("-")?"":e.length===1?"-":"--",o=r.indexOf(n+e),s=r.indexOf("--");return o!==-1&&(s===-1||o<s)}var{env:u}=T.default,_;m("no-color")||m("no-colors")||m("color=false")||m("color=never")?_=0:(m("color")||m("colors")||m("color=true")||m("color=always"))&&(_=1);function ke(){if("FORCE_COLOR"in u)return u.FORCE_COLOR==="true"?1:u.FORCE_COLOR==="false"?0:u.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(u.FORCE_COLOR,10),3)}function Ee(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function _e(e,{streamIsTTY:r,sniffFlags:n=!0}={}){let o=ke();o!==void 0&&(_=o);let s=n?_:o;if(s===0)return 0;if(n){if(m("color=16m")||m("color=full")||m("color=truecolor"))return 3;if(m("color=256"))return 2}if("TF_BUILD"in u&&"AGENT_NAME"in u)return 1;if(e&&!r&&s===void 0)return 0;let i=s||0;if(u.TERM==="dumb")return i;if(T.default.platform==="win32"){let c=K.default.release().split(".");return Number(c[0])>=10&&Number(c[2])>=10586?Number(c[2])>=14931?3:2:1}if("CI"in u)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(c=>c in u)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(c=>c in u)||u.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in u)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(u.TEAMCITY_VERSION)?1:0;if(u.COLORTERM==="truecolor"||u.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in u){let c=Number.parseInt((u.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(u.TERM_PROGRAM){case"iTerm.app":return c>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(u.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(u.TERM)||"COLORTERM"in u?1:i}function j(e,r={}){let n=_e(e,{streamIsTTY:e&&e.isTTY,...r});return Ee(n)}var Te={stdout:j({isTTY:L.default.isatty(1)}),stderr:j({isTTY:L.default.isatty(2)})},G=Te;function H(e,r,n){let o=e.indexOf(r);if(o===-1)return e;let s=r.length,i=0,c="";do c+=e.slice(i,o)+r+n,i=o+s,o=e.indexOf(r,i);while(o!==-1);return c+=e.slice(i),c}function W(e,r,n,o){let s=0,i="";do{let c=e[o-1]==="\r";i+=e.slice(s,c?o-1:o)+r+(c?`\r
|
|
3
3
|
`:`
|
|
4
4
|
`)+n,s=o+1,o=e.indexOf(`
|
|
5
|
-
`,s)}while(o!==-1);return i+=e.slice(s),i}var{stdout:V,stderr:
|
|
6
|
-
`);return i!==-1&&(r=W(r,s,o,i)),o+r+s};Object.defineProperties(
|
|
7
|
-
`)};function t(e,r){let n;switch(r){case"info":n=`${
|
|
8
|
-
${
|
|
5
|
+
`,s)}while(o!==-1);return i+=e.slice(s),i}var{stdout:V,stderr:X}=G,w=Symbol("GENERATOR"),y=Symbol("STYLER"),k=Symbol("IS_EMPTY"),J=["ansi","ansi","ansi256","ansi16m"],O=Object.create(null),De=(e,r={})=>{if(r.level&&!(Number.isInteger(r.level)&&r.level>=0&&r.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let n=V?V.level:0;e.level=r.level===void 0?n:r.level};var Ae=e=>{let r=(...n)=>n.join(" ");return De(r,e),Object.setPrototypeOf(r,E.prototype),r};function E(e){return Ae(e)}Object.setPrototypeOf(E.prototype,Function.prototype);for(let[e,r]of Object.entries(h))O[e]={get(){let n=D(this,x(r.open,r.close,this[y]),this[k]);return Object.defineProperty(this,e,{value:n}),n}};O.visible={get(){let e=D(this,this[y],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var $=(e,r,n,...o)=>e==="rgb"?r==="ansi16m"?h[n].ansi16m(...o):r==="ansi256"?h[n].ansi256(h.rgbToAnsi256(...o)):h[n].ansi(h.rgbToAnsi(...o)):e==="hex"?$("rgb",r,n,...h.hexToRgb(...o)):h[n][e](...o),Se=["rgb","hex","ansi256"];for(let e of Se){O[e]={get(){let{level:n}=this;return function(...o){let s=x($(e,J[n],"color",...o),h.color.close,this[y]);return D(this,s,this[k])}}};let r="bg"+e[0].toUpperCase()+e.slice(1);O[r]={get(){let{level:n}=this;return function(...o){let s=x($(e,J[n],"bgColor",...o),h.bgColor.close,this[y]);return D(this,s,this[k])}}}}var Ne=Object.defineProperties(()=>{},{...O,level:{enumerable:!0,get(){return this[w].level},set(e){this[w].level=e}}}),x=(e,r,n)=>{let o,s;return n===void 0?(o=e,s=r):(o=n.openAll+e,s=r+n.closeAll),{open:e,close:r,openAll:o,closeAll:s,parent:n}},D=(e,r,n)=>{let o=(...s)=>Ie(o,s.length===1?""+s[0]:s.join(" "));return Object.setPrototypeOf(o,Ne),o[w]=e,o[y]=r,o[k]=n,o},Ie=(e,r)=>{if(e.level<=0||!r)return e[k]?"":r;let n=e[y];if(n===void 0)return r;let{openAll:o,closeAll:s}=n;if(r.includes("\x1B"))for(;n!==void 0;)r=H(r,n.close,n.open),n=n.parent;let i=r.indexOf(`
|
|
6
|
+
`);return i!==-1&&(r=W(r,s,o,i)),o+r+s};Object.defineProperties(E.prototype,O);var ve=E(),Ge=E({level:X?X.level:0});var b=ve;var f={BOLD:b.bold,CYAN:b.cyan,GREEN:b.green,RED:b.red,YELLOW:b.yellow,PURPLE:b.magenta,RESET:b.reset},l={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 B=C(require("fs"));function Le(e){return e.replace(/\u001b\[[0-9;]*m/g,"")}var z=()=>{B.default.writeFileSync("torch.log","")},A=e=>{let r=Le(e).replace(/^\n/,""),n=new Date().toISOString();B.default.appendFileSync("torch.log",`[${n}] ${r}
|
|
7
|
+
`)};function t(e,r){let n;switch(r){case"info":n=`${f.CYAN(l.INFO)} ${f.BOLD(e)}${f.RESET("")}`;break;case"success":n=`${f.GREEN(l.SUCCESS)} ${e}${f.RESET("")}`;break;case"warn":n=`${f.YELLOW(l.WARN)} ${e}${f.RESET("")}`;break;case"fail":n=`${f.RED(l.FAIL)} ${e}${f.RESET("")}`;break;case"step":n=`
|
|
8
|
+
${f.PURPLE("\u25B6")} ${f.BOLD(e)}${f.RESET("")}`;break;default:n=e}console.log(n),A(n)}function q(){S([` ${l.TARGET} TORCH LIT ${l.ROCKET}`],f.PURPLE);let e=`
|
|
9
9
|
) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )
|
|
10
10
|
(( (( (( (( (( (( (( (( (( (( (( (( (( ((
|
|
11
11
|
) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )
|
|
@@ -16,4 +16,4 @@ ${p.PURPLE("\u25B6")} ${p.BOLD(e)}${p.RESET("")}`;break;default:n=e}console.log(
|
|
|
16
16
|
| _ \\| | | | |_) | \\| || || \\| | | _
|
|
17
17
|
| |_) | |_| | _ <| |\\ || || |\\ | |_| |
|
|
18
18
|
|____/ \\___/|_| \\_\\_| \\_|___|_| \\_|\\____|
|
|
19
|
-
`;console.log(e),A(e)}function
|
|
19
|
+
`;console.log(e),A(e)}function Q(){console.log(""),S([` ${l.PHOENIX} RISING FROM THE ASHES ${l.PHOENIX}`],f.PURPLE)}function S(e,r=f.GREEN){let o=r("\u2550".repeat(56));console.log(r("\u2554"+o+"\u2557")),e.forEach(s=>{if(A(s),s.trim()==="")console.log(r("\u2551"+" ".repeat(56)+"\u2551"));else{let i=56-s.length;console.log(r("\u2551"+s+" ".repeat(i)+"\u2551"))}}),console.log(r("\u255A"+o+"\u255D"))}var N=require("child_process"),Z=C(require("os"));function d(e,r={}){try{return(0,N.execSync)(e,{stdio:r.silent?"pipe":"inherit"}),!0}catch{return r.silent||t(`Command failed: ${e}`,"fail"),!1}}function p(e){try{return Z.platform()==="win32"?(0,N.execSync)(`where ${e}`,{stdio:"ignore"}):(0,N.execSync)(`command -v ${e}`,{stdio:"ignore"}),!0}catch{return!1}}function ee(){return I.existsSync("Dockerfile")||I.existsSync("docker-compose.yml")||I.existsSync("docker-compose.yaml")}function re(){let e=process.env.TORCH_DRY_RUN==="1";return ee()?(t("Stopping Docker services and removing all resources...","info"),p("docker")?d("docker info",{silent:!0})?d("docker compose ps",{silent:!0})?e?(t("Dry-run: would run 'docker compose down --rmi all --volumes'","info"),"OK"):d("docker compose down --rmi all --volumes")?(t("Docker services stopped and resources cleaned","success"),"OK"):(t("Docker cleanup encountered issues","warn"),t("Continuing with the rest of the script...","info"),"DOCKER_FAIL"):(t("No Docker Compose services found - skipping Docker cleanup","warn"),t("This is normal if no services were previously running","info"),"DOCKER_FAIL"):(t("Docker daemon is not running - skipping Docker cleanup","warn"),t("You may need to start Docker manually and run cleanup later","info"),"NO_DOCKER"):(t("Docker is not installed - skipping Docker cleanup","warn"),"NO_DOCKER")):(t("No Docker configuration found - skipping Docker operations","info"),"NO_DOCKER")}function ne(){let e=process.env.TORCH_DRY_RUN==="1";return ee()?p("docker")?d("docker info",{silent:!0})?(t("Building Docker resources (this may take a while...)...","step"),console.log(` ${f.YELLOW("\u23F3 Please be patient - pulling fresh images and building...")}`),e?(t("Dry-run: would run 'docker-compose build --pull --no-cache'","info"),!0):d("docker-compose build --pull --no-cache")?!0:(t("Docker build encountered issues - check torch.log for details","fail"),!1)):(t("Docker daemon is not running - skipping Docker rebuild","warn"),t("Start Docker manually and run 'docker-compose build --pull --no-cache' later","info"),!1):(t("Docker is not installed - skipping Docker rebuild","warn"),!1):!1}function oe(){let e=process.env.TORCH_DRY_RUN==="1";return t("Starting Docker services in detached mode...","step"),e?(t("Dry-run: would run 'docker compose up -d'","info"),!0):d("docker compose up -d")?!0:(t("Failed to start Docker services - check torch.log for details","fail"),!1)}var R=C(require("fs"));var te=["node_modules","dist","build",".svelte-kit",".svelte",".next",".nuxt","out",".output",".vercel",".netlify",".astro",".angular",".angular/cache",".solid",".docusaurus",".vite",".cache",".parcel-cache",".webpack",".rollup.cache",".rpt2_cache",".swc",".eslintcache",".stylelintcache",".sass-cache",".tmp","tmp","temp","coverage",".nyc_output","storybook-static",".storybook-out",".turbo",".rush",".firebase",".serverless","android/.gradle","android/build","android/app/build","ios/Pods","ios/build",".expo",".expo-shared","lib","es","cjs","umd"],se=[".pnpm-store",".pnpm-debug.log",".yarn/cache",".yarn/unplugged",".yarn/install-state.gz",".yarn/build-state.yml",".npm","node_modules/.cache"],ie=[];var we=()=>{let e="torchrc.json";if(!R.existsSync(e))return[];try{let r=JSON.parse(R.readFileSync(e,"utf8"));return[...Array.isArray(r.customPaths)?r.customPaths:[],...Array.isArray(r.customDirs)?r.customDirs:[],...Array.isArray(r.customFiles)?r.customFiles:[]].filter(o=>typeof o=="string").map(o=>o.trim()).filter(o=>o.length>0)}catch{return t("Invalid torchrc.json (must be valid JSON) - skipping custom paths","warn"),[]}},le=()=>{let e=process.env.TORCH_DRY_RUN==="1",r=0,n=we(),o=[...new Set([...te,...se,...ie])],s=[...new Set(n)],i=c=>{if(R.existsSync(c)){t(`${e?"Would remove":"Removing"} ${c}...`,"step");try{e||R.rmSync(c,{recursive:!0,force:!0}),t(`${c} ${e?"marked for removal (dry-run)":"removed"}`,"success"),r++}catch{t(`Failed to remove ${c}`,"fail")}}};return t("Scanning for build artifacts and cache directories...","step"),o.forEach(i),s.length>0&&(t("Deleting user defined custom directories and files","step"),s.forEach(i)),r===0?(t("No build artifacts or cache directories found (project already clean)","info"),!1):(t(`Removed ${r} build/cache directories`,"success"),!0)},ce=()=>{let e=process.env.TORCH_DRY_RUN==="1",r=!1;return p("npm")&&(e||d("npm cache clean --force"))&&(t(e?"Dry-run: would clean npm cache":"npm cache cleaned","success"),r=!0),p("yarn")&&(e||d("yarn cache clean"))&&(t(e?"Dry-run: would clean yarn cache":"yarn cache cleaned","success"),r=!0),p("pnpm")&&(e||d("pnpm store prune"))&&(t(e?"Dry-run: would clean pnpm store":"pnpm store cleaned","success"),r=!0),r||t("No package manager caches cleaned (tools not available)","info"),r};var v=C(require("fs"));var ae=()=>{let e=process.env.TORCH_DRY_RUN==="1",r=!1;return t("Detecting package manager and installing dependencies...","step"),v.existsSync("pnpm-lock.yaml")&&p("pnpm")?(t("Using pnpm (detected pnpm-lock.yaml)...","step"),e||d("pnpm install")?(t(`Dependencies ${e?"would be installed":"installed successfully"} with pnpm`,"success"),r=!0):t("pnpm install failed","fail")):v.existsSync("yarn.lock")&&p("yarn")?(t("Using yarn (detected yarn.lock)...","step"),e||d("yarn install")?(t(`Dependencies ${e?"would be installed":"installed successfully"} with yarn`,"success"),r=!0):t("yarn install failed","fail")):v.existsSync("package-lock.json")&&p("npm")?(t("Using npm (detected package-lock.json)...","step"),e||d("npm install")?(t(`Dependencies ${e?"would be installed":"installed successfully"} with npm`,"success"),r=!0):t("npm install failed","fail")):p("npm")?(t("Using npm (fallback)...","info"),e||d("npm install")?(t(`Dependencies ${e?"would be installed":"installed successfully"} with npm`,"success"),r=!0):t("npm install failed","fail")):p("yarn")?(t("Using yarn (fallback)...","info"),e||d("yarn install")?(t(`Dependencies ${e?"would be installed":"installed successfully"} with yarn`,"success"),r=!0):t("yarn install failed","")):p("pnpm")?(t("Using pnpm (fallback)...","info"),e||d("pnpm install")?(t(`Dependencies ${e?"would be installed":"installed successfully"} with pnpm`,"success"),r=!0):t("pnpm install failed","fail")):t("No package manager found (npm/yarn/pnpm). Please install dependencies manually.","fail"),r};var ue=e=>{let r="",n="",o="";e.dockerClean==="NO_DOCKER"?r=`${l.DOCKER} No Docker containers found`:e.dockerClean==="DOCKER_FAIL"&&(r=`${l.FAIL} Failed to remove Docker containers`),e.dockerClean==="OK"&&(e.dockerRebuild?n=`${l.DOCKER} Docker containers rebuilt from scratch`:n=`${l.FAIL} Failed to rebuild Docker containers`,e.dockerLaunch&&e.dockerRebuild?o=`${l.ROCKET} Services running in detached mode`:o=`${l.FAIL} Failed to start Docker containers`);let s=e.buildAndCacheClean&&e.packageManagerClean?`${l.CLEAN} All build artifacts & caches removed`:`${l.FAIL} Build artifacts or cache directories not found`,i=e.dependencyInstall?`${l.BOX} Dependencies freshly installed`:`${l.FAIL} Failed to install dependencies`;console.log(""),S(["\u{1F525} PROJECT SUCCESSFULLY TORCHED! \u{1F525}","",`${s}`,`${i}`,`${r}`,`${n}`,`${o}`,"",`${l.CLIPBOARD} Check torch.log for detailed logs`])};var $e=process.argv.slice(2),fe=$e.includes("--test");fe&&(process.env.TORCH_DRY_RUN="1");z();q();fe&&t("Running in --test dry-run mode (no files or services will be changed)","warn");var g={dockerClean:"NO_DOCKER",buildAndCacheClean:!1,packageManagerClean:!1,dependencyInstall:!1,dockerRebuild:!1,dockerLaunch:!1};t(`${l.CLEAN} DOCKER CLEANUP`,"step");g.dockerClean=re();t(`${l.CLEAN} BUILD ARTIFACTS & CACHE CLEANUP`,"step");g.buildAndCacheClean=le();t("Cleaning package manager caches...","step");g.packageManagerClean=ce();Q();t(`${l.BUILD} DEPENDENCY INSTALLATION`,"step");g.dependencyInstall=ae();g.dockerClean&&(t(`${l.BUILD} DOCKER REBUILD`,"step"),g.dockerRebuild=ne());g.dockerRebuild&&(g.dockerLaunch=oe(),t(`${l.ROCKET} LAUNCH`,"step"));ue(g);
|