torch-it 0.1.0 → 0.2.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 CHANGED
@@ -85,9 +85,19 @@ npx torch --test
85
85
 
86
86
  ---
87
87
 
88
- ## Customization (for contributors)
88
+ ## Customization
89
89
 
90
- If you're working on this repo directly, you can edit cleanup arrays in `src/constants/config.ts`:
90
+ For project-level customization (recommended), create `torchrc.json` in your project root:
91
+
92
+ ```json
93
+ {
94
+ "customPaths": ["apps/web/.next", "services/api/tmp", ".turbo/cache", "coverage-final.json"]
95
+ }
96
+ ```
97
+
98
+ `customPaths` supports both directories and files. Torch will remove these in the same cleanup pass as the built-in targets.
99
+
100
+ If you're working on this repo directly, you can also edit cleanup arrays in `src/constants/config.ts`:
91
101
 
92
102
  - `BUILD_DIRS`: Common framework build output and artifact directories
93
103
  - `CACHE_DIRS`: Cache directories for package managers and tooling
@@ -122,6 +132,10 @@ When `CUSTOM_DIRS` contains paths, `torch` will attempt to remove them in the sa
122
132
  3. Are your Docker configuration files valid?
123
133
  - If you see errors about missing `package.json`, initialize your project with `npm init -y` or add your project files.
