New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More β†’
Socket
Sign inDemoInstall
Socket

gitzy

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitzy - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

44

dist/index.js
#!/usr/bin/env node
"use strict";var c=require("ansi-colors"),E=require("commander"),se=require("enquirer"),re=require("lilconfig"),oe=require("yaml"),_=require("child_process"),mt=require("module"),ne=require("path"),ie=require("fs"),ae=require("os");function v(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ce=v(se),ue=v(oe),w=v(ne),$=v(ie),le=v(ae);const de={chore:{description:"Other changes that don't modify src or test files",emoji:"\u{1F916}"},ci:{description:"Changes to CI configuration files and scripts",emoji:"\u{1F477}"},docs:{description:"Add or update documentation",emoji:"\u{1F4DD}"},feat:{description:"A new feature",emoji:"\u2728"},fix:{description:"Fix a bug",emoji:"\u{1F41B}"},perf:{description:"Improve performance",emoji:"\u26A1\uFE0F"},refactor:{description:"Refactor code",emoji:"\u267B\uFE0F"},release:{description:"Deploy stuff",emoji:"\u{1F680}"},revert:{description:"Revert changes",emoji:"\u23EA"},style:{description:"Improve structure / format of the code",emoji:"\u{1F3A8}"},test:{description:"Add or update tests",emoji:"\u2705"}},pe={body:"",breaking:"",issues:"",scope:"",subject:"",type:""},M=["type","scope","subject","body","breaking","issues"],k={breakingChangeEmoji:"\u{1F4A5}",closedIssueEmoji:"\u{1F3C1}",details:de,disableEmoji:!1,headerMaxLength:64,headerMinLength:3,issuesHint:"#123",issuesPrefix:"closes",questions:M,scopes:[],types:["chore","docs","feat","fix","refactor","test","style","ci","perf","revert","release"],useCommitlintConfig:!1},h=e=>`skip "${e}" question and provide your own "${e}" message`,u={description:"interactive conventional commits cli",examples:`
"use strict";var c=require("ansi-colors"),j=require("commander"),te=require("enquirer"),x=require("node:child_process"),at=require("module"),E=require("node:path"),v=require("node:fs"),se=require("node:os"),re=require("lilconfig"),oe=require("yaml"),ct=typeof document!="undefined"?document.currentScript:null;const ne=e=>Object.entries(e).reduce((t,[s,r])=>(r==null||(t[s]=r),t),{}),k=72,ie=e=>e.replace(/"/g,'\\"').replace(/`/g,"\\`"),ae=(e,{disableEmoji:t,breakingChangeEmoji:s})=>e?`
BREAKING CHANGE: ${t?"":`${s} `}${e}`:"",ce=(e,{disableEmoji:t,closedIssueEmoji:s})=>e?`
${t?"":`${s} `}Closes: ${e}`:"",ue=e=>e&&e!=="none"?`(${e})`:"",le=(e,t=k)=>{const s=new RegExp(`(?![^\\n]{1,${t}}$)([^\\n]{1,${t}})\\s`,"g");return e.replace(s,`$1
`)},pe=(e,t,s)=>{const o=!e.disableEmoji&&e.details[t.type].emoji&&s?`${e.details[t.type].emoji} `:"",n=ue(t.scope),a=`${t.type+n}: ${o}${t.subject}`,i=t.body.trim()?`
${t.body}`:"",p=ae(t.breaking,e),b=ce(t.issues,e),h=e.headerMaxLength>k?e.headerMaxLength:k;return ie(le(`${a}${i}${p}${b}`,h))},C=e=>c.blue(`\u276F ${e}`),_=e=>c.yellow(`\u276F ${e}`),O=e=>c.red(`\u276F ${e}`),m=e=>{console.log(e)},de=(e,t=[],s=process.env)=>{x.spawn(e,t,{env:s,shell:!0,stdio:[0,1,2]}).on("close",o=>{o&&process.exit(o)})},me=e=>{m(C("Message...")),m(`
${e}
`)},ge=({config:e,answers:t},{passthrough:s=[],dryRun:r=!1,emoji:o=!0})=>{const n=pe(e,t,o);r?me(n):de("git",["commit","-m",`"${n}"`,...s])},z=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),he=e=>{const t=e.split("").map(z).reduce((s,r)=>`${s}[^${r}]*${z(r)}`);return new RegExp(t)},ye=(e,t)=>he(t).test(String(e)),fe=(e,t,s)=>e.filter(r=>ye(r[s],t)).sort(r=>r[s]===t?-1:1),M=(e,t,s)=>Promise.resolve(t?fe(e,t,s):e),be=()=>new Promise((e,t)=>{x.exec("git --no-pager diff --cached --quiet --exit-code",s=>{s&&e(""),t(new Error(`No files staged
${_('You can use "gitzy -p -a" to replicate git -am')}`))})}),ve=()=>new Promise((e,t)=>{x.exec("git rev-parse --is-inside-work-tree",s=>{s&&t(new Error(`Not a git repository
${_('You can try running "git init"')}`)),e("")})}),$e=(e=[])=>!["--add","-a","--amend"].some(t=>e.includes(t));var je=require;const R=()=>je(E.join(__dirname,"..","package.json")),Ee=e=>{try{return v.statSync(e)}catch(t){return null}},we=(e,t)=>{if(t.message.includes("null bytes"))throw new Error;if(!(["EEXIST","EISDIR","EPERM"].includes(t.code)&&E.dirname(e)!==e))throw new Error},xe=(e,t=!0)=>{const s=Ee(e);if(s){if(t&&!s.isDirectory())throw new Error(`Path exists and is not a directory: "${e}"`);return!0}return!1},ke=e=>{if(!xe(e))try{v.mkdirSync(e,{recursive:!0})}catch(t){we(e,t)}},Ce=e=>{try{v.unlinkSync(e)}catch(t){const s=t;if(s.code!=="ENOENT")throw new Error(s.message)}},_e=()=>`${se.tmpdir}/gitzy/${E.basename(process.cwd())}-store.json`,w=Symbol("gitzy");class Oe{constructor(){this.readParseFile=()=>JSON.parse(String(v.readFileSync(this.path))),this.tryLoad=()=>{try{return this[w]=this.readParseFile()}catch(t){const s=t,r=s.code==="EACCES",o=s.code==="ENOENT"||s.name==="SyntaxError";if(r)throw new Error("gitzy does not have permission to load this file");return o?(this[w]={},{}):{}}},this.json=()=>JSON.stringify(this.data,null,2),this.writeFile=()=>{ke(E.dirname(String(this.path))),v.writeFileSync(this.path,this.json(),{mode:384})},this.destroy=()=>{Ce(this.path)},this.clear=()=>{this.save({})},this.load=()=>this.data,this.path=_e()}get data(){var t;return(t=this[w])!=null?t:this.tryLoad()}save(t){this[w]=t,this.writeFile()}}const P=(e,t)=>oe.parse(t),T=e=>[`.${e}rc`,`.${e}rc.json`,`.${e}rc.yaml`,`.${e}rc.yml`,`.${e}rc.js`,`.${e}rc.cjs`,`${e}.config.js`,`${e}.config.cjs`],Pe=e=>["package.json",...T(e),...T(e).map(t=>`.config/${t}`)],N=async e=>re.lilconfig(e,{searchPlaces:Pe(e),loaders:{".yaml":P,".yml":P,noExt:P}}).search(process.cwd()),D=["close","closes","closed","fix","fixes","fixed","resolve","resolves","resolved"],l={breakingChangeEmoji:"breakingChangeEmoji must be a string",closedIssueEmoji:"closedIssueEmoji must be a string",details:'details must look like "{ description: "A new feature", emoji: "\u2728" }"',disableEmoji:"disableEmoji must be a boolean",headerMaxLength:"headerMaxLength must be a number",headerMinLength:"headerMinLength must be a number",issuesHint:"issuesHint must be a string",issuesPrefix:`issuesPrefix must be one of ${D.join(", ")}`,questions:"questions must be an array of strings",scopes:"scopes must be an array of strings",types:"types must be an array of strings",useCommitlintConfig:"useCommitlintConfig must be a boolean"},Se={body:"",breaking:"",issues:"",scope:"",subject:"",type:""},Ie={chore:{description:"Other changes that don't modify src or test files",emoji:"\u{1F916}"},ci:{description:"Changes to CI configuration files and scripts",emoji:"\u{1F477}"},docs:{description:"Add or update documentation",emoji:"\u{1F4DD}"},feat:{description:"A new feature",emoji:"\u2728"},fix:{description:"Fix a bug",emoji:"\u{1F41B}"},perf:{description:"Improve performance",emoji:"\u26A1\uFE0F"},refactor:{description:"Refactor code",emoji:"\u267B\uFE0F"},release:{description:"Deploy stuff",emoji:"\u{1F680}"},revert:{description:"Revert changes",emoji:"\u23EA"},style:{description:"Improve structure / format of the code",emoji:"\u{1F3A8}"},test:{description:"Add or update tests",emoji:"\u2705"}},H=["type","scope","subject","body","breaking","issues"],S={breakingChangeEmoji:"\u{1F4A5}",closedIssueEmoji:"\u{1F3C1}",details:Ie,disableEmoji:!1,headerMaxLength:64,headerMinLength:3,issuesHint:"#123",issuesPrefix:"closes",questions:H,scopes:[],types:["chore","docs","feat","fix","refactor","test","style","ci","perf","revert","release"],useCommitlintConfig:!1},G=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),g=e=>typeof e=="string",V=e=>typeof e=="boolean",B=e=>typeof e=="number",I=e=>typeof e=="object",q=e=>Array.isArray(e)&&e.every(g),qe=e=>I(e)&&Object.values(e).every(t=>{const s=t;return I(s)&&G(s,"description")&&G(s,"emoji")&&Object.values(s).every(g)}),Le=e=>g(e)&&D.includes(e),Ae=e=>{const t=Object.keys(S);return Object.keys(e).some(s=>!t.includes(s))},Fe={breakingChangeEmoji:e=>g(e)||l.breakingChangeEmoji,closedIssueEmoji:e=>g(e)||l.closedIssueEmoji,details:e=>qe(e)||l.details,disableEmoji:e=>V(e)||l.disableEmoji,headerMaxLength:e=>B(e)||l.headerMaxLength,headerMinLength:e=>B(e)||l.headerMinLength,issuesHint:e=>g(e)||l.issuesHint,issuesPrefix:e=>Le(e)||l.issuesPrefix,questions:e=>q(e)||l.questions,scopes:e=>q(e)||l.scopes,types:e=>q(e)||l.types,useCommitlintConfig:e=>V(e)||l.useCommitlintConfig},ze=e=>I(e)?e&&Ae(e)?"unknown or additional properties detected":Object.entries(e).map(([t,s])=>Fe[t](s))[0]:"invalid configuration",U=async e=>{const t=await Promise.resolve(ze(e));if(g(t))throw new Error(t);return t},Me=e=>{var t,s,r,o,n,a,i,p;return ne({headerMaxLength:(s=(t=e.rules)==null?void 0:t["header-max-length"])==null?void 0:s[2],headerMinLength:(o=(r=e.rules)==null?void 0:r["header-min-length"])==null?void 0:o[2],scopes:(a=(n=e.rules)==null?void 0:n["scope-enum"])==null?void 0:a[2],types:(p=(i=e.rules)==null?void 0:i["type-enum"])==null?void 0:p[2]})},K=async()=>{const e=await N("commitlint");if(e){const t=Me(e.config);return await U(t)?t:null}return null};var Re=Object.defineProperty,Y=Object.getOwnPropertySymbols,Te=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable,J=(e,t,s)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,L=(e,t)=>{for(var s in t||(t={}))Te.call(t,s)&&J(e,s,t[s]);if(Y)for(var s of Y(t))Ne.call(t,s)&&J(e,s,t[s]);return e};const De=async e=>{const t=await N("gitzy");if(e&&!t)return K();if(t&&await U(t.config)){if(t.config.useCommitlintConfig||e){const r=await K();return L(L({},t.config),r)}return L({},t.config)}return null},y=e=>`skip "${e}" question and provide your own "${e}" message`,u={description:"interactive conventional commits cli",examples:`
$ gitzy

@@ -7,25 +18,14 @@ $ gitzy -p -a

$ gitzy -lD --no-emoji
`,flags:{get body(){return h("body")},get breaking(){return h("breaking")},commitlint:"leverage commitlint's configuration",get dryRun(){return"displays git message but does not commit"},get issues(){return h("issues")},noEmoji:"disable all emojis",passthrough:'subsequent command line args passed through to "git"',retry:"retries previous commit, skips all prompts",get scope(){return h("scope")},skip:"skip questions",get subject(){return h("subject")},get type(){return h("type")}}},me={get skip(){const e=new E.Option("-S, --skip <questions...>",u.flags.skip);return e.variadic=!0,e.choices(M),e}},C=(e,t)=>ue.default.parse(t),R=e=>[`.${e}rc`,`.${e}rc.json`,`.${e}rc.yaml`,`.${e}rc.yml`,`.${e}rc.js`,`.${e}rc.cjs`,`${e}.config.js`,`${e}.config.cjs`],ge=e=>["package.json",...R(e),...R(e).map(t=>`.config/${t}`)],T=async e=>re.lilconfig(e,{searchPlaces:ge(e),loaders:{".yaml":C,".yml":C,noExt:C}}).search(process.cwd()),N=["close","closes","closed","fix","fixes","fixed","resolve","resolves","resolved"],l={breakingChangeEmoji:"breakingChangeEmoji must be a string",closedIssueEmoji:"closedIssueEmoji must be a string",details:'details must look like "{ description: "A new feature", emoji: "\u2728" }"',disableEmoji:"disableEmoji must be a boolean",headerMaxLength:"headerMaxLength must be a number",headerMinLength:"headerMinLength must be a number",issuesHint:"issuesHint must be a string",issuesPrefix:`issuesPrefix must be one of ${N.join(", ")}`,questions:"questions must be an array of strings",scopes:"scopes must be an array of strings",types:"types must be an array of strings",useCommitlintConfig:"useCommitlintConfig must be a boolean"},D=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),m=e=>typeof e=="string",H=e=>typeof e=="boolean",G=e=>typeof e=="number",O=e=>typeof e=="object",P=e=>Array.isArray(e)&&e.every(m),fe=e=>O(e)&&Object.values(e).every(t=>{const s=t;return O(s)&&D(s,"description")&&D(s,"emoji")&&Object.values(s).every(m)}),he=e=>m(e)&&N.includes(e),ye=e=>{const t=Object.keys(k);return Object.keys(e).some(s=>!t.includes(s))},be={breakingChangeEmoji:e=>m(e)||l.breakingChangeEmoji,closedIssueEmoji:e=>m(e)||l.closedIssueEmoji,details:e=>fe(e)||l.details,disableEmoji:e=>H(e)||l.disableEmoji,headerMaxLength:e=>G(e)||l.headerMaxLength,headerMinLength:e=>G(e)||l.headerMinLength,issuesHint:e=>m(e)||l.issuesHint,issuesPrefix:e=>he(e)||l.issuesPrefix,questions:e=>P(e)||l.questions,scopes:e=>P(e)||l.scopes,types:e=>P(e)||l.types,useCommitlintConfig:e=>H(e)||l.useCommitlintConfig},ve=e=>O(e)?e&&ye(e)?"unknown or additional properties detected":Object.entries(e).map(([t,s])=>be[t](s))[0]:"invalid configuration",V=async e=>{const t=await Promise.resolve(ve(e));if(m(t))throw new Error(t);return t},S=72,$e=e=>e.replace(/"/g,'\\"').replace(/`/g,"\\`"),je=(e,{disableEmoji:t,breakingChangeEmoji:s})=>e?`
BREAKING CHANGE: ${t?"":`${s} `}${e}`:"",Ee=(e,{disableEmoji:t,closedIssueEmoji:s})=>e?`
${t?"":`${s} `}Closes: ${e}`:"",we=e=>e&&e!=="none"?`(${e})`:"",xe=(e,t=S)=>{const s=new RegExp(`(?![^\\n]{1,${t}}$)([^\\n]{1,${t}})\\s`,"g");return e.replace(s,`$1
`)},_e=(e,t,s)=>{const o=!e.disableEmoji&&e.details[t.type].emoji&&s?`${e.details[t.type].emoji} `:"",n=we(t.scope),a=`${t.type+n}: ${o}${t.subject}`,i=t.body.trim()?`
${t.body}`:"",d=je(t.breaking,e),b=Ee(t.issues,e),f=e.headerMaxLength>S?e.headerMaxLength:S;return $e(xe(`${a}${i}${d}${b}`,f))},q=e=>c.blue(`\u276F ${e}`),I=e=>c.yellow(`\u276F ${e}`),L=e=>c.red(`\u276F ${e}`),g=e=>{console.log(e)},ke=(e,t=[],s=process.env)=>{_.spawn(e,t,{env:s,shell:!0,stdio:[0,1,2]}).on("close",o=>{o&&process.exit(o)})},Ce=e=>{g(q("Message...")),g(`
${e}
`)},Oe=({config:e,answers:t},{passthrough:s=[],dryRun:r=!1,emoji:o=!0})=>{const n=_e(e,t,o);r?Ce(n):ke("git",["commit","-m",`"${n}"`,...s])},Pe=e=>Object.entries(e).reduce((t,[s,r])=>(r==null||(t[s]=r),t),{}),Se=()=>new Promise((e,t)=>{_.exec("git --no-pager diff --cached --quiet --exit-code",s=>{s&&e(""),t(new Error(`No files staged
${I('You can use "gitzy -p -a" to replicate git -am')}`))})}),qe=()=>new Promise((e,t)=>{_.exec("git rev-parse --is-inside-work-tree",s=>{s&&t(new Error(`Not a git repository
${I('You can try running "git init"')}`)),e("")})}),Ie=(e=[])=>!["--add","-a","--amend"].some(t=>e.includes(t)),B=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Le=e=>{const t=e.split("").map(B).reduce((s,r)=>`${s}[^${r}]*${B(r)}`);return new RegExp(t)},Ae=(e,t)=>Le(t).test(String(e)),ze=(e,t,s)=>e.filter(r=>Ae(r[s],t)).sort(r=>r[s]===t?-1:1),U=(e,t,s)=>Promise.resolve(t?ze(e,t,s):e);var Fe=require;const K=()=>Fe(w.default.join(__dirname,"..","package.json")),Me=e=>{try{return $.default.statSync(e)}catch(t){return null}},Re=(e,t)=>{if(t.message.includes("null bytes"))throw new Error;if(!(["EEXIST","EISDIR","EPERM"].includes(t.code)&&w.default.dirname(e)!==e))throw new Error},Te=(e,t=!0)=>{const s=Me(e);if(s){if(t&&!s.isDirectory())throw new Error(`Path exists and is not a directory: "${e}"`);return!0}return!1},Ne=e=>{if(!Te(e))try{$.default.mkdirSync(e,{recursive:!0})}catch(t){Re(e,t)}},De=e=>{try{$.default.unlinkSync(e)}catch(t){const s=t;if(s.code!=="ENOENT")throw new Error(s.message)}},He=()=>`${le.default.tmpdir}/gitzy/${w.default.basename(process.cwd())}-store.json`,x=Symbol("gitzy");class Ge{constructor(){this.readParseFile=()=>JSON.parse(String($.default.readFileSync(this.path))),this.tryLoad=()=>{try{return this[x]=this.readParseFile()}catch(t){const s=t,r=s.code==="EACCES",o=s.code==="ENOENT"||s.name==="SyntaxError";if(r)throw new Error("gitzy does not have permission to load this file");return o?(this[x]={},{}):{}}},this.json=()=>JSON.stringify(this.data,null,2),this.writeFile=()=>{Ne(w.default.dirname(String(this.path))),$.default.writeFileSync(this.path,this.json(),{mode:384})},this.destroy=()=>{De(this.path)},this.clear=()=>{this.save({})},this.load=()=>this.data,this.path=He()}get data(){var t;return(t=this[x])!=null?t:this.tryLoad()}save(t){this[x]=t,this.writeFile()}}const Ve=e=>{var t,s,r,o,n,a,i,d;return Pe({headerMaxLength:(s=(t=e.rules)==null?void 0:t["header-max-length"])==null?void 0:s[2],headerMinLength:(o=(r=e.rules)==null?void 0:r["header-min-length"])==null?void 0:o[2],scopes:(a=(n=e.rules)==null?void 0:n["scope-enum"])==null?void 0:a[2],types:(d=(i=e.rules)==null?void 0:i["type-enum"])==null?void 0:d[2]})},Y=async()=>{const e=await T("commitlint");if(e){const t=Ve(e.config);return await V(t)?t:null}return null};var Be=Object.defineProperty,J=Object.getOwnPropertySymbols,Ue=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable,Q=(e,t,s)=>t in e?Be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,A=(e,t)=>{for(var s in t||(t={}))Ue.call(t,s)&&Q(e,s,t[s]);if(J)for(var s of J(t))Ke.call(t,s)&&Q(e,s,t[s]);return e};const Ye=async e=>{const t=await T("gitzy");if(e&&!t)return Y();if(t&&await V(t.config)){if(t.config.useCommitlintConfig||e){const r=await Y();return A(A({},t.config),r)}return A({},t.config)}return null},Je=c.red("BREAKING CHANGE:"),Qe=e=>c.reset(`${e}:`),p={body:{hint:"...supports multi line, press enter to go to next line",message:`Add a longer description
`,flags:{get body(){return y("body")},get breaking(){return y("breaking")},commitlint:"leverage commitlint's configuration",get dryRun(){return"displays git message but does not commit"},get issues(){return y("issues")},noEmoji:"disable all emojis",passthrough:'subsequent command line args passed through to "git"',retry:"retries previous commit, skips all prompts",get scope(){return y("scope")},skip:"skip questions",get subject(){return y("subject")},get type(){return y("type")}}},He=c.red("BREAKING CHANGE:"),Ge=e=>c.reset(`${e}:`),d={body:{hint:"...supports multi line, press enter to go to next line",message:`Add a longer description
`},breaking:{hint:c.dim("...skip when none"),message:`${c.bold("Add any breaking changes")}
${Je}`},scope:{hint:c.dim("...type or use arrow keys"),message:"Choose the scope"},subject:{message:"Add a short description"},type:{hint:c.dim("...type or use arrow keys"),message:"Choose the type"}},Xe=e=>`${c.bold("Add issues this commit closes")}
${Qe(e)}`,X={minTitleLength:e=>`The subject must have at least ${e} characters`,maxTitleLength:e=>`The subject must be less than ${e} characters`},We=()=>({format:e=>e.trim(),hint:p.body.hint,message:p.body.message,multiline:!0,name:"body",type:"text"}),Ze=()=>({hint:p.breaking.hint,message:p.breaking.message,name:"breaking",type:"text"}),et=({config:{issuesHint:e,issuesPrefix:t}})=>({hint:e,message:Xe(t),name:"issues",type:"text"}),tt=({config:{scopes:e}})=>{const t=e.map(s=>({indent:" ",title:s,value:s}));return e.length>0?{choices:t,hint:p.scope.hint,limit:10,message:p.scope.message,name:"scope",suggest:s=>U(t,s,"title"),type:"autocomplete"}:null},W=e=>{const t=e!=null&&e.scope&&e.scope!=="none"?`(${e.scope})`:"";return e!=null&&e.type?`${e.type}${t}: `:""},st=({config:{headerMinLength:e,headerMaxLength:t,disableEmoji:s}})=>{const r=X.minTitleLength(e),o=X.maxTitleLength(t),{subject:{message:n}}=p,a=s?0:3;return{message:i=>{const d=()=>{const b=W(i==null?void 0:i.answers),f=i?i.input.length:0,z=t-f-b.length-a,F=z/t*100,j=`${z}/${t}`;return f<e?c.red(j):F>25?c.green(j):F<0?c.red(j):c.yellow(j)};return c.bold(`${n}(${d()})`)},name:"subject",type:"input",validate:(i,d)=>{const b=W(d==null?void 0:d.answers),f=i.length+b.length+a>t;return i.length<e?r:f?o:!0}}},rt=({details:e,disableEmoji:t},s,r)=>{const{[s]:{description:o,emoji:n}}=e,a=n&&!t&&(r==null?void 0:r.emoji),i=a?`${n} `:"";return{title:`${s==="refactor"&&a?`${i} `:i}${s}:`,hint:o.toLowerCase(),indent:" ",value:s}},ot=({config:e,flags:t})=>{const s=e.types.map(r=>rt(e,r,t));return{choices:s,hint:p.type.hint,limit:10,message:p.type.message,name:"type",suggest:r=>U(s,r,"title"),type:"autocomplete"}},nt={body:We,breaking:Ze,issues:et,scope:tt,subject:st,type:ot},it=e=>e!=null,at=({config:e,answers:t},s)=>e.questions.filter(r=>{var o;return k.questions.includes(r)&&!((o=s.skip)!=null&&o.includes(r))}).map(r=>nt[r]({config:e,answers:t,flags:s})).filter(it);var ct=Object.defineProperty,Z=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,lt=Object.prototype.propertyIsEnumerable,ee=(e,t,s)=>t in e?ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,y=(e,t)=>{for(var s in t||(t={}))ut.call(t,s)&&ee(e,s,t[s]);if(Z)for(var s of Z(t))lt.call(t,s)&&ee(e,s,t[s]);return e};const dt={autofill:!0,cancel:()=>null,styles:{submitted:c.cyan,danger:c.red}},pt=async()=>{const e={config:k,answers:pe},t=new Ge,s=async({passthrough:o,commitlint:n,dryRun:a})=>{const i=await Ye(n);i&&(e.config=y(y({},e.config),i)),Ie(o)&&!a&&(await qe(),await Se())},r=async o=>{const n=new ce.default(dt,o),a=at(e,o);return n.prompt(a)};E.program.configureOutput({writeErr:o=>process.stdout.write(o.replace("error: ","")),outputError:(o,n)=>{n(`
${L(o)}
`)}}).version(K().version,"-v, --version").description(u.description).option("-d, --body <body>",u.flags.body).option("-b, --breaking <breaking>",u.flags.breaking).option("-D, --dry-run",u.flags.dryRun).option("-i, --issues <body>",u.flags.issues).option("-p, --passthrough <flags...>",u.flags.passthrough).option("-s, --scope <scope>",u.flags.scope).option("-m, --subject <message>",u.flags.subject).option("-t, --type <type>",u.flags.type).option("-l, --commitlint",u.flags.commitlint).option("-r, --retry",u.flags.retry).option("--no-emoji",u.flags.noEmoji).addOption(me.skip).addHelpText("after",`
${He}`},scope:{hint:c.dim("...type or use arrow keys"),message:"Choose the scope"},subject:{message:"Add a short description"},type:{hint:c.dim("...type or use arrow keys"),message:"Choose the type"}},Ve=e=>`${c.bold("Add issues this commit closes")}
${Ge(e)}`,Q={minTitleLength:e=>`The subject must have at least ${e} characters`,maxTitleLength:e=>`The subject must be less than ${e} characters`},Be=()=>({format:e=>e.trim(),hint:d.body.hint,message:d.body.message,multiline:!0,name:"body",type:"text"}),Ue=()=>({hint:d.breaking.hint,message:d.breaking.message,name:"breaking",type:"text"}),Ke=({config:{issuesHint:e,issuesPrefix:t}})=>({hint:e,message:Ve(t),name:"issues",type:"text"}),Ye=({config:{scopes:e}})=>{const t=e.map(s=>({indent:" ",title:s,value:s}));return e.length>0?{choices:t,hint:d.scope.hint,limit:10,message:d.scope.message,name:"scope",suggest:s=>M(t,s,"title"),type:"autocomplete"}:null},X=e=>{const t=e!=null&&e.scope&&e.scope!=="none"?`(${e.scope})`:"";return e!=null&&e.type?`${e.type}${t}: `:""},Je=({config:{headerMinLength:e,headerMaxLength:t,disableEmoji:s}})=>{const r=Q.minTitleLength(e),o=Q.maxTitleLength(t),{subject:{message:n}}=d,a=s?0:3;return{message:i=>{const p=()=>{const b=X(i==null?void 0:i.answers),h=i?i.input.length:0,A=t-h-b.length-a,F=A/t*100,$=`${A}/${t}`;return h<e?c.red($):F>25?c.green($):F<0?c.red($):c.yellow($)};return c.bold(`${n}(${p()})`)},name:"subject",type:"input",validate:(i,p)=>{const b=X(p==null?void 0:p.answers),h=i.length+b.length+a>t;return i.length<e?r:h?o:!0}}},Qe=({details:e,disableEmoji:t},s,r)=>{const{[s]:{description:o,emoji:n}}=e,a=n&&!t&&(r==null?void 0:r.emoji),i=a?`${n} `:"";return{title:`${s==="refactor"&&a?`${i} `:i}${s}:`,hint:o.toLowerCase(),indent:" ",value:s}},Xe=({config:e,flags:t})=>{const s=e.types.map(r=>Qe(e,r,t));return{choices:s,hint:d.type.hint,limit:10,message:d.type.message,name:"type",suggest:r=>M(s,r,"title"),type:"autocomplete"}},We={body:Be,breaking:Ue,issues:Ke,scope:Ye,subject:Je,type:Xe},Ze=e=>e!=null,et=({config:e,answers:t},s)=>e.questions.filter(r=>{var o;return S.questions.includes(r)&&!((o=s.skip)!=null&&o.includes(r))}).map(r=>We[r]({config:e,answers:t,flags:s})).filter(Ze),tt={get skip(){const e=new j.Option("-S, --skip <questions...>",u.flags.skip);return e.variadic=!0,e.choices(H),e}};var st=Object.defineProperty,W=Object.getOwnPropertySymbols,rt=Object.prototype.hasOwnProperty,ot=Object.prototype.propertyIsEnumerable,Z=(e,t,s)=>t in e?st(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,f=(e,t)=>{for(var s in t||(t={}))rt.call(t,s)&&Z(e,s,t[s]);if(W)for(var s of W(t))ot.call(t,s)&&Z(e,s,t[s]);return e};const nt={autofill:!0,cancel:()=>null,styles:{submitted:c.cyan,danger:c.red}},it=async()=>{const e={config:S,answers:Se},t=new Oe,s=async({passthrough:o,commitlint:n,dryRun:a})=>{const i=await De(n);i&&(e.config=f(f({},e.config),i)),$e(o)&&!a&&(await ve(),await be())},r=async o=>{const n=new te(nt,o),a=et(e,o);return n.prompt(a)};j.program.configureOutput({writeErr:o=>process.stdout.write(o.replace("error: ","")),outputError:(o,n)=>{n(`
${O(o)}
`)}}).version(R().version,"-v, --version").description(u.description).option("-d, --body <body>",u.flags.body).option("-b, --breaking <breaking>",u.flags.breaking).option("-D, --dry-run",u.flags.dryRun).option("-i, --issues <body>",u.flags.issues).option("-p, --passthrough <flags...>",u.flags.passthrough).option("-s, --scope <scope>",u.flags.scope).option("-m, --subject <message>",u.flags.subject).option("-t, --type <type>",u.flags.type).option("-l, --commitlint",u.flags.commitlint).option("-r, --retry",u.flags.retry).option("--no-emoji",u.flags.noEmoji).addOption(tt.skip).addHelpText("after",`
Examples:
${u.examples}
`).name("gitzy").action(async()=>{const o=E.program.opts();o.dryRun&&g(q("running in dry mode..."));try{await s(o);const n=o.retry?t.load():{};o.retry&&!Object.keys(n).length&&g(I("there is no previous gitzy commit to retry..."));const a=await r(y(y({},o),n));t.save(a),e.answers=y(y({},e.answers),a)}catch(n){g(`
${L(n.message)}
`),process.exit(1)}Oe(e,o)}),await E.program.parseAsync(process.argv)},te=parseInt(process.versions.node,10);te<10&&(g(`
${L(`node version ${te} is not supported`)}`),g(`${q(`please use ${K().engines.node}`)}
`),process.exit(1)),pt();
`).name("gitzy").action(async()=>{const o=j.program.opts();o.dryRun&&m(C("running in dry mode..."));try{await s(o);const n=o.retry?t.load():{};o.retry&&!Object.keys(n).length&&m(_("there is no previous gitzy commit to retry..."));const a=await r(f(f({},o),n));t.save(a),e.answers=f(f({},e.answers),a)}catch(n){m(`
${O(n.message)}
`),process.exit(1)}ge(e,o)}),await j.program.parseAsync(process.argv)},ee=parseInt(process.versions.node,10);ee<10&&(m(`
${O(`node version ${ee} is not supported`)}`),m(`${C(`please use ${R().engines.node}`)}
`),process.exit(1)),it();
{
"name": "gitzy",
"description": "interactive conventional commits cli",
"version": "4.0.0",
"version": "5.0.0",
"author": "jimmy-guzman @jimmy-guzman",

@@ -20,3 +20,3 @@ "repository": "jimmy-guzman/gitzy",

"scripts": {
"build": "pkgroll --minify --target=node16",
"build": "pkgroll --minify --target=node18",
"format": "prettier '**/**/*.{md,yml,json,ts}'",

@@ -56,17 +56,17 @@ "format:check": "pnpm format -c",

"@semantic-release/git": "10.0.1",
"@types/jest": "29.5.4",
"@types/node": "18.15.11",
"commitlint": "17.7.1",
"eslint": "8.47.0",
"eslint-config-jimmy-guzman": "9.1.0",
"husky": "8.0.3",
"@types/jest": "29.5.12",
"@types/node": "20.11.19",
"commitlint": "18.6.1",
"eslint": "8.56.0",
"eslint-config-jimmy-guzman": "12.2.0",
"husky": "9.0.11",
"is-ci": "3.0.1",
"jest": "29.6.3",
"lint-staged": "14.0.1",
"jest": "29.7.0",
"lint-staged": "15.2.2",
"npm-run-all": "4.1.5",
"pkgroll": "1.11.0",
"prettier": "2.7.1",
"semantic-release": "19.0.5",
"ts-jest": "29.1.1",
"typescript": "4.9.5"
"pkgroll": "2.0.1",
"prettier": "3.2.5",
"semantic-release": "23.0.2",
"ts-jest": "29.1.2",
"typescript": "5.3.3"
},

@@ -77,4 +77,5 @@ "files": [

"engines": {
"node": ">= 16"
}
"node": ">= 18"
},
"packageManager": "pnpm@7.33.6"
}

@@ -27,3 +27,3 @@ # gitzyπŸͺ„

> The current version of `gitzy` is fully supported on [active LTS versions of node][node-lts-versions], and requires at least node v16.
> The current version of `gitzy` is fully supported on [active LTS versions of node][node-lts-versions], and requires at least node v18.

@@ -30,0 +30,0 @@ ## Quick start

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc