@tochii/build 2.3.0 → 2.5.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.
@@ -1,9 +1,9 @@
1
- var _=Object.create;var F=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var Se=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var se=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var oe=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ne(e))!re.call(n,s)&&s!==t&&F(n,s,{get:()=>e[s],enumerable:!(r=ee(e,s))||r.enumerable});return n};var ie=(n,e,t)=>(t=n!=null?_(te(n)):{},oe(e||!n||!n.__esModule?F(t,"default",{value:n,enumerable:!0}):t,n));var L=se((Je,H)=>{"use strict";var ye=function(e){return ge(e)&&!me(e)};function ge(n){return!!n&&typeof n=="object"}function me(n){var e=Object.prototype.toString.call(n);return e==="[object RegExp]"||e==="[object Date]"||Oe(n)}var be=typeof Symbol=="function"&&Symbol.for,he=be?Symbol.for("react.element"):60103;function Oe(n){return n.$$typeof===he}function Ee(n){return Array.isArray(n)?[]:{}}function C(n,e){return e.clone!==!1&&e.isMergeableObject(n)?h(Ee(n),n,e):n}function xe(n,e,t){return n.concat(e).map(function(r){return C(r,t)})}function je(n,e){if(!e.customMerge)return h;var t=e.customMerge(n);return typeof t=="function"?t:h}function Ce(n){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(n).filter(function(e){return Object.propertyIsEnumerable.call(n,e)}):[]}function q(n){return Object.keys(n).concat(Ce(n))}function z(n,e){try{return e in n}catch{return!1}}function Pe(n,e){return z(n,e)&&!(Object.hasOwnProperty.call(n,e)&&Object.propertyIsEnumerable.call(n,e))}function De(n,e,t){var r={};return t.isMergeableObject(n)&&q(n).forEach(function(s){r[s]=C(n[s],t)}),q(e).forEach(function(s){Pe(n,s)||(z(n,s)&&t.isMergeableObject(e[s])?r[s]=je(s,t)(n[s],e[s],t):r[s]=C(e[s],t))}),r}function h(n,e,t){t=t||{},t.arrayMerge=t.arrayMerge||xe,t.isMergeableObject=t.isMergeableObject||ye,t.cloneUnlessOtherwiseSpecified=C;var r=Array.isArray(e),s=Array.isArray(n),o=r===s;return o?r?t.arrayMerge(n,e,t):De(n,e,t):C(e,t)}h.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(r,s){return h(r,s,t)},{})};var ve=h;H.exports=ve});import l from"#ansi-styles";import ce from"#supports-color";function K(n,e,t){let r=n.indexOf(e);if(r===-1)return n;let s=e.length,o=0,c="";do c+=n.slice(o,r)+e+t,o=r+s,r=n.indexOf(e,o);while(r!==-1);return c+=n.slice(o),c}function W(n,e,t,r){let s=0,o="";do{let c=n[r-1]==="\r";o+=n.slice(s,c?r-1:r)+e+(c?`\r
1
+ var _=Object.create;var F=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var ke=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var se=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var oe=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ne(e))!re.call(n,s)&&s!==t&&F(n,s,{get:()=>e[s],enumerable:!(r=ee(e,s))||r.enumerable});return n};var ie=(n,e,t)=>(t=n!=null?_(te(n)):{},oe(e||!n||!n.__esModule?F(t,"default",{value:n,enumerable:!0}):t,n));var L=se(($e,H)=>{"use strict";var ye=function(e){return ge(e)&&!me(e)};function ge(n){return!!n&&typeof n=="object"}function me(n){var e=Object.prototype.toString.call(n);return e==="[object RegExp]"||e==="[object Date]"||Oe(n)}var be=typeof Symbol=="function"&&Symbol.for,he=be?Symbol.for("react.element"):60103;function Oe(n){return n.$$typeof===he}function Ee(n){return Array.isArray(n)?[]:{}}function C(n,e){return e.clone!==!1&&e.isMergeableObject(n)?h(Ee(n),n,e):n}function xe(n,e,t){return n.concat(e).map(function(r){return C(r,t)})}function je(n,e){if(!e.customMerge)return h;var t=e.customMerge(n);return typeof t=="function"?t:h}function Ce(n){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(n).filter(function(e){return Object.propertyIsEnumerable.call(n,e)}):[]}function q(n){return Object.keys(n).concat(Ce(n))}function z(n,e){try{return e in n}catch{return!1}}function Pe(n,e){return z(n,e)&&!(Object.hasOwnProperty.call(n,e)&&Object.propertyIsEnumerable.call(n,e))}function De(n,e,t){var r={};return t.isMergeableObject(n)&&q(n).forEach(function(s){r[s]=C(n[s],t)}),q(e).forEach(function(s){Pe(n,s)||(z(n,s)&&t.isMergeableObject(e[s])?r[s]=je(s,t)(n[s],e[s],t):r[s]=C(e[s],t))}),r}function h(n,e,t){t=t||{},t.arrayMerge=t.arrayMerge||xe,t.isMergeableObject=t.isMergeableObject||ye,t.cloneUnlessOtherwiseSpecified=C;var r=Array.isArray(e),s=Array.isArray(n),o=r===s;return o?r?t.arrayMerge(n,e,t):De(n,e,t):C(e,t)}h.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(r,s){return h(r,s,t)},{})};var ve=h;H.exports=ve});import l from"#ansi-styles";import ce from"#supports-color";function K(n,e,t){let r=n.indexOf(e);if(r===-1)return n;let s=e.length,o=0,c="";do c+=n.slice(o,r)+e+t,o=r+s,r=n.indexOf(e,o);while(r!==-1);return c+=n.slice(o),c}function W(n,e,t,r){let s=0,o="";do{let c=n[r-1]==="\r";o+=n.slice(s,c?r-1:r)+e+(c?`\r
2
2
  `:`
3
3
  `)+t,s=r+1,r=n.indexOf(`
4
4
  `,s)}while(r!==-1);return o+=n.slice(s),o}var{stdout:Y,stderr:G}=ce,k=Symbol("GENERATOR"),m=Symbol("STYLER"),x=Symbol("IS_EMPTY"),V=["ansi","ansi","ansi256","ansi16m"],b=Object.create(null),ae=(n,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=Y?Y.level:0;n.level=e.level===void 0?t:e.level};var le=n=>{let e=(...t)=>t.join(" ");return ae(e,n),Object.setPrototypeOf(e,j.prototype),e};function j(n){return le(n)}Object.setPrototypeOf(j.prototype,Function.prototype);for(let[n,e]of Object.entries(l))b[n]={get(){let t=v(this,T(e.open,e.close,this[m]),this[x]);return Object.defineProperty(this,n,{value:t}),t}};b.visible={get(){let n=v(this,this[m],!0);return Object.defineProperty(this,"visible",{value:n}),n}};var I=(n,e,t,...r)=>n==="rgb"?e==="ansi16m"?l[t].ansi16m(...r):e==="ansi256"?l[t].ansi256(l.rgbToAnsi256(...r)):l[t].ansi(l.rgbToAnsi(...r)):n==="hex"?I("rgb",e,t,...l.hexToRgb(...r)):l[t][n](...r),de=["rgb","hex","ansi256"];for(let n of de){b[n]={get(){let{level:t}=this;return function(...r){let s=T(I(n,V[t],"color",...r),l.color.close,this[m]);return v(this,s,this[x])}}};let e="bg"+n[0].toUpperCase()+n.slice(1);b[e]={get(){let{level:t}=this;return function(...r){let s=T(I(n,V[t],"bgColor",...r),l.bgColor.close,this[m]);return v(this,s,this[x])}}}}var fe=Object.defineProperties(()=>{},{...b,level:{enumerable:!0,get(){return this[k].level},set(n){this[k].level=n}}}),T=(n,e,t)=>{let r,s;return t===void 0?(r=n,s=e):(r=t.openAll+n,s=e+t.closeAll),{open:n,close:e,openAll:r,closeAll:s,parent:t}},v=(n,e,t)=>{let r=(...s)=>ue(r,s.length===1?""+s[0]:s.join(" "));return Object.setPrototypeOf(r,fe),r[k]=n,r[m]=e,r[x]=t,r},ue=(n,e)=>{if(n.level<=0||!e)return n[x]?"":e;let t=n[m];if(t===void 0)return e;let{openAll:r,closeAll:s}=t;if(e.includes("\x1B"))for(;t!==void 0;)e=K(e,t.close,t.open),t=t.parent;let o=e.indexOf(`
5
- `);return o!==-1&&(e=W(e,s,r,o)),r+e+s};Object.defineProperties(j.prototype,b);var pe=j(),Me=j({level:G?G.level:0});var d=pe;var M=ie(L());import u from"node:fs";import S from"node:path";var R="tochibuild",P=d.cyan(R),f=class{};f.custom=(e,...t)=>{console[e](P,...t)},f.log=(...e)=>{console.log(P,...e)},f.debug=(...e)=>{console.debug(P,...e)},f.info=(...e)=>{console.info(P,...e)},f.warn=(...e)=>{console.warn(P,...[...e].map(t=>d.yellow(t)))},f.error=(e,...t)=>{console.error(d.red(R),d.bgRed(...t),e?.stack?`
6
- ${d.gray(e.stack)}`:"")},f.success=(...e)=>{console.log(d.green(R),...e)};var y=f;var i=class i{};i.defaultConfigOptions={tsconfig:"tsconfig.json",dts:!0,format:["esm"],minify:!0},i.ignoredEntries=["!build/**","!dist/**","!node_modules/**","!**/build/**","!**/dist/**","!**/node_modules/**","!**/*.d.ts","!**/{tochibuild,tsup}.*"],i.entriesCommon=["**/*.{js,ts}"],i.entriesIndex=["**/index.{js,ts}"],i.defaultEntriesIndex=[...i.ignoredEntries,...i.entriesIndex],i.defaultEntriesCommon=[...i.ignoredEntries,...i.entriesCommon],i.defaultOptions=(e,t)=>w(e,r=>{let s=A(r.entry,t?.excludeIgnoredEntries?[]:["ignoredEntries"]);return{...i.defaultConfigOptions,...r,noExternal:[...r.noExternal||[],...i.getPackageJsonDepsEntriesFromConfig(t)],entry:s}}),i.defaultOptionsWithIndexEntries=(e,t)=>w(e,r=>{let s=t?.excludeIgnoredEntries?["entriesIndex"]:["ignoredEntries","entriesIndex"],o=A(r.entry,s);return{...i.defaultConfigOptions,...r,noExternal:[...r.noExternal||[],...i.getPackageJsonDepsEntriesFromConfig(t)],entry:o}}),i.defaultOptionsWithCommonEntries=(e,t)=>w(e,r=>{let s=t?.excludeIgnoredEntries?["entriesCommon"]:["ignoredEntries","entriesCommon"],o=A(r.entry,s);return{...i.defaultConfigOptions,...r,noExternal:[...r.noExternal||[],...i.getPackageJsonDepsEntriesFromConfig(t)],entry:o}}),i.generateConfig=Ae,i.ensureEntries=A,i.getPackageJson=(e,t)=>{let r,s;try{return r=S.join(Q(e),"package.json"),u.existsSync(r)&&(s=JSON.parse(u.readFileSync(r,"utf-8"))),{filePath:r,data:s}}catch(o){if(t)throw o;return{filePath:r,data:s}}},i.getPackageJsonDepsEntriesFromConfig=(e,t)=>{let r=e?.includePackageJsonDeps??!0,s=e?.includePackageJsonDevDeps??!1,o=e?.includePackageJsonPeerDeps??!1,c=[];return r&&c.push("dependencies"),s&&c.push("devDependencies"),o&&c.push("peerDependencies"),i.getPackageJsonDepsEntries(t??i.getPackageJson().filePath,c)},i.getPackageJsonDepsEntries=(e,t=["dependencies","devDependencies","peerDependencies"])=>i.getPackageJsonDeps(e).toArray(t),i.getPackageJsonDeps=e=>{let t={},r={},s={},o={dependencies:t,devDependencies:r,peerDependencies:s,toArray:(c=["dependencies","devDependencies","peerDependencies"])=>[]};try{if(!e)return o;if(!u.existsSync(e))return y.error(void 0,`could not find package.json at ${e}`),o;let c=u.readFileSync(e,"utf-8"),a=JSON.parse(c),O={dependencies:a.dependencies||{},devDependencies:a.devDependencies||{},peerDependencies:a.peerDependencies||{}};return{...O,toArray:(p=["dependencies","devDependencies","peerDependencies"])=>p.flatMap(E=>Object.keys(O[E]))}}catch(c){y.error(c,`could not read package.json at ${e}`);let a={dependencies:t||{},devDependencies:r||{},peerDependencies:s||{}};return{...a,toArray:(O=["dependencies","devDependencies","peerDependencies"])=>O.flatMap(p=>Object.keys(a[p]))}}};var D=i,qe=D;function w(n,e){let t=s=>Array.isArray(s)?s.map(o=>(0,M.default)(e(o),s)):(0,M.default)(e(s),s);if(typeof n=="function"){let s=n;async function o(c){let a=await s(c);return t(a)}return o}return t(n)}function A(n,e){if(Array.isArray(n)){let t=[],r=[];return e.forEach(s=>r.push(...D[s])),t.push(...Array.from(new Set([...r,...n]))),t}return n}function Q(n){let e=S.resolve(process.cwd(),n||".");return n&&S.isAbsolute(n||".")?n:e}function Ae(n,e,t,r){let s="";try{let o=e?.ext||".ts",a=`${e?.filename||"tochibuild.config"}${o}`;(e?.outDir?.length?e.outDir:["."]).forEach(p=>{s=Q(p),u.existsSync(p)||u.mkdirSync(p,{recursive:!0});let E=S.join(s,a),X=u.existsSync(E);!e?.overwrite&&X&&(y.warn(`the config '${a}' file already exists for this project.`),r&&process.exit(1));let Z=" ",g="",N={clean:!1,splitting:!0},J=$=>{g+=$==="esm"?`import build from '${n}';
5
+ `);return o!==-1&&(e=W(e,s,r,o)),r+e+s};Object.defineProperties(j.prototype,b);var pe=j(),Ne=j({level:G?G.level:0});var d=pe;var M=ie(L());import u from"node:fs";import S from"node:path";var R="tochibuild",P=d.cyan(R),f=class{};f.custom=(e,...t)=>{console[e](P,...t)},f.log=(...e)=>{console.log(P,...e)},f.debug=(...e)=>{console.debug(P,...e)},f.info=(...e)=>{console.info(P,...e)},f.warn=(...e)=>{console.warn(P,...[...e].map(t=>d.yellow(t)))},f.error=(e,...t)=>{console.error(d.red(R),d.bgRed(...t),e?.stack?`
6
+ ${d.gray(e.stack)}`:"")},f.success=(...e)=>{console.log(d.green(R),...e)};var y=f;var Ae=(n,e)=>{let t=[];return t.push((e?.prefix??"")+n+(e?.suffix??"")),t.push((e?.prefix??"")+`**/${n}`+(e?.suffix??"")),t},i=class i{};i.defaultConfigOptions={tsconfig:"tsconfig.json",dts:!0,format:["esm"],minify:!0},i.ignoredEntries=[...["*.d.ts","{tochibuild,tsup}.*","build/**","dist/**","node_modules/**"].flatMap(e=>Ae(e,{prefix:"!"}))].sort().reverse(),i.entriesCommon=["*.{js,ts}","**/*.{js,ts}"],i.entriesIndex=["index.{js,ts}","**/index.{js,ts}"],i.defaultEntriesIndex=[...i.ignoredEntries,...i.entriesIndex],i.defaultEntriesCommon=[...i.ignoredEntries,...i.entriesCommon],i.defaultOptions=(e,t)=>w(e,r=>{let s=A(r.entry,t?.excludeIgnoredEntries?[]:["ignoredEntries"]);return{...i.defaultConfigOptions,...r,noExternal:[...r.noExternal||[],...i.getPackageJsonDepsEntriesFromConfig(t)],entry:s}}),i.defaultOptionsWithIndexEntries=(e,t)=>w(e,r=>{let s=t?.excludeIgnoredEntries?["entriesIndex"]:["ignoredEntries","entriesIndex"],o=A(r.entry,s);return{...i.defaultConfigOptions,...r,noExternal:[...r.noExternal||[],...i.getPackageJsonDepsEntriesFromConfig(t)],entry:o}}),i.defaultOptionsWithCommonEntries=(e,t)=>w(e,r=>{let s=t?.excludeIgnoredEntries?["entriesCommon"]:["ignoredEntries","entriesCommon"],o=A(r.entry,s);return{...i.defaultConfigOptions,...r,noExternal:[...r.noExternal||[],...i.getPackageJsonDepsEntriesFromConfig(t)],entry:o}}),i.generateConfig=Se,i.ensureEntries=A,i.getPackageJson=(e,t)=>{let r,s;try{return r=S.join(Q(e),"package.json"),u.existsSync(r)&&(s=JSON.parse(u.readFileSync(r,"utf-8"))),{filePath:r,data:s}}catch(o){if(t)throw o;return{filePath:r,data:s}}},i.getPackageJsonDepsEntriesFromConfig=(e,t)=>{let r=e?.includePackageJsonDeps??!0,s=e?.includePackageJsonDevDeps??!1,o=e?.includePackageJsonPeerDeps??!1,c=[];return r&&c.push("dependencies"),s&&c.push("devDependencies"),o&&c.push("peerDependencies"),i.getPackageJsonDepsEntries(t??i.getPackageJson().filePath,c)},i.getPackageJsonDepsEntries=(e,t=["dependencies","devDependencies","peerDependencies"])=>i.getPackageJsonDeps(e).toArray(t),i.getPackageJsonDeps=e=>{let t={},r={},s={},o={dependencies:t,devDependencies:r,peerDependencies:s,toArray:(c=["dependencies","devDependencies","peerDependencies"])=>[]};try{if(!e)return o;if(!u.existsSync(e))return y.error(void 0,`could not find package.json at ${e}`),o;let c=u.readFileSync(e,"utf-8"),a=JSON.parse(c),O={dependencies:a.dependencies||{},devDependencies:a.devDependencies||{},peerDependencies:a.peerDependencies||{}};return{...O,toArray:(p=["dependencies","devDependencies","peerDependencies"])=>p.flatMap(E=>Object.keys(O[E]))}}catch(c){y.error(c,`could not read package.json at ${e}`);let a={dependencies:t||{},devDependencies:r||{},peerDependencies:s||{}};return{...a,toArray:(O=["dependencies","devDependencies","peerDependencies"])=>O.flatMap(p=>Object.keys(a[p]))}}};var D=i,ze=D;function w(n,e){let t=s=>Array.isArray(s)?s.map(o=>(0,M.default)(e(o),s)):(0,M.default)(e(s),s);if(typeof n=="function"){let s=n;async function o(c){let a=await s(c);return t(a)}return o}return t(n)}function A(n,e){if(Array.isArray(n)){let t=[],r=[];return e.forEach(s=>r.push(...D[s])),t.push(...Array.from(new Set([...r,...n]))),t}return n}function Q(n){let e=S.resolve(process.cwd(),n||".");return n&&S.isAbsolute(n||".")?n:e}function Se(n,e,t,r){let s="";try{let o=e?.ext||".ts",a=`${e?.filename||"tochibuild.config"}${o}`;(e?.outDir?.length?e.outDir:["."]).forEach(p=>{s=Q(p),u.existsSync(p)||u.mkdirSync(p,{recursive:!0});let E=S.join(s,a),X=u.existsSync(E);!e?.overwrite&&X&&(y.warn(`the config '${a}' file already exists for this project.`),r&&process.exit(1));let Z=" ",g="",N={clean:!1,splitting:!0},J=$=>{g+=$==="esm"?`import build from '${n}';
7
7
 
8
8
  `:`const build = require('${n}');
9
9
 
@@ -12,4 +12,4 @@ ${d.gray(e.stack)}`:"")},f.success=(...e)=>{console.log(d.green(R),...e)};var y=
12
12
  `,Object.entries(N).forEach(([B,U])=>{g+=`${Z}${B}: ${JSON.stringify(U)},
13
13
  `}),g+=`});
14
14
  `};switch(o){case".ts":case".js":J("esm");break;case".cjs":J("cjs");break;case".json":g+=`${JSON.stringify({...N,entry:D.defaultEntriesIndex},null,2)}
15
- `;break;default:y.error(void 0,`unsupported extension: ${o}`),process.exit(1)}u.writeFileSync(E,g),y.success(d.cyan("the config file has been created at:"),d.gray(E))})}catch(o){if(t)throw o;y.error(o,o.message?`failed to generate config file in ${s}: ${o.message}`:`failed to generate config file in ${s}`),r&&process.exit(1)}}export{Se as a,se as b,ie as c,d,y as e,D as f,qe as g};
15
+ `;break;default:y.error(void 0,`unsupported extension: ${o}`),process.exit(1)}u.writeFileSync(E,g),y.success(d.cyan("the config file has been created at:"),d.gray(E))})}catch(o){if(t)throw o;y.error(o,o.message?`failed to generate config file in ${s}: ${o.message}`:`failed to generate config file in ${s}`),r&&process.exit(1)}}export{ke as a,se as b,ie as c,d,y as e,D as f,ze as g};
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{a as E,b as y,c as xt,d as C,e as x,g as F}from"./chunk-GKH6M3ZR.mjs";var v=y(I=>{"use strict";var S=class extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}},j=class extends S{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};I.CommanderError=S;I.InvalidArgumentError=j});var V=y(q=>{"use strict";var{InvalidArgumentError:wt}=v(),N=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,e){return e===this.defaultValue||!Array.isArray(e)?[t]:e.concat(t)}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(e,i)=>{if(!this.argChoices.includes(e))throw new wt(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,i):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Et(u){let t=u.name()+(u.variadic===!0?"...":"");return u.required?"<"+t+">":"["+t+"]"}q.Argument=N;q.humanReadableArgName=Et});var L=y(R=>{"use strict";var{humanReadableArgName:vt}=V(),M=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let e=t.commands.filter(s=>!s._hidden),i=t._getHelpCommand();return i&&!i._hidden&&e.push(i),this.sortSubcommands&&e.sort((s,n)=>s.name().localeCompare(n.name())),e}compareOptions(t,e){let i=s=>s.short?s.short.replace(/^-/,""):s.long.replace(/^--/,"");return i(t).localeCompare(i(e))}visibleOptions(t){let e=t.options.filter(s=>!s.hidden),i=t._getHelpOption();if(i&&!i.hidden){let s=i.short&&t._findOption(i.short),n=i.long&&t._findOption(i.long);!s&&!n?e.push(i):i.long&&!n?e.push(t.createOption(i.long,i.description)):i.short&&!s&&e.push(t.createOption(i.short,i.description))}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let e=[];for(let i=t.parent;i;i=i.parent){let s=i.options.filter(n=>!n.hidden);e.push(...s)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(e=>e.description)?t.registeredArguments:[]}subcommandTerm(t){let e=t.registeredArguments.map(i=>vt(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleSubcommandTerm(e.subcommandTerm(s)))),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleOptionTerm(e.optionTerm(s)))),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleOptionTerm(e.optionTerm(s)))),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleArgumentTerm(e.argumentTerm(s)))),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let s=t.parent;s;s=s.parent)i=s.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let e=[];return t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&e.push(`env: ${t.envVar}`),e.length>0?`${t.description} (${e.join(", ")})`:t.description}argumentDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){let i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatHelp(t,e){let i=e.padWidth(t,e),s=e.helpWidth??80;function n(c,p){return e.formatItem(c,i,p,e)}let r=[`${e.styleTitle("Usage:")} ${e.styleUsage(e.commandUsage(t))}`,""],a=e.commandDescription(t);a.length>0&&(r=r.concat([e.boxWrap(e.styleCommandDescription(a),s),""]));let o=e.visibleArguments(t).map(c=>n(e.styleArgumentTerm(e.argumentTerm(c)),e.styleArgumentDescription(e.argumentDescription(c))));o.length>0&&(r=r.concat([e.styleTitle("Arguments:"),...o,""]));let h=e.visibleOptions(t).map(c=>n(e.styleOptionTerm(e.optionTerm(c)),e.styleOptionDescription(e.optionDescription(c))));if(h.length>0&&(r=r.concat([e.styleTitle("Options:"),...h,""])),e.showGlobalOptions){let c=e.visibleGlobalOptions(t).map(p=>n(e.styleOptionTerm(e.optionTerm(p)),e.styleOptionDescription(e.optionDescription(p))));c.length>0&&(r=r.concat([e.styleTitle("Global Options:"),...c,""]))}let l=e.visibleCommands(t).map(c=>n(e.styleSubcommandTerm(e.subcommandTerm(c)),e.styleSubcommandDescription(e.subcommandDescription(c))));return l.length>0&&(r=r.concat([e.styleTitle("Commands:"),...l,""])),r.join(`
2
+ import{a as E,b as y,c as xt,d as C,e as x,g as F}from"./chunk-4IB5MIMZ.mjs";var v=y(I=>{"use strict";var S=class extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}},j=class extends S{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};I.CommanderError=S;I.InvalidArgumentError=j});var V=y(q=>{"use strict";var{InvalidArgumentError:wt}=v(),N=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,e){return e===this.defaultValue||!Array.isArray(e)?[t]:e.concat(t)}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(e,i)=>{if(!this.argChoices.includes(e))throw new wt(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,i):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Et(u){let t=u.name()+(u.variadic===!0?"...":"");return u.required?"<"+t+">":"["+t+"]"}q.Argument=N;q.humanReadableArgName=Et});var L=y(R=>{"use strict";var{humanReadableArgName:vt}=V(),M=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let e=t.commands.filter(s=>!s._hidden),i=t._getHelpCommand();return i&&!i._hidden&&e.push(i),this.sortSubcommands&&e.sort((s,n)=>s.name().localeCompare(n.name())),e}compareOptions(t,e){let i=s=>s.short?s.short.replace(/^-/,""):s.long.replace(/^--/,"");return i(t).localeCompare(i(e))}visibleOptions(t){let e=t.options.filter(s=>!s.hidden),i=t._getHelpOption();if(i&&!i.hidden){let s=i.short&&t._findOption(i.short),n=i.long&&t._findOption(i.long);!s&&!n?e.push(i):i.long&&!n?e.push(t.createOption(i.long,i.description)):i.short&&!s&&e.push(t.createOption(i.short,i.description))}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let e=[];for(let i=t.parent;i;i=i.parent){let s=i.options.filter(n=>!n.hidden);e.push(...s)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(e=>e.description)?t.registeredArguments:[]}subcommandTerm(t){let e=t.registeredArguments.map(i=>vt(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleSubcommandTerm(e.subcommandTerm(s)))),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleOptionTerm(e.optionTerm(s)))),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleOptionTerm(e.optionTerm(s)))),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleArgumentTerm(e.argumentTerm(s)))),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let s=t.parent;s;s=s.parent)i=s.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let e=[];return t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&e.push(`env: ${t.envVar}`),e.length>0?`${t.description} (${e.join(", ")})`:t.description}argumentDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){let i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatHelp(t,e){let i=e.padWidth(t,e),s=e.helpWidth??80;function n(c,p){return e.formatItem(c,i,p,e)}let r=[`${e.styleTitle("Usage:")} ${e.styleUsage(e.commandUsage(t))}`,""],a=e.commandDescription(t);a.length>0&&(r=r.concat([e.boxWrap(e.styleCommandDescription(a),s),""]));let o=e.visibleArguments(t).map(c=>n(e.styleArgumentTerm(e.argumentTerm(c)),e.styleArgumentDescription(e.argumentDescription(c))));o.length>0&&(r=r.concat([e.styleTitle("Arguments:"),...o,""]));let h=e.visibleOptions(t).map(c=>n(e.styleOptionTerm(e.optionTerm(c)),e.styleOptionDescription(e.optionDescription(c))));if(h.length>0&&(r=r.concat([e.styleTitle("Options:"),...h,""])),e.showGlobalOptions){let c=e.visibleGlobalOptions(t).map(p=>n(e.styleOptionTerm(e.optionTerm(p)),e.styleOptionDescription(e.optionDescription(p))));c.length>0&&(r=r.concat([e.styleTitle("Global Options:"),...c,""]))}let l=e.visibleCommands(t).map(c=>n(e.styleSubcommandTerm(e.subcommandTerm(c)),e.styleSubcommandDescription(e.subcommandDescription(c))));return l.length>0&&(r=r.concat([e.styleTitle("Commands:"),...l,""])),r.join(`
3
3
  `)}displayWidth(t){return it(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(e=>e==="[options]"?this.styleOptionText(e):e==="[command]"?this.styleSubcommandText(e):e[0]==="["||e[0]==="<"?this.styleArgumentText(e):this.styleCommandText(e)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(e=>e==="[options]"?this.styleOptionText(e):e[0]==="["||e[0]==="<"?this.styleArgumentText(e):this.styleSubcommandText(e)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,e,i,s){let r=" ".repeat(2);if(!i)return r+t;let a=t.padEnd(e+t.length-s.displayWidth(t)),o=2,l=(this.helpWidth??80)-e-o-2,c;return l<this.minWidthToWrap||s.preformatted(i)?c=i:c=s.boxWrap(i,l).replace(/\n/g,`
4
4
  `+" ".repeat(e+o)),r+a+" ".repeat(o)+c.replace(/\n/g,`
5
5
  ${r}`)}boxWrap(t,e){if(e<this.minWidthToWrap)return t;let i=t.split(/\r\n|\n/),s=/[\s]*[^\s]+/g,n=[];return i.forEach(r=>{let a=r.match(s);if(a===null){n.push("");return}let o=[a.shift()],h=this.displayWidth(o[0]);a.forEach(l=>{let c=this.displayWidth(l);if(h+c<=e){o.push(l),h+=c;return}n.push(o.join(""));let p=l.trimStart();o=[p],h=this.displayWidth(p)}),n.push(o.join(""))}),n.join(`
@@ -24,4 +24,4 @@ Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._life
24
24
  `),this.outputHelp({error:!0}));let i=e||{},s=i.exitCode||1,n=i.code||"commander.error";this._exit(s,n,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in d.env){let e=t.attributeName();(this.getOptionValue(e)===void 0||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,d.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new Ft(this.options),e=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&e(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(s=>!e(s)).forEach(s=>{this.setOptionValueWithSource(s,i.implied[s],"implied")})})}missingArgument(t){let e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){let e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){let i=r=>{let a=r.attributeName(),o=this.getOptionValue(a),h=this.options.find(c=>c.negate&&a===c.attributeName()),l=this.options.find(c=>!c.negate&&a===c.attributeName());return h&&(h.presetArg===void 0&&o===!1||h.presetArg!==void 0&&o===h.presetArg)?h:l||r},s=r=>{let a=i(r),o=a.attributeName();return this.getOptionValueSource(o)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},n=`error: ${s(t)} cannot be used with ${s(e)}`;this.error(n,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let s=[],n=this;do{let r=n.createHelp().visibleOptions(n).filter(a=>a.long).map(a=>a.long);s=s.concat(r),n=n.parent}while(n&&!n._enablePositionalOptions);e=at(t,s)}let i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let e=this.registeredArguments.length,i=e===1?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${i} but got ${t.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],e="";if(this._showSuggestionAfterError){let s=[];this.createHelp().visibleCommands(this).forEach(n=>{s.push(n.name()),n.alias()&&s.push(n.alias())}),e=at(t,s)}let i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(t===void 0)return this._version;this._version=t,e=e||"-V, --version",i=i||"output the version number";let s=this.createOption(e,i);return this._versionOptionName=s.attributeName(),this._registerOption(s),this.on("option:"+s.name(),()=>{this._outputConfiguration.writeOut(`${t}
25
25
  `),this._exit(0,"commander.version",t)}),this}description(t,e){return t===void 0&&e===void 0?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let e=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(t);if(i){let s=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${s}'`)}return e._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(e=>this.alias(e)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(i=>Pt(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}nameFromFilename(t){return this._name=A.basename(t,A.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let e=this.createHelp(),i=this._getOutputContext(t);e.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let s=e.formatHelp(this,e);return i.hasColors?s:this._outputConfiguration.stripColor(s)}_getOutputContext(t){t=t||{};let e=!!t.error,i,s,n;return e?(i=a=>this._outputConfiguration.writeErr(a),s=this._outputConfiguration.getErrHasColors(),n=this._outputConfiguration.getErrHelpWidth()):(i=a=>this._outputConfiguration.writeOut(a),s=this._outputConfiguration.getOutHasColors(),n=this._outputConfiguration.getOutHelpWidth()),{error:e,write:a=>(s||(a=this._outputConfiguration.stripColor(a)),i(a)),hasColors:s,helpWidth:n}}outputHelp(t){let e;typeof t=="function"&&(e=t,t=void 0);let i=this._getOutputContext(t),s={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(r=>r.emit("beforeAllHelp",s)),this.emit("beforeHelp",s);let n=this.helpInformation({error:i.error});if(e&&(n=e(n),typeof n!="string"&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",s),this._getCommandAndAncestors().forEach(r=>r.emit("afterAllHelp",s))}helpOption(t,e){return typeof t=="boolean"?(t?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(t=t??"-h, --help",e=e??"display help for command",this._helpOption=this.createOption(t,e),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this}help(t){this.outputHelp(t);let e=Number(d.exitCode??0);e===0&&t&&typeof t!="function"&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){let i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.
26
26
  Expecting one of '${i.join("', '")}'`);let s=`${t}Help`;return this.on(s,n=>{let r;typeof e=="function"?r=e({error:n.error,command:n.command}):r=e,r&&n.write(`${r}
27
- `)}),this}_outputHelpIfRequested(t){let e=this._getHelpOption();e&&t.find(s=>e.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function lt(u){return u.map(t=>{if(!t.startsWith("--inspect"))return t;let e,i="127.0.0.1",s="9229",n;return(n=t.match(/^(--inspect(-brk)?)$/))!==null?e=n[1]:(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(e=n[1],/^\d+$/.test(n[3])?s=n[3]:i=n[3]):(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(e=n[1],i=n[3],s=n[4]),e&&s!=="0"?`${e}=${i}:${parseInt(s)+1}`:t})}function Q(){if(d.env.NO_COLOR||d.env.FORCE_COLOR==="0"||d.env.FORCE_COLOR==="false")return!1;if(d.env.FORCE_COLOR||d.env.CLICOLOR_FORCE!==void 0)return!0}X.Command=z;X.useColor=Q});var pt=y(_=>{"use strict";var{Argument:ht}=V(),{Command:Z}=ut(),{CommanderError:jt,InvalidArgumentError:ct}=v(),{Help:It}=L(),{Option:dt}=J();_.program=new Z;_.createCommand=u=>new Z(u);_.createOption=(u,t)=>new dt(u,t);_.createArgument=(u,t)=>new ht(u,t);_.Command=Z;_.Option=dt;_.Argument=ht;_.Help=It;_.CommanderError=jt;_.InvalidArgumentError=ct;_.InvalidOptionArgumentError=ct});import _t from"node:fs";import w from"node:path";import{fileURLToPath as qt}from"node:url";import{spawn as Mt}from"node:child_process";var mt=xt(pt(),1),{program:Qt,createCommand:Xt,createArgument:Zt,createOption:te,CommanderError:ee,InvalidArgumentError:ie,InvalidOptionArgumentError:se,Command:ft,Argument:ne,Option:re,Help:oe}=mt.default;var gt={name:"tochibuild",version:"2.3.0",description:"An extremely fast JavaScript/Typescript and CSS bundler with minimal configuration.",repository:"https://github.com/tochiResources/project/tree/main/packages/build/tochibuild.git",license:"MIT",keywords:["bundler","build","typescript","javascript","tsup","esbuild","glob","cli","node","tochi","tochiResources"],bin:"./dist/cli.mjs",scripts:{dev:"tsx cli.ts",copybundler:"copyfiles ./tsup@8.4.0-minified/* ./dist",build:"tsx cli.ts && bun run copybundler","build:release":"bun run build && bun run release",release:"bun publish --access public --no-private"},dependencies:{chalk:"^5.4.1",commander:"^13.1.0",deepmerge:"^4.3.1",tsup:"8.4.0"},devDependencies:{"@types/node":"^22.15.17",copyfiles:"^2.4.1",tsx:"^4.19.4",typescript:"^5.8.3"},main:"dist/index.mjs",types:"dist/index.d.mts",exports:{".":{types:"./dist/index.d.mts",require:"./dist/index.mjs",import:"./dist/index.mjs"},"./utils":{types:"./dist/utils.d.mts",import:"./dist/utils.mjs",require:"./dist/utils.mjs"}},engines:{node:">=18.17.0"},files:["dist"]};var Rt=qt(import.meta.url),Lt=w.dirname(Rt),Ct=w.resolve(process.cwd(),"."),Ot=Ct.replace(/\\/g,"/").includes("packages/build");async function bt(u){let t={node:w.join(Lt,"tsup@8.4.0-minified/cli-node.js")},e=process.cwd(),i=[...[".ts",".js",".cjs",".json"].map(p=>w.join(e,`tochibuild.config${p}`)),...[".ts",".js",".cjs",".json"].map(p=>w.join(e,`tsup.config${p}`))],s=F.getPackageJson(),n=s.data?.tochibuild,r=s.data?.tsup,a=!!Object.keys(n||{}).length||!!Object.keys(r||{}).length,o=i.find(p=>_t.existsSync(p)),h=a||o,l=new ft("tochibuild").name("tochibuild <command>").description("bundle a Node.js project powered by tsup (https://tsup.egoist.dev)").allowUnknownOption(!0).version(gt.version).argument("[args...]","arguments to pass to tsup").action(async(...p)=>c(p));l.command("config").description("generate config files").option("--ext <string>","the file extension to use excluding the file extension (defaults to .ts)",".ts").option("-f, --filename <string>","the file name to use (defaults to tochibuild.config)","tochibuild.config").option("-o, --overwrite","whether or not to overwrite the config file if it already exists (defaults to false)",!1).option("--outDir <string...>","the absolute/relative output directory paths to create the config files in (defaults to the working directory)").action(p=>F.generateConfig(u,p,!1,!0)),l.parseAsync(process.argv);async function c(p){let[m]=p;return new Promise((H,$)=>{try{let T="node",f=[],P=m.includes("--config"),tt=m.includes("--no-config"),W=P?m.findIndex(g=>g==="--config")+1:void 0;if(!P&&!tt&&!h){if(m[0]==null||m[0]?.startsWith("-")){x.custom("error",`${C.red("No input files, try")} '${C.magenta(u)} ${C.gray("[...files]")}' ${C.red("instead")}`),$();return}f.push(...m)}else if(!P&&!tt&&h)if(a){let g=n||r;m.filter(O=>O.startsWith("-")).forEach(O=>{let b=m.findIndex(yt=>yt===O),At=O.startsWith("--")?O.slice(2):O.slice(1);if(g[At]||(f.push(O),f[b+1]?.startsWith("-")))return;let et=f[b+1];et&&f.push(et)}),Object.entries(g).forEach(([O,b])=>{typeof b=="boolean"||b==="true"||b==="false"?b&&f.push(`--${O}`):typeof b=="string"&&f.push(`--${O}`,b)}),f.push("--no-config")}else if(o){let g=w.relative(Ct,o).replace(/\\/g,"/");x.log(`using existing configuration file: ${C.gray(g)}`),f.push("--config",g),f.push(...m)}else f.push(...m);else{if(W!=null&&W>=0){let g=m[W]||"unspecified";_t.existsSync(g)||(x.error(void 0,`config file '${g}' does not exist`),x.info(`try running '${C.magenta(u)} ${C.blue("config")} ${C.gray("-h")}' to get help on how to generate a config file`),process.exit(1))}f.push(...m)}x.log(`running build${Ot||s.data?.name?` for ${C.magenta(Ot?u:s.data.name)}`:""}...`);let D=Mt("node",[t[T],...f],{stdio:"inherit",shell:!0,cwd:process.cwd(),env:process.env});D.on("exit",g=>{process.exit(g??1)}),process.on("SIGINT",()=>{$(),D.kill("SIGINT")}),process.on("SIGTERM",()=>{$(),D.kill("SIGTERM")}),H()}catch(T){$(T)}})}}bt("@tochii/build");
27
+ `)}),this}_outputHelpIfRequested(t){let e=this._getHelpOption();e&&t.find(s=>e.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function lt(u){return u.map(t=>{if(!t.startsWith("--inspect"))return t;let e,i="127.0.0.1",s="9229",n;return(n=t.match(/^(--inspect(-brk)?)$/))!==null?e=n[1]:(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(e=n[1],/^\d+$/.test(n[3])?s=n[3]:i=n[3]):(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(e=n[1],i=n[3],s=n[4]),e&&s!=="0"?`${e}=${i}:${parseInt(s)+1}`:t})}function Q(){if(d.env.NO_COLOR||d.env.FORCE_COLOR==="0"||d.env.FORCE_COLOR==="false")return!1;if(d.env.FORCE_COLOR||d.env.CLICOLOR_FORCE!==void 0)return!0}X.Command=z;X.useColor=Q});var pt=y(_=>{"use strict";var{Argument:ht}=V(),{Command:Z}=ut(),{CommanderError:jt,InvalidArgumentError:ct}=v(),{Help:It}=L(),{Option:dt}=J();_.program=new Z;_.createCommand=u=>new Z(u);_.createOption=(u,t)=>new dt(u,t);_.createArgument=(u,t)=>new ht(u,t);_.Command=Z;_.Option=dt;_.Argument=ht;_.Help=It;_.CommanderError=jt;_.InvalidArgumentError=ct;_.InvalidOptionArgumentError=ct});import _t from"node:fs";import w from"node:path";import{fileURLToPath as qt}from"node:url";import{spawn as Mt}from"node:child_process";var mt=xt(pt(),1),{program:Qt,createCommand:Xt,createArgument:Zt,createOption:te,CommanderError:ee,InvalidArgumentError:ie,InvalidOptionArgumentError:se,Command:ft,Argument:ne,Option:re,Help:oe}=mt.default;var gt={name:"tochibuild",version:"2.5.0",description:"An extremely fast JavaScript/Typescript and CSS bundler with minimal configuration.",repository:"https://github.com/tochiResources/project/tree/main/packages/build/tochibuild.git",license:"MIT",keywords:["bundler","build","typescript","javascript","tsup","esbuild","glob","cli","node","tochi","tochiResources"],bin:"./dist/cli.mjs",scripts:{dev:"tsx cli.ts",copybundler:"copyfiles ./tsup@8.4.0-minified/* ./dist",build:"tsx cli.ts && bun run copybundler","build:release":"bun run build && bun run release",release:"bun publish --access public --no-private"},dependencies:{chalk:"^5.4.1",commander:"^13.1.0",deepmerge:"^4.3.1",tsup:"8.4.0"},devDependencies:{"@types/node":"^22.15.17",copyfiles:"^2.4.1",tsx:"^4.19.4",typescript:"^5.8.3"},main:"dist/index.mjs",types:"dist/index.d.mts",exports:{".":{types:"./dist/index.d.mts",require:"./dist/index.mjs",import:"./dist/index.mjs"},"./utils":{types:"./dist/utils.d.mts",import:"./dist/utils.mjs",require:"./dist/utils.mjs"}},engines:{node:">=18.17.0"},files:["dist"]};var Rt=qt(import.meta.url),Lt=w.dirname(Rt),Ct=w.resolve(process.cwd(),"."),Ot=Ct.replace(/\\/g,"/").includes("packages/build");async function bt(u){let t={node:w.join(Lt,"tsup@8.4.0-minified/cli-node.js")},e=process.cwd(),i=[...[".ts",".js",".cjs",".json"].map(p=>w.join(e,`tochibuild.config${p}`)),...[".ts",".js",".cjs",".json"].map(p=>w.join(e,`tsup.config${p}`))],s=F.getPackageJson(),n=s.data?.tochibuild,r=s.data?.tsup,a=!!Object.keys(n||{}).length||!!Object.keys(r||{}).length,o=i.find(p=>_t.existsSync(p)),h=a||o,l=new ft("tochibuild").name("tochibuild <command>").description("bundle a Node.js project powered by tsup (https://tsup.egoist.dev)").allowUnknownOption(!0).version(gt.version).argument("[args...]","arguments to pass to tsup").action(async(...p)=>c(p));l.command("config").description("generate config files").option("--ext <string>","the file extension to use excluding the file extension (defaults to .ts)",".ts").option("-f, --filename <string>","the file name to use (defaults to tochibuild.config)","tochibuild.config").option("-o, --overwrite","whether or not to overwrite the config file if it already exists (defaults to false)",!1).option("--outDir <string...>","the absolute/relative output directory paths to create the config files in (defaults to the working directory)").action(p=>F.generateConfig(u,p,!1,!0)),l.parseAsync(process.argv);async function c(p){let[m]=p;return new Promise((H,$)=>{try{let T="node",f=[],P=m.includes("--config"),tt=m.includes("--no-config"),W=P?m.findIndex(g=>g==="--config")+1:void 0;if(!P&&!tt&&!h){if(m[0]==null||m[0]?.startsWith("-")){x.custom("error",`${C.red("No input files, try")} '${C.magenta(u)} ${C.gray("[...files]")}' ${C.red("instead")}`),$();return}f.push(...m)}else if(!P&&!tt&&h)if(a){let g=n||r;m.filter(O=>O.startsWith("-")).forEach(O=>{let b=m.findIndex(yt=>yt===O),At=O.startsWith("--")?O.slice(2):O.slice(1);if(g[At]||(f.push(O),f[b+1]?.startsWith("-")))return;let et=f[b+1];et&&f.push(et)}),Object.entries(g).forEach(([O,b])=>{typeof b=="boolean"||b==="true"||b==="false"?b&&f.push(`--${O}`):typeof b=="string"&&f.push(`--${O}`,b)}),f.push("--no-config")}else if(o){let g=w.relative(Ct,o).replace(/\\/g,"/");x.log(`using existing configuration file: ${C.gray(g)}`),f.push("--config",g),f.push(...m)}else f.push(...m);else{if(W!=null&&W>=0){let g=m[W]||"unspecified";_t.existsSync(g)||(x.error(void 0,`config file '${g}' does not exist`),x.info(`try running '${C.magenta(u)} ${C.blue("config")} ${C.gray("-h")}' to get help on how to generate a config file`),process.exit(1))}f.push(...m)}x.log(`running build${Ot||s.data?.name?` for ${C.magenta(Ot?u:s.data.name)}`:""}...`);let D=Mt("node",[t[T],...f],{stdio:"inherit",shell:!0,cwd:process.cwd(),env:process.env});D.on("exit",g=>{process.exit(g??1)}),process.on("SIGINT",()=>{$(),D.kill("SIGINT")}),process.on("SIGTERM",()=>{$(),D.kill("SIGTERM")}),H()}catch(T){$(T)}})}}bt("@tochii/build");
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{a as m,b as L,c as Ie,g as q}from"./chunk-GKH6M3ZR.mjs";var me=L(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});var Be="8.4.0";V.version=Be});var se=L(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});function Q(e){return e&&e.__esModule?e:{default:e}}function X(e){let t,r=e[0],n=1;for(;n<e.length;){let s=e[n],i=e[n+1];if(n+=2,(s==="optionalAccess"||s==="optionalCall")&&r==null)return;s==="access"||s==="optionalAccess"?(t=r,r=i(r)):(s==="call"||s==="optionalCall")&&(r=i((...o)=>r.call(t,...o)),t=void 0)}return r}var We=Object.create,ge=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,ye=Object.getOwnPropertyNames,ze=Object.getPrototypeOf,Ue=Object.prototype.hasOwnProperty,ve=(e=>typeof m<"u"?m:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof m<"u"?m:t)[r]}):e)(function(e){if(typeof m<"u")return m.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),He=(e,t)=>function(){return t||(0,e[ye(e)[0]])((t={exports:{}}).exports,t),t.exports},Ye=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ye(t))!Ue.call(e,s)&&s!==r&&ge(e,s,{get:()=>t[s],enumerable:!(n=Je(t,s))||n.enumerable});return e},Ge=(e,t,r)=>(r=e!=null?We(ze(e)):{},Ye(t||!e||!e.__esModule?ge(r,"default",{value:e,enumerable:!0}):r,e)),Ke=m("fs"),T=Q(Ke),Ve=m("path"),D=Q(Ve),Ze=m("resolve-from"),Xe=Q(Ze),Z=Symbol("singleComment"),he=Symbol("multiComment"),Qe=()=>"",et=(e,t,r)=>e.slice(t,r).replace(/\S/g," "),tt=(e,t)=>{let r=t-1,n=0;for(;e[r]==="\\";)r-=1,n+=1;return!!(n%2)};function rt(e,{whitespace:t=!0,trailingCommas:r=!1}={}){if(typeof e!="string")throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof e}\``);let n=t?et:Qe,s=!1,i=!1,o=0,a="",u="",c=-1;for(let l=0;l<e.length;l++){let f=e[l],h=e[l+1];if(!i&&f==='"'&&(tt(e,l)||(s=!s)),!s)if(!i&&f+h==="//")a+=e.slice(o,l),o=l,i=Z,l++;else if(i===Z&&f+h===`\r
1
+ import{a as m,b as L,c as Ie,g as q}from"./chunk-4IB5MIMZ.mjs";var me=L(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});var Be="8.4.0";V.version=Be});var se=L(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});function Q(e){return e&&e.__esModule?e:{default:e}}function X(e){let t,r=e[0],n=1;for(;n<e.length;){let s=e[n],i=e[n+1];if(n+=2,(s==="optionalAccess"||s==="optionalCall")&&r==null)return;s==="access"||s==="optionalAccess"?(t=r,r=i(r)):(s==="call"||s==="optionalCall")&&(r=i((...o)=>r.call(t,...o)),t=void 0)}return r}var We=Object.create,ge=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,ye=Object.getOwnPropertyNames,ze=Object.getPrototypeOf,Ue=Object.prototype.hasOwnProperty,ve=(e=>typeof m<"u"?m:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof m<"u"?m:t)[r]}):e)(function(e){if(typeof m<"u")return m.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),He=(e,t)=>function(){return t||(0,e[ye(e)[0]])((t={exports:{}}).exports,t),t.exports},Ye=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ye(t))!Ue.call(e,s)&&s!==r&&ge(e,s,{get:()=>t[s],enumerable:!(n=Je(t,s))||n.enumerable});return e},Ge=(e,t,r)=>(r=e!=null?We(ze(e)):{},Ye(t||!e||!e.__esModule?ge(r,"default",{value:e,enumerable:!0}):r,e)),Ke=m("fs"),T=Q(Ke),Ve=m("path"),D=Q(Ve),Ze=m("resolve-from"),Xe=Q(Ze),Z=Symbol("singleComment"),he=Symbol("multiComment"),Qe=()=>"",et=(e,t,r)=>e.slice(t,r).replace(/\S/g," "),tt=(e,t)=>{let r=t-1,n=0;for(;e[r]==="\\";)r-=1,n+=1;return!!(n%2)};function rt(e,{whitespace:t=!0,trailingCommas:r=!1}={}){if(typeof e!="string")throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof e}\``);let n=t?et:Qe,s=!1,i=!1,o=0,a="",u="",c=-1;for(let l=0;l<e.length;l++){let f=e[l],h=e[l+1];if(!i&&f==='"'&&(tt(e,l)||(s=!s)),!s)if(!i&&f+h==="//")a+=e.slice(o,l),o=l,i=Z,l++;else if(i===Z&&f+h===`\r
2
2
  `){l++,i=!1,a+=n(e,o,l),o=l;continue}else if(i===Z&&f===`
3
3
  `)i=!1,a+=n(e,o,l),o=l;else if(!i&&f+h==="/*"){a+=e.slice(o,l),o=l,i=he,l++;continue}else if(i===he&&f+h==="*/"){l++,i=!1,a+=n(e,o,l+1),o=l+1;continue}else r&&!i&&(c!==-1?f==="}"||f==="]"?(a+=e.slice(o,l),u+=n(a,0,1)+a.slice(1),a="",o=l,c=-1):f!==" "&&f!==" "&&f!=="\r"&&f!==`
4
4
  `&&(a+=e.slice(o,l),o=l,c=-1):f===","&&(u+=a+e.slice(o,l),a="",o=l,c=l))}return u+a+(i?n(e.slice(o)):e.slice(o))}var ee=m("tinyglobby");function st(){return te("postcss")}function nt(){return te("@microsoft/api-extractor")}function te(e){let t=Xe.default.silent(process.cwd(),e);return t&&ve(t)}async function it(e,t){(await ee.glob.call(void 0,e,{cwd:t,absolute:!0})).forEach(n=>T.default.existsSync(n)&&T.default.unlinkSync(n))}function at(e,t,r){let n,s,i;return function o(...a){s?i=()=>{o(...a),i=void 0}:(n!=null&&clearTimeout(n),n=setTimeout(()=>{n=void 0,s=e(...a).catch(r).finally(()=>{s=void 0,i&&i()})},t))}}function we(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}function ot(e){return!!e}function lt(e){try{return new Function(`return ${rt(e).trim()}`)()}catch{return{}}}function ct({format:e,pkgType:t}){let r=".js",n=".d.ts",s=t==="module";return s&&e==="cjs"&&(r=".cjs",n=".d.cts"),!s&&e==="esm"&&(r=".mjs",n=".d.mts"),e==="iife"&&(r=".global.js"),{js:r,dts:n}}function ut(){let e=process.cwd(),t=D.default.join(e,".tsup","declaration");if(T.default.existsSync(t))return t;T.default.mkdirSync(t,{recursive:!0});let r=D.default.join(e,".tsup",".gitignore");return xe(r,`**/*
package/dist/utils.mjs CHANGED
@@ -1 +1 @@
1
- import{f as r,g as o}from"./chunk-GKH6M3ZR.mjs";var e=o;export{r as BuildUtils,e as default};
1
+ import{f as r,g as o}from"./chunk-4IB5MIMZ.mjs";var e=o;export{r as BuildUtils,e as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tochii/build",
3
- "version": "2.3.0",
3
+ "version": "2.5.0",
4
4
  "description": "An extremely fast JavaScript/Typescript and CSS bundler with minimal configuration.",
5
5
  "repository": "https://github.com/tochiResources/project/tree/main/packages/build.git",
6
6
  "license": "MIT",
@@ -19,24 +19,28 @@
19
19
  ],
20
20
  "bin": "./dist/cli.mjs",
21
21
  "scripts": {
22
+ "install:tochibuild": "cd ./tochibuild && bun install",
23
+ "copybundler": "copyfiles -u 1 ./tochibuild/tsup@8.4.0-minified/* ./dist",
22
24
  "dev": "tsx cli.ts",
23
25
  "build": "bun run build:root && bun run build:tochibuild",
24
- "copybundler": "copyfiles -u 1 ./tochibuild/tsup@8.4.0-minified/* ./dist",
25
26
  "build:root": "tsx cli.ts && bun run copybundler",
26
27
  "build:tochibuild": "cd ./tochibuild && bun run build",
28
+ "build:release:deprecate": "bun run build:release:root && bun run build:release:tochibuild && bun run deprecate:all",
27
29
  "build:release": "bun run build:release:root && bun run build:release:tochibuild",
28
30
  "build:release:root": "bun run build:root && bun run release:root",
29
31
  "build:release:tochibuild": "cd ./tochibuild && bun run build && bun run release",
30
- "install:tochibuild": "cd ./tochibuild && bun install",
31
32
  "release": "bun run release:root && bun run release:tochibuild",
33
+ "release:deprecate": "bun run release && bun run deprecate:all",
32
34
  "release:root": "bun publish --access public --no-private",
33
- "release:tochibuild": "cd ./tochibuild && bun run release"
35
+ "release:tochibuild": "cd ./tochibuild && bun run release",
36
+ "deprecate:all": "bun run deprecate:root && bun run deprecate:tochibuild",
37
+ "deprecate:root": "bun run deprecate @tochii/build@\"<2.5.0\" \"Deprecated: Please upgrade to version 2.5.0 or higher.\"",
38
+ "deprecate:tochibuild": "bun run deprecate tochiibuild@\"<2.5.0\" \"Deprecated: Please upgrade to version 2.5.0 or higher.\""
34
39
  },
35
40
  "dependencies": {
36
41
  "chalk": "^5.4.1",
37
42
  "commander": "^13.1.0",
38
43
  "deepmerge": "^4.3.1",
39
- "tochibuild": "^2.2.6",
40
44
  "tsup": "8.4.0"
41
45
  },
42
46
  "devDependencies": {