@longzai-intelligence-vite/cli 0.0.2 → 0.0.4

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.
Files changed (2) hide show
  1. package/dist/index.js +2 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -205,7 +205,7 @@ ${Z.default.gray(Id+Pd.repeat(a+2)+Ld)}
205
205
  `):process.stdout.write(`${r} ${s}
206
206
  `),m(),i()};return{start:v,stop:y,message:(e=``)=>{s=g(e??s)}}},Zd={red:e=>Z.default.red(e),green:e=>Z.default.green(e),yellow:e=>Z.default.yellow(e),blue:e=>Z.default.blue(e),cyan:e=>Z.default.cyan(e),magenta:e=>Z.default.magenta(e),gray:e=>Z.default.gray(e),bold:e=>Z.default.bold(e),dim:e=>Z.default.dim(e)},Qd={async select(e,t){let n=await Kd({message:e,options:t.map(e=>({value:e.value,label:e.label,hint:e.hint}))});return dd(n)&&(Jd(`操作已取消`),process.exit(0)),typeof n==`string`?n:String(n)},async textInput(e,t){let n=await Wd({message:e,placeholder:t?.placeholder,defaultValue:t?.defaultValue});return dd(n)&&(Jd(`操作已取消`),process.exit(0)),typeof n==`string`?n:String(n)},async confirm(e,t){let n=await Gd({message:e,initialValue:t?.defaultValue??!1});return dd(n)&&(Jd(`操作已取消`),process.exit(0)),typeof n==`boolean`?n:!!n},spinner(){let e=Xd();return{start(t){e.start(t)},stop(t){e.stop(t)}}},note(e,t){qd(e,t)},log:{info(e){Yd.info(Z.default.blue(e))},success(e){Yd.success(Z.default.green(e))},warn(e){Yd.warn(Z.default.yellow(e))},error(e){Yd.error(Z.default.red(e))},step(e){Yd.step(e)}}},$d=[`bin`,`vite.js`],ef=()=>{let t=e(x(process.cwd(),`package.json`)).resolve(`vite/package.json`);return x(b(t),...$d)},tf=async e=>{let t;try{t=ef()}catch{process.stderr.write(`错误: 当前目录未解析到 vite 依赖
207
207
  `),process.stderr.write(`请在声明 vite 依赖的单元根目录执行,例如 apps/web
208
- `),process.exit(1)}let n=[e,...process.argv.slice(3)],r=await Bun.spawn([`node`,t,...n],{cwd:process.cwd(),stdout:`inherit`,stderr:`inherit`}).exited;r!==0&&process.exit(r)};var nf=/* @__PURE__ */ _(import.meta.url);function rf(e){let t=f(e);return t.length>1&&t[t.length-1]===g&&(t=t.substring(0,t.length-1)),t}const af=/[\\/]/g;function of(e,t){return e.replace(af,t)}const sf=/^[a-z]:[\\/]$/i;function cf(e){return e===`/`||sf.test(e)}function lf(e,t){let{resolvePaths:n,normalizePath:r,pathSeparator:i}=t,a=process.platform===`win32`&&e.includes(`/`)||e.startsWith(`.`);return n&&(e=h(e)),(r||a)&&(e=rf(e)),e===`.`?``:of(e[e.length-1]===i?e:e+i,i)}function uf(e,t){return t+e}function df(e,t){return function(n,r){return r.startsWith(e)?r.slice(e.length)+n:of(m(e,r),t.pathSeparator)+t.pathSeparator+n}}function ff(e){return e}function pf(e,t,n){return t+e+n}function mf(e,t){let{relativePaths:n,includeBasePath:r}=t;return n&&e?df(e,t):r?uf:ff}function hf(e){return function(t,n){n.push(t.substring(e.length)||`.`)}}function gf(e){return function(t,n,r){let i=t.substring(e.length)||`.`;r.every(e=>e(i,!0))&&n.push(i)}}const _f=(e,t)=>{t.push(e||`.`)},vf=(e,t,n)=>{let r=e||`.`;n.every(e=>e(r,!0))&&t.push(r)},yf=()=>{};function bf(e,t){let{includeDirs:n,filters:r,relativePaths:i}=t;return n?i?r&&r.length?gf(e):hf(e):r&&r.length?vf:_f:yf}const xf=(e,t,n,r)=>{r.every(t=>t(e,!1))&&n.files++},Sf=(e,t,n,r)=>{r.every(t=>t(e,!1))&&t.push(e)},Cf=(e,t,n,r)=>{n.files++},wf=(e,t)=>{t.push(e)},Tf=()=>{};function Ef(e){let{excludeFiles:t,filters:n,onlyCounts:r}=e;return t?Tf:n&&n.length?r?xf:Sf:r?Cf:wf}const Df=e=>e,Of=()=>[``].slice(0,0);function kf(e){return e.group?Of:Df}const Af=(e,t,n)=>{e.push({directory:t,files:n,dir:t})},jf=()=>{};function Mf(e){return e.group?Af:jf}const Nf=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue(),i.realpath(e,(o,s)=>{if(o)return r.dequeue(a?null:o,t);i.stat(s,(i,o)=>{if(i)return r.dequeue(a?null:i,t);if(o.isDirectory()&&If(e,s,t))return r.dequeue(null,t);n(o,s),r.dequeue(null,t)})})},Pf=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue();try{let r=i.realpathSync(e),a=i.statSync(r);if(a.isDirectory()&&If(e,r,t))return;n(a,r)}catch(e){if(!a)throw e}};function Ff(e,t){return!e.resolveSymlinks||e.excludeSymlinks?null:t?Pf:Nf}function If(e,t,n){if(n.options.useRealPaths)return Lf(t,n);let r=u(e),i=1;for(;r!==n.root&&i<2;){let e=n.symlinks.get(r);e&&(e===t||e.startsWith(t)||t.startsWith(e))?i++:r=u(r)}return n.symlinks.set(e,t),i>1}function Lf(e,t){return t.visited.includes(e+t.options.pathSeparator)}const Rf=e=>e.counts,zf=e=>e.groups,Bf=e=>e.paths,Vf=e=>e.paths.slice(0,e.options.maxFiles),Hf=(e,t,n)=>(Kf(t,n,e.counts,e.options.suppressErrors),null),Uf=(e,t,n)=>(Kf(t,n,e.paths,e.options.suppressErrors),null),Wf=(e,t,n)=>(Kf(t,n,e.paths.slice(0,e.options.maxFiles),e.options.suppressErrors),null),Gf=(e,t,n)=>(Kf(t,n,e.groups,e.options.suppressErrors),null);function Kf(e,t,n,r){t(e&&!r?e:null,n)}function qf(e,t){let{onlyCounts:n,group:r,maxFiles:i}=e;return n?t?Rf:Hf:r?t?zf:Gf:i?t?Vf:Wf:t?Bf:Uf}const Jf={withFileTypes:!0},Yf=(e,t,n,r,i)=>{if(e.queue.enqueue(),r<0)return e.queue.dequeue(null,e);let{fs:a}=e;e.visited.push(t),e.counts.directories++,a.readdir(t||`.`,Jf,(t,a=[])=>{i(a,n,r),e.queue.dequeue(e.options.suppressErrors?null:t,e)})},Xf=(e,t,n,r,i)=>{let{fs:a}=e;if(r<0)return;e.visited.push(t),e.counts.directories++;let o=[];try{o=a.readdirSync(t||`.`,Jf)}catch(t){if(!e.options.suppressErrors)throw t}i(o,n,r)};function Zf(e){return e?Xf:Yf}var Qf=class{count=0;constructor(e){this.onQueueEmpty=e}enqueue(){return this.count++,this.count}dequeue(e,t){this.onQueueEmpty&&(--this.count<=0||e)&&(this.onQueueEmpty(e,t),e&&(t.controller.abort(),this.onQueueEmpty=void 0))}},$f=class{_files=0;_directories=0;set files(e){this._files=e}get files(){return this._files}set directories(e){this._directories=e}get directories(){return this._directories}
208
+ `),process.exit(1)}let n=e===`dev`?process.argv.slice(3):[e,...process.argv.slice(3)],r=await Bun.spawn([`node`,t,...n],{cwd:process.cwd(),stdout:`inherit`,stderr:`inherit`}).exited;r!==0&&process.exit(r)};var nf=/* @__PURE__ */ _(import.meta.url);function rf(e){let t=f(e);return t.length>1&&t[t.length-1]===g&&(t=t.substring(0,t.length-1)),t}const af=/[\\/]/g;function of(e,t){return e.replace(af,t)}const sf=/^[a-z]:[\\/]$/i;function cf(e){return e===`/`||sf.test(e)}function lf(e,t){let{resolvePaths:n,normalizePath:r,pathSeparator:i}=t,a=process.platform===`win32`&&e.includes(`/`)||e.startsWith(`.`);return n&&(e=h(e)),(r||a)&&(e=rf(e)),e===`.`?``:of(e[e.length-1]===i?e:e+i,i)}function uf(e,t){return t+e}function df(e,t){return function(n,r){return r.startsWith(e)?r.slice(e.length)+n:of(m(e,r),t.pathSeparator)+t.pathSeparator+n}}function ff(e){return e}function pf(e,t,n){return t+e+n}function mf(e,t){let{relativePaths:n,includeBasePath:r}=t;return n&&e?df(e,t):r?uf:ff}function hf(e){return function(t,n){n.push(t.substring(e.length)||`.`)}}function gf(e){return function(t,n,r){let i=t.substring(e.length)||`.`;r.every(e=>e(i,!0))&&n.push(i)}}const _f=(e,t)=>{t.push(e||`.`)},vf=(e,t,n)=>{let r=e||`.`;n.every(e=>e(r,!0))&&t.push(r)},yf=()=>{};function bf(e,t){let{includeDirs:n,filters:r,relativePaths:i}=t;return n?i?r&&r.length?gf(e):hf(e):r&&r.length?vf:_f:yf}const xf=(e,t,n,r)=>{r.every(t=>t(e,!1))&&n.files++},Sf=(e,t,n,r)=>{r.every(t=>t(e,!1))&&t.push(e)},Cf=(e,t,n,r)=>{n.files++},wf=(e,t)=>{t.push(e)},Tf=()=>{};function Ef(e){let{excludeFiles:t,filters:n,onlyCounts:r}=e;return t?Tf:n&&n.length?r?xf:Sf:r?Cf:wf}const Df=e=>e,Of=()=>[``].slice(0,0);function kf(e){return e.group?Of:Df}const Af=(e,t,n)=>{e.push({directory:t,files:n,dir:t})},jf=()=>{};function Mf(e){return e.group?Af:jf}const Nf=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue(),i.realpath(e,(o,s)=>{if(o)return r.dequeue(a?null:o,t);i.stat(s,(i,o)=>{if(i)return r.dequeue(a?null:i,t);if(o.isDirectory()&&If(e,s,t))return r.dequeue(null,t);n(o,s),r.dequeue(null,t)})})},Pf=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue();try{let r=i.realpathSync(e),a=i.statSync(r);if(a.isDirectory()&&If(e,r,t))return;n(a,r)}catch(e){if(!a)throw e}};function Ff(e,t){return!e.resolveSymlinks||e.excludeSymlinks?null:t?Pf:Nf}function If(e,t,n){if(n.options.useRealPaths)return Lf(t,n);let r=u(e),i=1;for(;r!==n.root&&i<2;){let e=n.symlinks.get(r);e&&(e===t||e.startsWith(t)||t.startsWith(e))?i++:r=u(r)}return n.symlinks.set(e,t),i>1}function Lf(e,t){return t.visited.includes(e+t.options.pathSeparator)}const Rf=e=>e.counts,zf=e=>e.groups,Bf=e=>e.paths,Vf=e=>e.paths.slice(0,e.options.maxFiles),Hf=(e,t,n)=>(Kf(t,n,e.counts,e.options.suppressErrors),null),Uf=(e,t,n)=>(Kf(t,n,e.paths,e.options.suppressErrors),null),Wf=(e,t,n)=>(Kf(t,n,e.paths.slice(0,e.options.maxFiles),e.options.suppressErrors),null),Gf=(e,t,n)=>(Kf(t,n,e.groups,e.options.suppressErrors),null);function Kf(e,t,n,r){t(e&&!r?e:null,n)}function qf(e,t){let{onlyCounts:n,group:r,maxFiles:i}=e;return n?t?Rf:Hf:r?t?zf:Gf:i?t?Vf:Wf:t?Bf:Uf}const Jf={withFileTypes:!0},Yf=(e,t,n,r,i)=>{if(e.queue.enqueue(),r<0)return e.queue.dequeue(null,e);let{fs:a}=e;e.visited.push(t),e.counts.directories++,a.readdir(t||`.`,Jf,(t,a=[])=>{i(a,n,r),e.queue.dequeue(e.options.suppressErrors?null:t,e)})},Xf=(e,t,n,r,i)=>{let{fs:a}=e;if(r<0)return;e.visited.push(t),e.counts.directories++;let o=[];try{o=a.readdirSync(t||`.`,Jf)}catch(t){if(!e.options.suppressErrors)throw t}i(o,n,r)};function Zf(e){return e?Xf:Yf}var Qf=class{count=0;constructor(e){this.onQueueEmpty=e}enqueue(){return this.count++,this.count}dequeue(e,t){this.onQueueEmpty&&(--this.count<=0||e)&&(this.onQueueEmpty(e,t),e&&(t.controller.abort(),this.onQueueEmpty=void 0))}},$f=class{_files=0;_directories=0;set files(e){this._files=e}get files(){return this._files}set directories(e){this._directories=e}get directories(){return this._directories}
209
209
  /* c8 ignore next 3 */
210
210
  get dirs(){return this._directories}},ep=class{aborted=!1;abort(){this.aborted=!0}},tp=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(e,t,r){this.isSynchronous=!r,this.callbackInvoker=qf(t,this.isSynchronous),this.root=lf(e,t),this.state={root:cf(this.root)?this.root:this.root.slice(0,-1),paths:[``].slice(0,0),groups:[],counts:new $f,options:t,queue:new Qf((e,t)=>this.callbackInvoker(t,e,r)),symlinks:/* @__PURE__ */ new Map,visited:[``].slice(0,0),controller:new ep,fs:t.fs||n},this.joinPath=mf(this.root,t),this.pushDirectory=bf(this.root,t),this.pushFile=Ef(t),this.getArray=kf(t),this.groupFiles=Mf(t),this.resolveSymlink=Ff(t,this.isSynchronous),this.walkDirectory=Zf(this.isSynchronous)}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(e,t,n)=>{let{paths:r,options:{filters:i,resolveSymlinks:a,excludeSymlinks:o,exclude:s,maxFiles:c,signal:d,useRealPaths:f,pathSeparator:p},controller:m}=this.state;if(m.aborted||d&&d.aborted||c&&r.length>c)return;let h=this.getArray(this.state.paths);for(let c=0;c<e.length;++c){let d=e[c];if(d.isFile()||d.isSymbolicLink()&&!a&&!o){let e=this.joinPath(d.name,t);this.pushFile(e,h,this.state.counts,i)}else if(d.isDirectory()){let e=pf(d.name,t,this.state.options.pathSeparator);if(s&&s(d.name,e))continue;this.pushDirectory(e,r,i),this.walkDirectory(this.state,e,e,n-1,this.walk)}else if(this.resolveSymlink&&d.isSymbolicLink()){let e=uf(d.name,t);this.resolveSymlink(e,this.state,(t,r)=>{if(t.isDirectory()){if(r=lf(r,this.state.options),s&&s(d.name,f?r:e+p))return;this.walkDirectory(this.state,r,f?r:e+p,n-1,this.walk)}else{r=f?r:e;let t=l(r),n=lf(u(r),this.state.options);r=this.joinPath(t,n),this.pushFile(r,h,this.state.counts,i)}})}}this.groupFiles(this.state.groups,t,h)}};function np(e,t){return new Promise((n,r)=>{rp(e,t,(e,t)=>{if(e)return r(e);n(t)})})}function rp(e,t,n){new tp(e,t,n).start()}function ip(e,t){return new tp(e,t).start()}var ap=class{constructor(e,t){this.root=e,this.options=t}withPromise(){return np(this.root,this.options)}withCallback(e){rp(this.root,this.options,e)}sync(){return ip(this.root,this.options)}};let op=null;
211
211
  /* c8 ignore next 6 */
@@ -217,4 +217,4 @@ if(!n)throw Error(`Please specify a glob function to use glob matching.`);var r=
217
217
  /* node:coverage ignore next 2 */
218
218
  const bp=/^[A-Z]:\/$/i,xp=_p?e=>bp.test(e):e=>e===`/`;function Sp(e,t,n){if(e===t||t.startsWith(`${e}/`)){if(n){let t=e.length+ +!xp(e);return(e,n)=>e.slice(t,n?-1:void 0)||`.`}let r=t.slice(e.length+1);return r?(e,t)=>{if(e===`.`)return r;let n=`${r}/${e}`;return t?n.slice(0,-1):n}:(e,t)=>t&&e!==`.`?e.slice(0,-1):e}return n?t=>p.relative(e,t)||`.`:n=>p.relative(e,`${t}/${n}`)||`.`}function Cp(e,t){if(t.startsWith(`${e}/`)){let n=t.slice(e.length+1);return e=>`${n}/${e}`}return n=>{let r=p.relative(e,`${t}/${n}`);return n[n.length-1]===`/`&&r!==``?`${r}/`:r||`.`}}function wp(e){return e.replace(gp,e=>`${e}/`)}const Tp={parts:!0};function Ep(e){let t=pp.default.scan(e,Tp);return t.parts?.length?t.parts:[e]}const Dp=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,Op=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,kp=_p?e=>e.replace(Op,`\\$&`):e=>e.replace(Dp,`\\$&`);function Ap(e,t){if(t?.caseSensitiveMatch===!1)return!0;let n=pp.default.scan(e);return n.isGlob||n.negated}function jp(...e){console.log(`[tinyglobby ${(/* @__PURE__ */ new Date()).toLocaleTimeString(`es`)}]`,...e)}function Mp(e){return typeof e==`string`?[e]:e??[]}const Np=/^(\/?\.\.)+/,Pp=/\\(?=[()[\]{}!*+?@|])/g;function Fp(e,t,n,r){let i=t.cwd,a=e;e[e.length-1]===`/`&&(a=e.slice(0,-1)),a[a.length-1]!==`*`&&t.expandDirectories&&(a+=`/**`);let o=kp(i);a=d(a.replace(Pp,``))?p.relative(o,a):p.normalize(a);let s=Np.exec(a)?.[0],c=Ep(a);if(s){let e=(s.length+1)/3,t=0,r=o.split(`/`);for(;t<e&&c[t+e]===r[r.length+t-e];)a=a.slice(0,(e-t-1)*3)+a.slice((e-t)*3+c[t+e].length+1)||`.`,t++;let l=p.join(i,s.slice(t*3));l[0]!==`.`&&n.root.length>l.length&&(n.root=wp(l),n.depthOffset=-e+t)}if(!r&&n.depthOffset>=0){n.commonPath??=c;let e=[],t=Math.min(n.commonPath.length,c.length);for(let r=0;r<t;r++){let t=c[r];if(t===`**`&&!c[r+1]){e.pop();break}if(r===c.length-1||t!==n.commonPath[r]||Ap(t))break;e.push(t)}n.depthOffset=e.length,n.commonPath=e,n.root=wp(e.length>0?p.join(i,...e):i)}return a}function Ip(e,t,n){let r=[],i=[];for(let t of e.ignore)t&&(t[0]!==`!`||t[1]===`(`)&&i.push(Fp(t,e,n,!0));for(let a of t)a&&(a[0]!==`!`||a[1]===`(`?r.push(Fp(a,e,n,!1)):(a[1]!==`!`||a[2]===`(`)&&i.push(Fp(a.slice(1),e,n,!0)));return{match:r,ignore:i}}function Lp(e,t){let n=e.cwd,r={root:n,depthOffset:0},i=Ip(e,t,r);e.debug&&jp(`internal processing patterns:`,i);let{absolute:a,caseSensitiveMatch:o,debug:s,dot:c,followSymbolicLinks:l,onlyDirectories:u}=e,d=r.root.replace(hp,``),f={dot:c,nobrace:e.braceExpansion===!1,nocase:!o,noextglob:e.extglob===!1,noglobstar:e.globstar===!1,posix:!0},p=(0,pp.default)(i.match,f),m=(0,pp.default)(i.ignore,f),h=yp(i.match,f),g=Sp(n,d,a),_=a?g:Sp(n,d,!0),v=(e,t)=>{let n=_(t,!0);return n!==`.`&&!h(n)||m(n)},y;e.deep!==void 0&&(y=Math.round(e.deep-r.depthOffset));let b=new sp({filters:[s?(e,t)=>{let n=g(e,t),r=p(n)&&!m(n);return r&&jp(`matched ${n}`),r}:(e,t)=>{let n=g(e,t);return p(n)&&!m(n)}],exclude:s?(e,t)=>{let n=v(e,t);return jp(`${n?`skipped`:`crawling`} ${t}`),n}:v,fs:e.fs,pathSeparator:`/`,relativePaths:!a,resolvePaths:a,includeBasePath:a,resolveSymlinks:l,excludeSymlinks:!l,excludeFiles:u,includeDirs:u||!e.onlyFiles,maxDepth:y,signal:e.signal}).crawl(d);return e.debug&&jp(`internal properties:`,{...r,root:d}),[b,n!==d&&!a&&Cp(n,d)]}function Rp(e,t){if(t)for(let n=e.length-1;n>=0;n--)e[n]=t(e[n]);return e}const zp={caseSensitiveMatch:!0,debug:!!process.env.TINYGLOBBY_DEBUG,expandDirectories:!0,followSymbolicLinks:!0,onlyFiles:!0};function Bp(e){let t=Object.assign({},e);for(let e in zp)t[e]===void 0&&Object.assign(t,{[e]:zp[e]});return t.cwd=(t.cwd instanceof URL?w(t.cwd):h(t.cwd||process.cwd())).replace(hp,`/`),t.ignore=Mp(t.ignore),t.fs&&={readdir:t.fs.readdir||r,readdirSync:t.fs.readdirSync||i,realpath:t.fs.realpath||a,realpathSync:t.fs.realpathSync||o,stat:t.fs.stat||s,statSync:t.fs.statSync||c},t.debug&&jp(`globbing with options:`,t),t}function Vp(e,t={}){if(e&&t?.patterns)throw Error(`Cannot pass patterns as both an argument and an option`);let n=mp(e)||typeof e==`string`,r=Mp((n?e:e.patterns)??`**/*`),i=Bp(n?t:e);return r.length>0?Lp(i,r):[]}async function Hp(e,t){let[n,r]=Vp(e,t);return n?Rp(await n.withPromise(),r):[]}const Up=[`**/vite.config.ts`,`**/vite.config.mts`],Wp=[`**/node_modules/**`,`**/dist/**`,`**/out/**`,`**/.turbo/**`,`**/.cache/**`,`**/coverage/**`,`**/.zcode/**`];async function Gp(e){return(await Hp(Up,{cwd:e,ignore:Wp,absolute:!0,dot:!1})).sort()}function Kp(e){return typeof e==`function`}async function qp(e){let t=(await import(C(e).href)).default;return Kp(t)?await t({command:`serve`,mode:`development`}):t??null}const Jp=/^\^\/[a-z0-9-]+\(\/\|\$\|\\\?\)$/,Yp=/^\/[a-z0-9-]+$/,Xp=[`node:child_process`,`execFileSync`,`spawnSync`,`rev-parse`],Zp=`@longzai-intelligence-vite/plugins`,Qp={readText:e=>{try{return y(e,`utf-8`)}catch{return null}},pathExists:e=>v(e)};function $p(e){return typeof e==`object`&&!!e}const em=zl({include:Ll(ol()).optional(),compilerOptions:zl({allowImportingTsExtensions:jl().optional()}).optional()}),tm=zl({dependencies:Kl(ol(),ol()).optional(),devDependencies:Kl(ol(),ol()).optional(),peerDependencies:Kl(ol(),ol()).optional()});function nm(e){if(!$p(e))return null;let t=e.server;if(!$p(t))return null;let n=t.proxy;return $p(n)?n:null}function rm(e,t){let n=nm(e);if(n===null)return[];let r=[];for(let e of Object.keys(n)){if(Jp.test(e))continue;let n=Yp.test(e)?`裸前缀键 \`${e}\` 会以 \`startsWith\` 误吞同前缀前端路由,应改写为锚定边界正则形态 \`^${e}(/|$|\\\\?)\``:`代理键 \`${e}\` 不符合 \`^/前缀(/|$|\\\\?)\` 锚定边界正则形态`;r.push({rule:`proxy-key-form`,file:t,message:n,severity:`violation`})}return r}function im(e,t){let n=[];for(let r of Xp)e.includes(r)&&n.push({rule:`inline-plugin-signal`,file:t,message:`检测到内联插件逻辑信号 \`${r}\`,此类逻辑应归位 \`@longzai-intelligence-vite/plugins\` 或 app 根级 \`plugins/\` 目录`,severity:`violation`});return e.includes(`z.object`)&&e.includes(`package.json`)&&n.push({rule:`inline-plugin-signal`,file:t,message:`检测到配置文件内解析包定义的组合信号,包定义读取应归位统一插件或独立模块`,severity:`violation`}),n}function am(e,t,n=Qp){if(!n.pathExists(`${e}/plugins`))return[];let r=n.readText(`${e}/tsconfig/node.json`);if(r===null)return[{rule:`plugins-dir-tsconfig`,file:t,message:"存在 `plugins/` 目录但缺失 `tsconfig/node.json` 分片,无法归位插件模块类型检查",severity:`violation`}];let i;try{i=em.parse(JSON.parse(r))}catch{return[{rule:`plugins-dir-tsconfig`,file:t,message:"`tsconfig/node.json` 不是可解析的 JSON 形态",severity:`violation`}]}let a=[];return(i.include??[]).some(e=>e.includes(`plugins`))||a.push({rule:`plugins-dir-tsconfig`,file:t,message:"`plugins/` 目录未纳入 `tsconfig/node.json` 的 include,插件模块游离在类型检查之外",severity:`violation`}),i.compilerOptions?.allowImportingTsExtensions!==!0&&a.push({rule:`plugins-dir-tsconfig`,file:t,message:"导入插件模块需要显式 ts 扩展名,`tsconfig/node.json` 须开 `allowImportingTsExtensions`",severity:`violation`}),a}function om(e,t,n=Qp){let r=n.readText(`${e}/package.json`);if(r===null)return[];let i;try{i=tm.parse(JSON.parse(r))}catch{return[]}return[i.dependencies,i.devDependencies,i.peerDependencies].some(e=>e!==void 0&&Zp in e)?[]:[{rule:`adoption`,file:t,message:`尚未声明 \`${Zp}\` 依赖,采纳状态经 \`docs/ledgers/lzi-vite-adoption/\` 台账追踪`,severity:`advisory`}]}const sm=/\b(?:from|import)\s+['"]electron(?:-vite)?['"]/;async function cm(e,t){let n,r=new Promise((e,r)=>{n=setTimeout(()=>r(/* @__PURE__ */ Error(`配置加载超时`)),t)});try{return await Promise.race([e,r])}finally{clearTimeout(n)}}async function lm(e){let t=e.io??Qp,n=await Gp(e.cwd),r=[];for(let i of n){let n=S(e.cwd,i),a=t.readText(i);if(a===null){r.push({rule:`config-load`,file:n,message:`配置文件读取失败`,severity:`violation`});continue}let o=i.slice(0,i.lastIndexOf(`/`));if(sm.test(a))r.push({rule:`config-load`,file:n,message:"配置导入 `electron` 等副作用模块,装载期会触发二进制下载,已跳过动态加载仅执行静态判据",severity:`advisory`});else try{let e=await cm(qp(i),15e3);r.push(...rm(e,n))}catch(e){r.push({rule:`config-load`,file:n,message:`配置文件加载失败,${e instanceof Error?e.message:String(e)}`,severity:`violation`})}r.push(...im(a,n)),r.push(...am(o,n,t)),r.push(...om(o,n,t))}return{configCount:n.length,findings:r,violationCount:r.filter(e=>e.severity===`violation`).length,advisoryCount:r.filter(e=>e.severity===`advisory`).length}}function um(e){let t=[`lzi-vite check:扫描 ${e.configCount} 个 vite 配置`];if(e.findings.length===0)return t.push(`未发现违规项`),`${t.join(`
219
219
  `)}\n`;for(let n of e.findings){let e=n.severity===`violation`?`[违规]`:`[提示]`;t.push(`${e} ${n.rule} ${n.file}`),t.push(` ${n.message}`)}return t.push(`汇总:违规 ${e.violationCount} 项,提示 ${e.advisoryCount} 项`),`${t.join(`
220
- `)}\n`}async function dm(){let e=await lm({cwd:process.cwd()});process.stdout.write(um(e)),process.exit(+(e.violationCount>0))}const fm=Du({name:`lzi-vite`,description:`Longzai Intelligence Vite 配置规范巡检`,interaction:Qd,color:Zd});ju(fm,{name:`check`,description:`巡检当前仓全部 vite 配置的工程规范合规性`,schema:Bl({}),action:async()=>{await dm()}}),ju(fm,{name:`build`,description:`以 node 运行时统一执行 vite 构建`,schema:Bl({}),action:async()=>{await tf(`build`)}}),ju(fm,{name:`preview`,description:`以 node 运行时统一执行 vite 产物预览`,schema:Bl({}),action:async()=>{await tf(`preview`)}});async function pm(){await fm.parseAsync(process.argv)}pm().catch(e=>{process.stderr.write(`错误: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)});export{};
220
+ `)}\n`}async function dm(){let e=await lm({cwd:process.cwd()});process.stdout.write(um(e)),process.exit(+(e.violationCount>0))}const fm=Du({name:`lzi-vite`,description:`Longzai Intelligence Vite 配置规范巡检`,interaction:Qd,color:Zd});ju(fm,{name:`check`,description:`巡检当前仓全部 vite 配置的工程规范合规性`,schema:Bl({}),action:async()=>{await dm()}});for(let e of[{name:`build`,description:`以 node 运行时统一执行 vite 构建`},{name:`dev`,description:`以 node 运行时统一启动 vite 开发服务器`},{name:`preview`,description:`以 node 运行时统一执行 vite 产物预览`}]){ju(fm,{name:e.name,description:e.description,arguments:[{signature:`[args...]`,description:`原样透传给 vite 的参数`}],schema:Bl({}),action:async()=>{await tf(e.name)}});let t=fm.commands.find(t=>t.name()===e.name);t!==void 0&&t.allowUnknownOption(!0)}async function pm(){await fm.parseAsync(process.argv)}pm().catch(e=>{process.stderr.write(`错误: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)});export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-vite/cli",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Longzai Intelligence Vite 配置规范巡检 CLI",
5
5
  "keywords": [
6
6
  "check",