@clerc/plugin-not-found 0.34.1 → 0.36.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/LICENSE +21 -21
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Ray <https://github.com/so1ve>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Ray <https://github.com/so1ve>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{definePlugin as z,NoSuchCommandError as q,NoCommandGivenError as N}from"@clerc/core";import
|
|
1
|
+
import{definePlugin as z,NoSuchCommandError as q,NoCommandGivenError as N}from"@clerc/core";import B from"tty";const Z={en:{"utils.and":"%s and %s"},"zh-CN":{"utils.and":"%s \u548C %s"}},$=(t,{add:e,t:u})=>(e(Z),t.length<=1?t[0]:u("utils.and",t.slice(0,-1).join(", "),t[t.length-1])),E=new Uint32Array(65536),J=(t,e)=>{const u=t.length,d=e.length,a=1<<u-1;let s=-1,l=0,b=u,c=u;for(;c--;)E[t.charCodeAt(c)]|=1<<c;for(c=0;c<d;c++){let f=E[e.charCodeAt(c)];const S=f|l;f|=(f&s)+s^s,l|=~(f|s),s&=f,l&a&&b++,s&a&&b--,l=l<<1|1,s=s<<1|~(S|l),l&=S}for(c=u;c--;)E[t.charCodeAt(c)]=0;return b},K=(t,e)=>{const u=e.length,d=t.length,a=[],s=[],l=Math.ceil(u/32),b=Math.ceil(d/32);for(let o=0;o<l;o++)s[o]=-1,a[o]=0;let c=0;for(;c<b-1;c++){let o=0,i=-1;const h=c*32,y=Math.min(32,d)+h;for(let x=h;x<y;x++)E[t.charCodeAt(x)]|=1<<x;for(let x=0;x<u;x++){const I=E[e.charCodeAt(x)],A=s[x/32|0]>>>x&1,T=a[x/32|0]>>>x&1,w=I|o,M=((I|T)&i)+i^i|I|T;let L=o|~(M|i),_=i&M;L>>>31^A&&(s[x/32|0]^=1<<x),_>>>31^T&&(a[x/32|0]^=1<<x),L=L<<1|A,_=_<<1|T,i=_|~(w|L),o=L&w}for(let x=h;x<y;x++)E[t.charCodeAt(x)]=0}let f=0,S=-1;const p=c*32,r=Math.min(32,d-p)+p;for(let o=p;o<r;o++)E[t.charCodeAt(o)]|=1<<o;let n=d;for(let o=0;o<u;o++){const i=E[e.charCodeAt(o)],h=s[o/32|0]>>>o&1,y=a[o/32|0]>>>o&1,x=i|f,I=((i|y)&S)+S^S|i|y;let A=f|~(I|S),T=S&I;n+=A>>>d-1&1,n-=T>>>d-1&1,A>>>31^h&&(s[o/32|0]^=1<<o),T>>>31^y&&(a[o/32|0]^=1<<o),A=A<<1|h,T=T<<1|y,S=T|~(x|A),f=A&x}for(let o=p;o<r;o++)E[t.charCodeAt(o)]=0;return n},R=(t,e)=>{if(t.length<e.length){const u=e;e=t,t=u}return e.length===0?t.length:t.length<=32?J(t,e):K(t,e)};var F=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},W=1/0,Q="[object Symbol]",V=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,X="\\u0300-\\u036f\\ufe20-\\ufe23",tt="\\u20d0-\\u20f0",et="["+X+tt+"]",ot=RegExp(et,"g"),rt={\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"},nt=typeof F=="object"&&F&&F.Object===Object&&F,ut=typeof self=="object"&&self&&self.Object===Object&&self,st=nt||ut||Function("return this")();function ct(t){return function(e){return t==null?void 0:t[e]}}var it=ct(rt),mt=Object.prototype,at=mt.toString,k=st.Symbol,D=k?k.prototype:void 0,H=D?D.toString:void 0;function lt(t){if(typeof t=="string")return t;if(dt(t))return H?H.call(t):"";var e=t+"";return e=="0"&&1/t==-W?"-0":e}function xt(t){return!!t&&typeof t=="object"}function dt(t){return typeof t=="symbol"||xt(t)&&at.call(t)==Q}function ft(t){return t==null?"":lt(t)}function ht(t){return t=ft(t),t&&t.replace(V,it).replace(ot,"")}var bt=ht;let g,C;(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"}(C||(C={}));const j=new Error("unknown returnType"),O=new Error("unknown thresholdType"),Y=(t,e)=>{let u=t;return e.trimSpaces&&(u=u.trim().replace(/\s+/g," ")),e.deburr&&(u=bt(u)),e.caseSensitive||(u=u.toLowerCase()),u},U=(t,e)=>{const{matchPath:u}=e,d=((a,s)=>{const l=s.length>0?s.reduce((b,c)=>b==null?void 0:b[c],a):a;return typeof l!="string"?"":l})(t,u);return Y(d,e)};function St(t,e,u){const d=(r=>{const n={caseSensitive:!1,deburr:!0,matchPath:[],returnType:g.FIRST_CLOSEST_MATCH,thresholdType:C.SIMILARITY,trimSpaces:!0,...r};switch(n.thresholdType){case C.EDIT_DISTANCE:return{threshold:20,...n};case C.SIMILARITY:return{threshold:.4,...n};default:throw O}})(u),{returnType:a,threshold:s,thresholdType:l}=d,b=Y(t,d);let c,f;switch(l){case C.EDIT_DISTANCE:c=r=>r<=s,f=r=>R(b,U(r,d));break;case C.SIMILARITY:c=r=>r>=s,f=r=>((n,o)=>{if(!n||!o)return 0;if(n===o)return 1;const i=R(n,o),h=Math.max(n.length,o.length);return(h-i)/h})(b,U(r,d));break;default:throw O}const S=[],p=e.length;switch(a){case g.ALL_CLOSEST_MATCHES:case g.FIRST_CLOSEST_MATCH:{const r=[];let n;switch(l){case C.EDIT_DISTANCE:n=1/0;for(let i=0;i<p;i+=1){const h=f(e[i]);n>h&&(n=h),r.push(h)}break;case C.SIMILARITY:n=0;for(let i=0;i<p;i+=1){const h=f(e[i]);n<h&&(n=h),r.push(h)}break;default:throw O}const o=r.length;for(let i=0;i<o;i+=1){const h=r[i];c(h)&&h===n&&S.push(i)}break}case g.ALL_MATCHES:for(let r=0;r<p;r+=1)c(f(e[r]))&&S.push(r);break;case g.ALL_SORTED_MATCHES:{const r=[];for(let n=0;n<p;n+=1){const o=f(e[n]);c(o)&&r.push({score:o,index:n})}switch(l){case C.EDIT_DISTANCE:r.sort((n,o)=>n.score-o.score);break;case C.SIMILARITY:r.sort((n,o)=>o.score-n.score);break;default:throw O}for(const n of r)S.push(n.index);break}case g.FIRST_MATCH:for(let r=0;r<p;r+=1)if(c(f(e[r]))){S.push(r);break}break;default:throw j}return((r,n,o)=>{switch(o){case g.ALL_CLOSEST_MATCHES:case g.ALL_MATCHES:case g.ALL_SORTED_MATCHES:return n.map(i=>r[i]);case g.FIRST_CLOSEST_MATCH:case g.FIRST_MATCH:return n.length?r[n[0]]:null;default:throw j}})(e,S,a)}var v={exports:{}};let gt=B,Ct=!("NO_COLOR"in process.env||process.argv.includes("--no-color"))&&("FORCE_COLOR"in process.env||process.argv.includes("--color")||process.platform==="win32"||gt.isatty(1)&&process.env.TERM!=="dumb"||"CI"in process.env),m=(t,e,u=t)=>d=>{let a=""+d,s=a.indexOf(e,t.length);return~s?t+G(a,e,u,s)+e:t+a+e},G=(t,e,u,d)=>{let a=t.substring(0,d)+u,s=t.substring(d+e.length),l=s.indexOf(e);return~l?a+G(s,e,u,l):a+s},P=(t=Ct)=>({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});v.exports=P(),v.exports.createColors=P;const pt={en:{"notFound.possibleCommands":"Possible commands: %s.","notFound.commandNotFound":'Command "%s" not found.',"notFound.didyoumean":'Did you mean "%s"?',"notFound.commandNotRegisteredNote":"NOTE: You haven't register any command yet."},"zh-CN":{"notFound.possibleCommands":"\u53EF\u80FD\u7684\u547D\u4EE4: %s\u3002","notFound.commandNotFound":'\u672A\u627E\u5230\u547D\u4EE4 "%s"\u3002',"notFound.didyoumean":'\u4F60\u662F\u4E0D\u662F\u6307 "%s"\uFF1F',"notFound.commandNotRegisteredNote":"\u63D0\u793A: \u4F60\u8FD8\u6CA1\u6709\u6CE8\u518C\u4EFB\u4F55\u547D\u4EE4\u3002"}},Tt=()=>z({setup:t=>{const{t:e,add:u}=t.i18n;return u(pt),t.inspector({enforce:"pre",fn:(d,a)=>{const s=Object.keys(t._commands),l=!!s.length;try{a()}catch(b){if(!(b instanceof q||b instanceof N))throw b;if(d.raw._.length===0||b instanceof N){console.error(e("core.noCommandGiven")),l&&console.error(e("notFound.possibleCommands",$(s,t.i18n)));return}const c=b.commandName,f=St(c,s);console.error(e("notFound.commandNotFound",v.exports.strikethrough(c))),l&&f?console.error(e("notFound.didyoumean",v.exports.bold(f))):l||console.error(e("notFound.commandNotRegisteredNote")),process.stderr.write(`
|
|
2
2
|
`),process.exit(2)}}})}});export{Tt as notFoundPlugin};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/plugin-not-found",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"author": "Ray <i@mk1.io> (https://github.com/so1ve)",
|
|
5
5
|
"description": "Clerc plugin not found (did you mean)",
|
|
6
6
|
"keywords": [
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"didyoumean2": "^5.0.0",
|
|
55
55
|
"picocolors": "^1.0.0",
|
|
56
|
-
"@clerc/core": "0.
|
|
57
|
-
"@clerc/utils": "0.
|
|
56
|
+
"@clerc/core": "0.36.0",
|
|
57
|
+
"@clerc/utils": "0.36.0"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "puild --minify",
|