@clerc/plugin-not-found
Advanced tools
Comparing version 0.25.1 to 0.26.0
@@ -1,47 +0,2 @@ | ||
import { definePlugin, NoSuchCommandError, NoCommandGivenError } from '@clerc/core'; | ||
import didyoumean from 'didyoumean2'; | ||
import pc from 'picocolors'; | ||
const semanticArray = (arr) => { | ||
if (arr.length <= 1) { | ||
return arr[0]; | ||
} | ||
return `${arr.slice(0, -1).map(pc.bold).join(", ")} and ${pc.bold(arr[arr.length - 1])}`; | ||
}; | ||
const notFoundPlugin = () => definePlugin({ | ||
setup: (cli) => { | ||
return cli.inspector({ | ||
enforce: "pre", | ||
fn: (ctx, next) => { | ||
const commandKeys = Object.keys(cli._commands); | ||
const hasCommands = !!commandKeys.length; | ||
try { | ||
next(); | ||
} catch (e) { | ||
if (!(e instanceof NoSuchCommandError || e instanceof NoCommandGivenError)) { | ||
throw e; | ||
} | ||
if (ctx.raw._.length === 0 || e instanceof NoCommandGivenError) { | ||
console.error("No command given."); | ||
if (hasCommands) { | ||
console.error(`Possible commands: ${semanticArray(commandKeys)}.`); | ||
} | ||
return; | ||
} | ||
const calledCommandName = e.commandName; | ||
const closestCommandName = didyoumean(calledCommandName, commandKeys); | ||
console.error(`Command "${pc.strikethrough(calledCommandName)}" not found.`); | ||
if (hasCommands && closestCommandName) { | ||
console.error(`Did you mean "${pc.bold(closestCommandName)}"?`); | ||
} else if (!hasCommands) { | ||
console.error("NOTE: You haven't register any command yet."); | ||
} | ||
process.stderr.write("\n"); | ||
process.exit(2); | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
export { notFoundPlugin }; | ||
import{definePlugin as $,NoSuchCommandError as q,NoCommandGivenError as R}from"@clerc/core";import z from"tty";const I=new Uint32Array(65536),Z=(t,e)=>{const s=t.length,x=e.length,i=1<<s-1;let u=-1,f=0,S=s,l=s;for(;l--;)I[t.charCodeAt(l)]|=1<<l;for(l=0;l<x;l++){let b=I[e.charCodeAt(l)];const d=b|f;b|=(b&u)+u^u,f|=~(b|u),u&=b,f&i&&S++,u&i&&S--,f=f<<1|1,u=u<<1|~(d|f),f&=d}for(l=s;l--;)I[t.charCodeAt(l)]=0;return S},B=(t,e)=>{const s=e.length,x=t.length,i=[],u=[],f=Math.ceil(s/32),S=Math.ceil(x/32);for(let r=0;r<f;r++)u[r]=-1,i[r]=0;let l=0;for(;l<S-1;l++){let r=0,c=-1;const h=l*32,y=Math.min(32,x)+h;for(let a=h;a<y;a++)I[t.charCodeAt(a)]|=1<<a;for(let a=0;a<s;a++){const E=I[e.charCodeAt(a)],A=u[a/32|0]>>>a&1,C=i[a/32|0]>>>a&1,M=E|r,k=((E|C)&c)+c^c|E|C;let _=r|~(k|c),O=c&k;_>>>31^A&&(u[a/32|0]^=1<<a),O>>>31^C&&(i[a/32|0]^=1<<a),_=_<<1|A,O=O<<1|C,c=O|~(M|_),r=_&M}for(let a=h;a<y;a++)I[t.charCodeAt(a)]=0}let b=0,d=-1;const T=l*32,o=Math.min(32,x-T)+T;for(let r=T;r<o;r++)I[t.charCodeAt(r)]|=1<<r;let n=x;for(let r=0;r<s;r++){const c=I[e.charCodeAt(r)],h=u[r/32|0]>>>r&1,y=i[r/32|0]>>>r&1,a=c|b,E=((c|y)&d)+d^d|c|y;let A=b|~(E|d),C=d&E;n+=A>>>x-1&1,n-=C>>>x-1&1,A>>>31^h&&(u[r/32|0]^=1<<r),C>>>31^y&&(i[r/32|0]^=1<<r),A=A<<1|h,C=C<<1|y,d=C|~(a|A),b=A&a}for(let r=T;r<o;r++)I[t.charCodeAt(r)]=0;return n},N=(t,e)=>{if(t.length<e.length){const s=e;e=t,t=s}return e.length===0?t.length:t.length<=32?Z(t,e):B(t,e)};var v=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},J=1/0,K="[object Symbol]",W=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Q="\\u0300-\\u036f\\ufe20-\\ufe23",V="\\u20d0-\\u20f0",X="["+Q+V+"]",tt=RegExp(X,"g"),et={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"ss"},rt=typeof v=="object"&&v&&v.Object===Object&&v,ot=typeof self=="object"&&self&&self.Object===Object&&self,nt=rt||ot||Function("return this")();function ut(t){return function(e){return t==null?void 0:t[e]}}var st=ut(et),ct=Object.prototype,it=ct.toString,H=nt.Symbol,j=H?H.prototype:void 0,D=j?j.toString:void 0;function xt(t){if(typeof t=="string")return t;if(mt(t))return D?D.call(t):"";var e=t+"";return e=="0"&&1/t==-J?"-0":e}function lt(t){return!!t&&typeof t=="object"}function mt(t){return typeof t=="symbol"||lt(t)&&it.call(t)==K}function at(t){return t==null?"":xt(t)}function ft(t){return t=at(t),t&&t.replace(W,st).replace(tt,"")}var ht=ft;let g,p;(function(t){t.ALL_CLOSEST_MATCHES="all-closest-matches",t.ALL_MATCHES="all-matches",t.ALL_SORTED_MATCHES="all-sorted-matches",t.FIRST_CLOSEST_MATCH="first-closest-match",t.FIRST_MATCH="first-match"})(g||(g={})),function(t){t.EDIT_DISTANCE="edit-distance",t.SIMILARITY="similarity"}(p||(p={}));const Y=new Error("unknown returnType"),w=new Error("unknown thresholdType"),F=(t,e)=>{let s=t;return e.trimSpaces&&(s=s.trim().replace(/\s+/g," ")),e.deburr&&(s=ht(s)),e.caseSensitive||(s=s.toLowerCase()),s},U=(t,e)=>{const{matchPath:s}=e,x=((i,u)=>{const f=u.length>0?u.reduce((S,l)=>S==null?void 0:S[l],i):i;return typeof f!="string"?"":f})(t,s);return F(x,e)};function bt(t,e,s){const x=(o=>{const n={caseSensitive:!1,deburr:!0,matchPath:[],returnType:g.FIRST_CLOSEST_MATCH,thresholdType:p.SIMILARITY,trimSpaces:!0,...o};switch(n.thresholdType){case p.EDIT_DISTANCE:return{threshold:20,...n};case p.SIMILARITY:return{threshold:.4,...n};default:throw w}})(s),{returnType:i,threshold:u,thresholdType:f}=x,S=F(t,x);let l,b;switch(f){case p.EDIT_DISTANCE:l=o=>o<=u,b=o=>N(S,U(o,x));break;case p.SIMILARITY:l=o=>o>=u,b=o=>((n,r)=>{if(!n||!r)return 0;if(n===r)return 1;const c=N(n,r),h=Math.max(n.length,r.length);return(h-c)/h})(S,U(o,x));break;default:throw w}const d=[],T=e.length;switch(i){case g.ALL_CLOSEST_MATCHES:case g.FIRST_CLOSEST_MATCH:{const o=[];let n;switch(f){case p.EDIT_DISTANCE:n=1/0;for(let c=0;c<T;c+=1){const h=b(e[c]);n>h&&(n=h),o.push(h)}break;case p.SIMILARITY:n=0;for(let c=0;c<T;c+=1){const h=b(e[c]);n<h&&(n=h),o.push(h)}break;default:throw w}const r=o.length;for(let c=0;c<r;c+=1){const h=o[c];l(h)&&h===n&&d.push(c)}break}case g.ALL_MATCHES:for(let o=0;o<T;o+=1)l(b(e[o]))&&d.push(o);break;case g.ALL_SORTED_MATCHES:{const o=[];for(let n=0;n<T;n+=1){const r=b(e[n]);l(r)&&o.push({score:r,index:n})}switch(f){case p.EDIT_DISTANCE:o.sort((n,r)=>n.score-r.score);break;case p.SIMILARITY:o.sort((n,r)=>r.score-n.score);break;default:throw w}for(const n of o)d.push(n.index);break}case g.FIRST_MATCH:for(let o=0;o<T;o+=1)if(l(b(e[o]))){d.push(o);break}break;default:throw Y}return((o,n,r)=>{switch(r){case g.ALL_CLOSEST_MATCHES:case g.ALL_MATCHES:case g.ALL_SORTED_MATCHES:return n.map(c=>o[c]);case g.FIRST_CLOSEST_MATCH:case g.FIRST_MATCH:return n.length?o[n[0]]:null;default:throw Y}})(e,d,i)}var L={exports:{}};let dt=z,St=!("NO_COLOR"in process.env||process.argv.includes("--no-color"))&&("FORCE_COLOR"in process.env||process.argv.includes("--color")||process.platform==="win32"||dt.isatty(1)&&process.env.TERM!=="dumb"||"CI"in process.env),m=(t,e,s=t)=>x=>{let i=""+x,u=i.indexOf(e,t.length);return~u?t+G(i,e,s,u)+e:t+i+e},G=(t,e,s,x)=>{let i=t.substring(0,x)+s,u=t.substring(x+e.length),f=u.indexOf(e);return~f?i+G(u,e,s,f):i+u},P=(t=St)=>({isColorSupported:t,reset:t?e=>`\x1B[0m${e}\x1B[0m`:String,bold:t?m("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"):String,dim:t?m("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"):String,italic:t?m("\x1B[3m","\x1B[23m"):String,underline:t?m("\x1B[4m","\x1B[24m"):String,inverse:t?m("\x1B[7m","\x1B[27m"):String,hidden:t?m("\x1B[8m","\x1B[28m"):String,strikethrough:t?m("\x1B[9m","\x1B[29m"):String,black:t?m("\x1B[30m","\x1B[39m"):String,red:t?m("\x1B[31m","\x1B[39m"):String,green:t?m("\x1B[32m","\x1B[39m"):String,yellow:t?m("\x1B[33m","\x1B[39m"):String,blue:t?m("\x1B[34m","\x1B[39m"):String,magenta:t?m("\x1B[35m","\x1B[39m"):String,cyan:t?m("\x1B[36m","\x1B[39m"):String,white:t?m("\x1B[37m","\x1B[39m"):String,gray:t?m("\x1B[90m","\x1B[39m"):String,bgBlack:t?m("\x1B[40m","\x1B[49m"):String,bgRed:t?m("\x1B[41m","\x1B[49m"):String,bgGreen:t?m("\x1B[42m","\x1B[49m"):String,bgYellow:t?m("\x1B[43m","\x1B[49m"):String,bgBlue:t?m("\x1B[44m","\x1B[49m"):String,bgMagenta:t?m("\x1B[45m","\x1B[49m"):String,bgCyan:t?m("\x1B[46m","\x1B[49m"):String,bgWhite:t?m("\x1B[47m","\x1B[49m"):String});L.exports=P(),L.exports.createColors=P;const gt=t=>t.length<=1?t[0]:`${t.slice(0,-1).map(L.exports.bold).join(", ")} and ${L.exports.bold(t[t.length-1])}`,pt=()=>$({setup:t=>t.inspector({enforce:"pre",fn:(e,s)=>{const x=Object.keys(t._commands),i=!!x.length;try{s()}catch(u){if(!(u instanceof q||u instanceof R))throw u;if(e.raw._.length===0||u instanceof R){console.error("No command given."),i&&console.error(`Possible commands: ${gt(x)}.`);return}const f=u.commandName,S=bt(f,x);console.error(`Command "${L.exports.strikethrough(f)}" not found.`),i&&S?console.error(`Did you mean "${L.exports.bold(S)}"?`):i||console.error("NOTE: You haven't register any command yet."),process.stderr.write(` | ||
`),process.exit(2)}}})});export{pt as notFoundPlugin}; |
{ | ||
"name": "@clerc/plugin-not-found", | ||
"version": "0.25.1", | ||
"version": "0.26.0", | ||
"author": "Ray <nn_201312@163.com> (https://github.com/so1ve)", | ||
@@ -53,14 +53,12 @@ "description": "Clerc plugin not found (did you mean)", | ||
}, | ||
"dependencies": { | ||
"devDependencies": { | ||
"didyoumean2": "^5.0.0", | ||
"picocolors": "^1.0.0", | ||
"@clerc/utils": "0.25.1" | ||
"@clerc/core": "0.26.0", | ||
"@clerc/utils": "0.26.0" | ||
}, | ||
"devDependencies": { | ||
"@clerc/core": "0.25.1" | ||
}, | ||
"scripts": { | ||
"build": "puild", | ||
"build": "puild --minify", | ||
"watch": "puild --watch" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
20755
1
4
75
8
2
- Removed@clerc/utils@0.25.1
- Removeddidyoumean2@^5.0.0
- Removedpicocolors@^1.0.0
- Removed@babel/runtime@7.26.9(transitive)
- Removed@clerc/utils@0.25.1(transitive)
- Removeddidyoumean2@5.0.0(transitive)
- Removedfastest-levenshtein@1.0.16(transitive)
- Removedlodash.deburr@4.1.0(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedregenerator-runtime@0.14.1(transitive)
- Removedtype-fest@3.13.1(transitive)