124
134
  - 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`:
136
+ ```gitignore
137
+ torch.log
138
+ ```
125
139
 
126
140
  ---
127
141
 
package/dist/torch.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var fe=Object.create;var M=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty;var he=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of de(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?fe(me(e)):{},he(r||!e||!e.__esModule?M(n,"default",{value:e,enumerable:!0}):n,e));var N=C(require("fs"));var U=(e=0)=>r=>`\x1B[${r+e}m`,P=(e=0)=>r=>`\x1B[${38+e};5;${r}m`,Y=(e=0)=>(r,n,o)=>`\x1B[${38+e};2;${r};${n};${o}m`,c={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]}},xe=Object.keys(c.modifier),Ce=Object.keys(c.color),be=Object.keys(c.bgColor),we=[...Ce,...be];function Re(){let e=new Map;for(let[r,n]of Object.entries(c)){for(let[o,s]of Object.entries(n))c[o]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[o]=c[o],e.set(s[0],s[1]);Object.defineProperty(c,r,{value:n,enumerable:!1})}return Object.defineProperty(c,"codes",{value:e,enumerable:!1}),c.color.close="\x1B[39m",c.bgColor.close="\x1B[49m",c.color.ansi=U(),c.color.ansi256=P(),c.color.ansi16m=Y(),c.bgColor.ansi=U(10),c.bgColor.ansi256=P(10),c.bgColor.ansi16m=Y(10),Object.defineProperties(c,{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(l=>l+l).join(""));let s=Number.parseInt(o,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:r=>c.rgbToAnsi256(...c.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 l=Math.max(n,o,s)*2;if(l===0)return 30;let u=30+(Math.round(s)<<2|Math.round(o)<<1|Math.round(n));return l===2&&(u+=60),u},enumerable:!1},rgbToAnsi:{value:(r,n,o)=>c.ansi256ToAnsi(c.rgbToAnsi256(r,n,o)),enumerable:!1},hexToAnsi:{value:r=>c.ansi256ToAnsi(c.hexToAnsi256(r)),enumerable:!1}}),c}var ye=Re(),g=ye;var E=C(require("node:process"),1),j=C(require("node:os"),1),I=C(require("node:tty"),1);function m(e,r=globalThis.Deno?globalThis.Deno.args:E.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:a}=E.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 Oe(){if("FORCE_COLOR"in a)return a.FORCE_COLOR==="true"?1:a.FORCE_COLOR==="false"?0:a.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(a.FORCE_COLOR,10),3)}function ke(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=Oe();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 a&&"AGENT_NAME"in a)return 1;if(e&&!r&&s===void 0)return 0;let l=s||0;if(a.TERM==="dumb")return l;if(E.default.platform==="win32"){let u=j.default.release().split(".");return Number(u[0])>=10&&Number(u[2])>=10586?Number(u[2])>=14931?3:2:1}if("CI"in a)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(u=>u in a)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(u=>u in a)||a.CI_NAME==="codeship"?1:l;if("TEAMCITY_VERSION"in a)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION)?1:0;if(a.COLORTERM==="truecolor"||a.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in a){let u=Number.parseInt((a.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(a.TERM_PROGRAM){case"iTerm.app":return u>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(a.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(a.TERM)||"COLORTERM"in a?1:l}function K(e,r={}){let n=_e(e,{streamIsTTY:e&&e.isTTY,...r});return ke(n)}var Ee={stdout:K({isTTY:I.default.isatty(1)}),stderr:K({isTTY:I.default.isatty(2)})},G=Ee;function H(e,r,n){let o=e.indexOf(r);if(o===-1)return e;let s=r.length,l=0,u="";do u+=e.slice(l,o)+r+n,l=o+s,o=e.indexOf(r,l);while(o!==-1);return u+=e.slice(l),u}function W(e,r,n,o){let s=0,l="";do{let u=e[o-1]==="\r";l+=e.slice(s,u?o-1:o)+r+(u?`\r
2
+ "use strict";var fe=Object.create;var M=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty;var ge=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of de(r))!he.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?fe(me(e)):{},ge(r||!e||!e.__esModule?M(n,"default",{value:e,enumerable:!0}):n,e));var N=C(require("fs"));var U=(e=0)=>r=>`\x1B[${r+e}m`,P=(e=0)=>r=>`\x1B[${38+e};5;${r}m`,Y=(e=0)=>(r,n,o)=>`\x1B[${38+e};2;${r};${n};${o}m`,c={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]}},xe=Object.keys(c.modifier),Ce=Object.keys(c.color),be=Object.keys(c.bgColor),Be=[...Ce,...be];function Re(){let e=new Map;for(let[r,n]of Object.entries(c)){for(let[o,s]of Object.entries(n))c[o]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[o]=c[o],e.set(s[0],s[1]);Object.defineProperty(c,r,{value:n,enumerable:!1})}return Object.defineProperty(c,"codes",{value:e,enumerable:!1}),c.color.close="\x1B[39m",c.bgColor.close="\x1B[49m",c.color.ansi=U(),c.color.ansi256=P(),c.color.ansi16m=Y(),c.bgColor.ansi=U(10),c.bgColor.ansi256=P(10),c.bgColor.ansi16m=Y(10),Object.defineProperties(c,{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=>c.rgbToAnsi256(...c.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 u=30+(Math.round(s)<<2|Math.round(o)<<1|Math.round(n));return i===2&&(u+=60),u},enumerable:!1},rgbToAnsi:{value:(r,n,o)=>c.ansi256ToAnsi(c.rgbToAnsi256(r,n,o)),enumerable:!1},hexToAnsi:{value:r=>c.ansi256ToAnsi(c.hexToAnsi256(r)),enumerable:!1}}),c}var ye=Re(),h=ye;var D=C(require("node:process"),1),K=C(require("node:os"),1),I=C(require("node:tty"),1);function m(e,r=globalThis.Deno?globalThis.Deno.args:D.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:a}=D.default,E;m("no-color")||m("no-colors")||m("color=false")||m("color=never")?E=0:(m("color")||m("colors")||m("color=true")||m("color=always"))&&(E=1);function Oe(){if("FORCE_COLOR"in a)return a.FORCE_COLOR==="true"?1:a.FORCE_COLOR==="false"?0:a.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(a.FORCE_COLOR,10),3)}function ke(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=Oe();o!==void 0&&(E=o);let s=n?E: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 a&&"AGENT_NAME"in a)return 1;if(e&&!r&&s===void 0)return 0;let i=s||0;if(a.TERM==="dumb")return i;if(D.default.platform==="win32"){let u=K.default.release().split(".");return Number(u[0])>=10&&Number(u[2])>=10586?Number(u[2])>=14931?3:2:1}if("CI"in a)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(u=>u in a)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(u=>u in a)||a.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in a)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION)?1:0;if(a.COLORTERM==="truecolor"||a.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in a){let u=Number.parseInt((a.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(a.TERM_PROGRAM){case"iTerm.app":return u>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(a.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(a.TERM)||"COLORTERM"in a?1:i}function j(e,r={}){let n=_e(e,{streamIsTTY:e&&e.isTTY,...r});return ke(n)}var Ee={stdout:j({isTTY:I.default.isatty(1)}),stderr:j({isTTY:I.default.isatty(2)})},G=Ee;function H(e,r,n){let o=e.indexOf(r);if(o===-1)return e;let s=r.length,i=0,u="";do u+=e.slice(i,o)+r+n,i=o+s,o=e.indexOf(r,i);while(o!==-1);return u+=e.slice(i),u}function W(e,r,n,o){let s=0,i="";do{let u=e[o-1]==="\r";i+=e.slice(s,u?o-1:o)+r+(u?`\r
3
3
  `:`
4
4
  `)+n,s=o+1,o=e.indexOf(`
5
- `,s)}while(o!==-1);return l+=e.slice(s),l}var{stdout:V,stderr:X}=G,L=Symbol("GENERATOR"),R=Symbol("STYLER"),O=Symbol("IS_EMPTY"),z=["ansi","ansi","ansi256","ansi16m"],y=Object.create(null),Te=(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 De=e=>{let r=(...n)=>n.join(" ");return Te(r,e),Object.setPrototypeOf(r,k.prototype),r};function k(e){return De(e)}Object.setPrototypeOf(k.prototype,Function.prototype);for(let[e,r]of Object.entries(g))y[e]={get(){let n=T(this,x(r.open,r.close,this[R]),this[O]);return Object.defineProperty(this,e,{value:n}),n}};y.visible={get(){let e=T(this,this[R],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var $=(e,r,n,...o)=>e==="rgb"?r==="ansi16m"?g[n].ansi16m(...o):r==="ansi256"?g[n].ansi256(g.rgbToAnsi256(...o)):g[n].ansi(g.rgbToAnsi(...o)):e==="hex"?$("rgb",r,n,...g.hexToRgb(...o)):g[n][e](...o),Ae=["rgb","hex","ansi256"];for(let e of Ae){y[e]={get(){let{level:n}=this;return function(...o){let s=x($(e,z[n],"color",...o),g.color.close,this[R]);return T(this,s,this[O])}}};let r="bg"+e[0].toUpperCase()+e.slice(1);y[r]={get(){let{level:n}=this;return function(...o){let s=x($(e,z[n],"bgColor",...o),g.bgColor.close,this[R]);return T(this,s,this[O])}}}}var Ne=Object.defineProperties(()=>{},{...y,level:{enumerable:!0,get(){return this[L].level},set(e){this[L].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}},T=(e,r,n)=>{let o=(...s)=>Se(o,s.length===1?""+s[0]:s.join(" "));return Object.setPrototypeOf(o,Ne),o[L]=e,o[R]=r,o[O]=n,o},Se=(e,r)=>{if(e.level<=0||!r)return e[O]?"":r;let n=e[R];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 l=r.indexOf(`
6
- `);return l!==-1&&(r=W(r,s,o,l)),o+r+s};Object.defineProperties(k.prototype,y);var ve=k(),Ke=k({level:X?X.level:0});var b=ve;var p={BOLD:b.bold,CYAN:b.cyan,GREEN:b.green,RED:b.red,YELLOW:b.yellow,PURPLE:b.magenta,RESET:b.reset},i={INFO:"\u{1F525}",SUCCESS:"\u2705",FAIL:"\u274C",EXCLAMATION:"\u2757",WARN:"\u26A0\uFE0F",ROCKET:"\u{1F525}",CLEAN:"\u{1F525}",BUILD:"\u{1FAB5}",TARGET:"\u{1F525}",CELEBRATE:"\u{1F525}",STARS:"\u2728",BOX:"\u{1F4E6}",CLIPBOARD:"\u{1F4CB}",DOCKER:"\u{1F433}"};var w=C(require("fs"));function Ie(e){return e.replace(/\u001b\[[0-9;]*m/g,"")}var J=()=>{w.default.writeFileSync("torch.log","")},D=e=>{let r=Ie(e).replace(/^\n/,""),n=new Date().toISOString();w.default.appendFileSync("torch.log",`[${n}] ${r}
7
- `)};function t(e,r){let n;switch(r){case"info":n=`${p.CYAN(i.INFO)} ${p.BOLD(e)}${p.RESET("")}`;break;case"success":n=`${p.GREEN(i.SUCCESS)} ${e}${p.RESET("")}`;break;case"warn":n=`${p.YELLOW(i.WARN)} ${e}${p.RESET("")}`;break;case"fail":n=`${p.RED(i.FAIL)} ${e}${p.RESET("")}`;break;case"step":n=`
8
- ${p.PURPLE("\u25B6")} ${p.BOLD(e)}${p.RESET("")}`;break;default:n=e}console.log(n),D(n)}function q(){B([` ${i.TARGET} TORCH LIT ${i.ROCKET}`],p.PURPLE);let e=`
5
+ `,s)}while(o!==-1);return i+=e.slice(s),i}var{stdout:V,stderr:J}=G,L=Symbol("GENERATOR"),y=Symbol("STYLER"),k=Symbol("IS_EMPTY"),X=["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 Te=e=>{let r=(...n)=>n.join(" ");return De(r,e),Object.setPrototypeOf(r,_.prototype),r};function _(e){return Te(e)}Object.setPrototypeOf(_.prototype,Function.prototype);for(let[e,r]of Object.entries(h))O[e]={get(){let n=T(this,$(r.open,r.close,this[y]),this[k]);return Object.defineProperty(this,e,{value:n}),n}};O.visible={get(){let e=T(this,this[y],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var w=(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"?w("rgb",r,n,...h.hexToRgb(...o)):h[n][e](...o),Ae=["rgb","hex","ansi256"];for(let e of Ae){O[e]={get(){let{level:n}=this;return function(...o){let s=$(w(e,X[n],"color",...o),h.color.close,this[y]);return T(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=$(w(e,X[n],"bgColor",...o),h.bgColor.close,this[y]);return T(this,s,this[k])}}}}var Se=Object.defineProperties(()=>{},{...O,level:{enumerable:!0,get(){return this[L].level},set(e){this[L].level=e}}}),$=(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}},T=(e,r,n)=>{let o=(...s)=>Ne(o,s.length===1?""+s[0]:s.join(" "));return Object.setPrototypeOf(o,Se),o[L]=e,o[y]=r,o[k]=n,o},Ne=(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(_.prototype,O);var ve=_(),Ke=_({level:J?J.level:0});var b=ve;var p={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}",BUILD:"\u{1FAB5}",TARGET:"\u{1F525}",CELEBRATE:"\u{1F525}",STARS:"\u2728",BOX:"\u{1F4E6}",CLIPBOARD:"\u{1F4CB}",DOCKER:"\u{1F433}"};var x=C(require("fs"));function Ie(e){return e.replace(/\u001b\[[0-9;]*m/g,"")}var z=()=>{x.default.writeFileSync("torch.log","")},A=e=>{let r=Ie(e).replace(/^\n/,""),n=new Date().toISOString();x.default.appendFileSync("torch.log",`[${n}] ${r}
7
+ `)};function t(e,r){let n;switch(r){case"info":n=`${p.CYAN(l.INFO)} ${p.BOLD(e)}${p.RESET("")}`;break;case"success":n=`${p.GREEN(l.SUCCESS)} ${e}${p.RESET("")}`;break;case"warn":n=`${p.YELLOW(l.WARN)} ${e}${p.RESET("")}`;break;case"fail":n=`${p.RED(l.FAIL)} ${e}${p.RESET("")}`;break;case"step":n=`
8
+ ${p.PURPLE("\u25B6")} ${p.BOLD(e)}${p.RESET("")}`;break;default:n=e}console.log(n),A(n)}function q(){B([` ${l.TARGET} TORCH LIT ${l.ROCKET}`],p.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),D(e)}function B(e,r=p.GREEN){let o=r("\u2550".repeat(56));console.log(r("\u2554"+o+"\u2557")),e.forEach(s=>{if(D(s),s.trim()==="")console.log(r("\u2551"+" ".repeat(56)+"\u2551"));else{let l=56-s.length;console.log(r("\u2551"+s+" ".repeat(l)+"\u2551"))}}),console.log(r("\u255A"+o+"\u255D"))}var A=require("child_process"),Q=C(require("os"));function f(e,r={}){try{return(0,A.execSync)(e,{stdio:r.silent?"pipe":"inherit"}),!0}catch{return r.silent||t(`Command failed: ${e}`,"fail"),!1}}function d(e){try{return Q.platform()==="win32"?(0,A.execSync)(`where ${e}`,{stdio:"ignore"}):(0,A.execSync)(`command -v ${e}`,{stdio:"ignore"}),!0}catch{return!1}}function Z(){return N.existsSync("Dockerfile")||N.existsSync("docker-compose.yml")||N.existsSync("docker-compose.yaml")}function ee(){let e=process.env.TORCH_DRY_RUN==="1";return Z()?(t("Stopping Docker services and removing all resources...","info"),d("docker")?f("docker info",{silent:!0})?f("docker compose ps",{silent:!0})?e?(t("Dry-run: would run 'docker compose down --rmi all --volumes'","info"),"OK"):f("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 re(){let e=process.env.TORCH_DRY_RUN==="1";return Z()?d("docker")?f("docker info",{silent:!0})?(t("Building Docker resources (this may take a while...)...","step"),console.log(` ${p.YELLOW("\u23F3 Please be patient - pulling fresh images and building...")}`),e?(t("Dry-run: would run 'docker-compose build --pull --no-cache'","info"),!0):f("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 ne(){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):f("docker compose up -d")?!0:(t("Failed to start Docker services - check torch.log for details","fail"),!1)}var S=C(require("fs"));var oe=["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","lib","es","cjs","umd"],te=[".pnpm-store",".pnpm-debug.log",".yarn/cache",".yarn/unplugged",".yarn/install-state.gz",".yarn/build-state.yml",".npm","node_modules/.cache"],se=[];var le=()=>{let e=process.env.TORCH_DRY_RUN==="1",r=0;return t("Scanning for build artifacts and cache directories...","step"),[...oe,...te,...se].forEach(n=>{if(S.existsSync(n)){t(`${e?"Would remove":"Removing"} ${n}...`,"step");try{e||S.rmSync(n,{recursive:!0,force:!0}),t(`${n} ${e?"marked for removal (dry-run)":"removed"}`,"success"),r++}catch{t(`Failed to remove ${n}`,"fail")}}}),r===0?(t("No build artifacts or cache directories found (project already clean)","info"),!1):(t(`Removed ${r} build/cache directories`,"success"),!0)},ie=()=>{let e=process.env.TORCH_DRY_RUN==="1",r=!1;return d("npm")&&(e||f("npm cache clean --force"))&&(t(e?"Dry-run: would clean npm cache":"npm cache cleaned","success"),r=!0),d("yarn")&&(e||f("yarn cache clean"))&&(t(e?"Dry-run: would clean yarn cache":"yarn cache cleaned","success"),r=!0),d("pnpm")&&(e||f("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 ce=()=>{let e=process.env.TORCH_DRY_RUN==="1",r=!1;return t("Detecting package manager and installing dependencies...","step"),v.existsSync("pnpm-lock.yaml")&&d("pnpm")?(t("Using pnpm (detected pnpm-lock.yaml)...","step"),e||f("pnpm install")?(t(`Dependencies ${e?"would be installed":"installed successfully"} with pnpm`,"success"),r=!0):t("pnpm install failed","fail")):v.existsSync("yarn.lock")&&d("yarn")?(t("Using yarn (detected yarn.lock)...","step"),e||f("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")&&d("npm")?(t("Using npm (detected package-lock.json)...","step"),e||f("npm install")?(t(`Dependencies ${e?"would be installed":"installed successfully"} with npm`,"success"),r=!0):t("npm install failed","fail")):d("npm")?(t("Using npm (fallback)...","info"),e||f("npm install")?(t(`Dependencies ${e?"would be installed":"installed successfully"} with npm`,"success"),r=!0):t("npm install failed","fail")):d("yarn")?(t("Using yarn (fallback)...","info"),e||f("yarn install")?(t(`Dependencies ${e?"would be installed":"installed successfully"} with yarn`,"success"),r=!0):t("yarn install failed","")):d("pnpm")?(t("Using pnpm (fallback)...","info"),e||f("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 ae=e=>{let r="",n="",o="";e.dockerClean==="NO_DOCKER"?r=`${i.DOCKER} No Docker containers found`:e.dockerClean==="DOCKER_FAIL"&&(r=`${i.FAIL} Failed to remove Docker containers`),e.dockerClean==="OK"&&(e.dockerRebuild?n=`${i.DOCKER} Docker containers rebuilt from scratch`:n=`${i.FAIL} Failed to rebuild Docker containers`,e.dockerLaunch&&e.dockerRebuild?o=`${i.ROCKET} Services running in detached mode`:o=`${i.FAIL} Failed to start Docker containers`);let s=e.buildAndCacheClean&&e.packageManagerClean?`${i.CLEAN} All build artifacts & caches removed`:`${i.FAIL} Build artifacts or cache directories not found`,l=e.dependencyInstall?`${i.BOX} Dependencies freshly installed`:`${i.FAIL} Failed to install dependencies`;console.log(""),B(["\u{1F525} PROJECT SUCCESSFULLY TORCHED! \u{1F525}","",`${s}`,`${l}`,`${r}`,`${n}`,`${o}`,"",`${i.CLIPBOARD} Check torch.log for detailed logs`])};var Le=process.argv.slice(2),ue=Le.includes("--test");ue&&(process.env.TORCH_DRY_RUN="1");J();q();ue&&t("Running in --test dry-run mode (no files or services will be changed)","warn");var h={dockerClean:"NO_DOCKER",buildAndCacheClean:!1,packageManagerClean:!1,dependencyInstall:!1,dockerRebuild:!1,dockerLaunch:!1};t(`${i.CLEAN} DOCKER CLEANUP`,"step");h.dockerClean=ee();t(`${i.CLEAN} BUILD ARTIFACTS & CACHE CLEANUP`,"step");h.buildAndCacheClean=le();t("Cleaning package manager caches...","step");h.packageManagerClean=ie();t(`${i.BUILD} DEPENDENCY INSTALLATION`,"step");h.dependencyInstall=ce();h.dockerClean&&(t(`${i.BUILD} DOCKER REBUILD`,"step"),h.dockerRebuild=re());h.dockerRebuild&&(h.dockerLaunch=ne(),t(`${i.ROCKET} LAUNCH`,"step"));ae(h);
19
+ `;console.log(e),A(e)}function B(e,r=p.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 S=require("child_process"),Q=C(require("os"));function f(e,r={}){try{return(0,S.execSync)(e,{stdio:r.silent?"pipe":"inherit"}),!0}catch{return r.silent||t(`Command failed: ${e}`,"fail"),!1}}function d(e){try{return Q.platform()==="win32"?(0,S.execSync)(`where ${e}`,{stdio:"ignore"}):(0,S.execSync)(`command -v ${e}`,{stdio:"ignore"}),!0}catch{return!1}}function Z(){return N.existsSync("Dockerfile")||N.existsSync("docker-compose.yml")||N.existsSync("docker-compose.yaml")}function ee(){let e=process.env.TORCH_DRY_RUN==="1";return Z()?(t("Stopping Docker services and removing all resources...","info"),d("docker")?f("docker info",{silent:!0})?f("docker compose ps",{silent:!0})?e?(t("Dry-run: would run 'docker compose down --rmi all --volumes'","info"),"OK"):f("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 re(){let e=process.env.TORCH_DRY_RUN==="1";return Z()?d("docker")?f("docker info",{silent:!0})?(t("Building Docker resources (this may take a while...)...","step"),console.log(` ${p.YELLOW("\u23F3 Please be patient - pulling fresh images and building...")}`),e?(t("Dry-run: would run 'docker-compose build --pull --no-cache'","info"),!0):f("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 ne(){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):f("docker compose up -d")?!0:(t("Failed to start Docker services - check torch.log for details","fail"),!1)}var R=C(require("fs"));var oe=["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","lib","es","cjs","umd"],te=[".pnpm-store",".pnpm-debug.log",".yarn/cache",".yarn/unplugged",".yarn/install-state.gz",".yarn/build-state.yml",".npm","node_modules/.cache"],se=[];var Le=()=>{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"),[]}},ie=()=>{let e=process.env.TORCH_DRY_RUN==="1",r=0,n=Le(),o=[...new Set([...oe,...te,...se,...n])];return n.length>0&&t(`Loaded ${n.length} custom path(s) from torchrc.json`,"info"),t("Scanning for build artifacts and cache directories...","step"),o.forEach(s=>{if(R.existsSync(s)){t(`${e?"Would remove":"Removing"} ${s}...`,"step");try{e||R.rmSync(s,{recursive:!0,force:!0}),t(`${s} ${e?"marked for removal (dry-run)":"removed"}`,"success"),r++}catch{t(`Failed to remove ${s}`,"fail")}}}),r===0?(t("No build artifacts or cache directories found (project already clean)","info"),!1):(t(`Removed ${r} build/cache directories`,"success"),!0)},le=()=>{let e=process.env.TORCH_DRY_RUN==="1",r=!1;return d("npm")&&(e||f("npm cache clean --force"))&&(t(e?"Dry-run: would clean npm cache":"npm cache cleaned","success"),r=!0),d("yarn")&&(e||f("yarn cache clean"))&&(t(e?"Dry-run: would clean yarn cache":"yarn cache cleaned","success"),r=!0),d("pnpm")&&(e||f("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 ce=()=>{let e=process.env.TORCH_DRY_RUN==="1",r=!1;return t("Detecting package manager and installing dependencies...","step"),v.existsSync("pnpm-lock.yaml")&&d("pnpm")?(t("Using pnpm (detected pnpm-lock.yaml)...","step"),e||f("pnpm install")?(t(`Dependencies ${e?"would be installed":"installed successfully"} with pnpm`,"success"),r=!0):t("pnpm install failed","fail")):v.existsSync("yarn.lock")&&d("yarn")?(t("Using yarn (detected yarn.lock)...","step"),e||f("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")&&d("npm")?(t("Using npm (detected package-lock.json)...","step"),e||f("npm install")?(t(`Dependencies ${e?"would be installed":"installed successfully"} with npm`,"success"),r=!0):t("npm install failed","fail")):d("npm")?(t("Using npm (fallback)...","info"),e||f("npm install")?(t(`Dependencies ${e?"would be installed":"installed successfully"} with npm`,"success"),r=!0):t("npm install failed","fail")):d("yarn")?(t("Using yarn (fallback)...","info"),e||f("yarn install")?(t(`Dependencies ${e?"would be installed":"installed successfully"} with yarn`,"success"),r=!0):t("yarn install failed","")):d("pnpm")?(t("Using pnpm (fallback)...","info"),e||f("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 ae=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(""),B(["\u{1F525} PROJECT SUCCESSFULLY TORCHED! \u{1F525}","",`${s}`,`${i}`,`${r}`,`${n}`,`${o}`,"",`${l.CLIPBOARD} Check torch.log for detailed logs`])};var we=process.argv.slice(2),ue=we.includes("--test");ue&&(process.env.TORCH_DRY_RUN="1");z();q();ue&&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=ee();t(`${l.CLEAN} BUILD ARTIFACTS & CACHE CLEANUP`,"step");g.buildAndCacheClean=ie();t("Cleaning package manager caches...","step");g.packageManagerClean=le();t(`${l.BUILD} DEPENDENCY INSTALLATION`,"step");g.dependencyInstall=ce();g.dockerClean&&(t(`${l.BUILD} DOCKER REBUILD`,"step"),g.dockerRebuild=re());g.dockerRebuild&&(g.dockerLaunch=ne(),t(`${l.ROCKET} LAUNCH`,"step"));ae(g);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "torch-it",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "CLI to reset, clean, and rebuild Node.js project environments.",
5
5
  "keywords": [
6
6
  "cleanup",