@shopify/cli
Version:
A CLI tool to build for the Shopify platform
17 lines (10 loc) • 3.67 kB
JavaScript
import{b as C}from"./chunk-MHWV5RQV.js";import{b as f}from"./chunk-XOTA6JTZ.js";import{A as S,u as i,y as x}from"./chunk-6G6TMKXF.js";import{d as v}from"./chunk-M56NDIMD.js";import{Qb as I}from"./chunk-N5PQPIBF.js";import{g as a}from"./chunk-VPRTJUIN.js";a();a();a();var m={on:"Autocorrect on. The system will automatically run commands even when you mistype them.",off:"Autocorrect off. You'll need to confirm corrections for mistyped commands."};a();function p(o=W()){return!!o.get("autocorrectEnabled")}function y(o,n=W()){n.set("autocorrectEnabled",o)}function W(){return b??(b=new C({projectName:"did-you-mean"})),b}var b;var A,s=class extends f{async run(){y(!0),i({body:m.on})}};A=s;s.summary="Enable autocorrect. Off by default.";s.descriptionWithMarkdown=`Enable autocorrect. Off by default.
When autocorrection is enabled, Shopify CLI automatically runs a corrected version of your command if a correction is available.
When autocorrection is disabled, you need to confirm that you want to run corrections for mistyped commands.
`;s.description=A.descriptionWithoutMarkdown();var E=s;a();var k,u=class extends f{async run(){y(!1),i({body:m.off})}};k=u;u.summary="Disable autocorrect. Off by default.";u.descriptionWithMarkdown=`Disable autocorrect. Off by default.
When autocorrection is enabled, Shopify CLI automatically runs a corrected version of your command if a correction is available.
When autocorrection is disabled, you need to confirm that you want to run corrections for mistyped commands.
`;u.description=k.descriptionWithoutMarkdown();var D=u;a();var M,d=class extends f{async run(){p()?i({body:m.on}):i({body:m.off})}};M=d;d.summary="Check whether autocorrect is enabled or disabled. On by default.";d.descriptionWithMarkdown=`Check whether autocorrect is enabled or disabled. On by default.
When autocorrection is enabled, Shopify CLI automatically runs a corrected version of your command if a correction is available.
When autocorrection is disabled, you need to confirm that you want to run corrections for mistyped commands.
`;d.description=M.descriptionWithoutMarkdown();var N=d;a();var g=O(2),ao=O(3);function O(o){if(typeof o!="number"||Number.isNaN(o)||o<1||o===Number.POSITIVE_INFINITY)throw new Error("`"+o+"` is not a valid argument for `n-gram`");return n;function n(t){let c=[];if(t==null)return c;let e=typeof t.slice=="function"?t:String(t),r=e.length-o+1;if(r<1)return c;for(;r--;)c[r]=e.slice(r,r+o);return c}}function h(o){return o.replace(/:/g," ")}function F(o,n){let t={};o.forEach(e=>{t[e]=t[e]?t[e]+1:1});let c=[];for(let e of n)e in t&&t[e]>0&&(c.push(e),t[e]=t[e]-1);return c.length}function L(o){if(o.id.length<2)return;let n=new Set(o.config.commands.filter(r=>r.hidden).map(r=>r.id)),t=Array.from(new Set([...o.config.commandIDs,...o.config.commands.flatMap(r=>r.aliases)].filter(r=>!n.has(r)))),c=g(o.id),e=t.map(r=>{let l=g(r);return{score:F(l,c),cmd:r}}).filter(({score:r})=>r>=2).sort((r,l)=>{let w=l.score-r.score;return w!==0?w:r.cmd.length-l.cmd.length});if(I(`'Did you mean' options: ${JSON.stringify(e)}`),e.length>0){let{cmd:r}=e[0];return r}}async function Y(o,n){return p()?(i({body:["Autocorrecting",{command:h(n)},"to",{command:h(o)},{char:"."}]}),!0):S({message:["Command",{command:n},"not found. Did you mean",{command:h(o)},{char:"?"}]})}var bo={"config:autocorrect:off":D,"config:autocorrect:status":N,"config:autocorrect:on":E},go=async function(o){let n=L(o),t=h(o.id);if(o.argv&&(o.argv.includes("-f")||o.argv.includes("--force"))||!n){x(new v(`Command '${t}' not found.`));return}await Y(n,t)&&await this.config.runCommand(n,o.argv)};export{L as a,Y as b,bo as c,go as d};