@nice-move/cli 0.12.2 → 0.12.3
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/dist/cli.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as e,i as t}from"./git-hooks-ukr62xCA.mjs";import{a as n,i as r}from"./lint-
|
|
2
|
+
import{a as e,i as t}from"./git-hooks-ukr62xCA.mjs";import{a as n,i as r}from"./lint-CUwrJNIa.mjs";import{Cheetor as i}from"cheetor";import{fileURLToPath as a}from"node:url";function o(){if(n(`svgo/package.json`)&&n(`svgo-config/package.json`))return{command:`svgo`,describe:"Run `svgo` to optimize `*.svg`",async handler(t){let[n=`./`]=t._;try{await e(`svgo`,[`-r`,`-q`,`--pretty`,`--indent`,`2`,`--config`,a(import.meta.resolve(`svgo-config`)),`-f`,n]),console.log(`Done: calling svgo`)}catch(e){process.exitCode=1,console.error(`Error:`,e.message)}}}}process.on(`SIGINT`,()=>{}),new i(`../package.json`,import.meta.url).website(`https://www.npmjs.com/org/nice-move`).command(r).command(t).commandSmart(o).setup();export{};
|
package/dist/cmd/lint.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{t as builder,n as command,r as description}from"../lint-
|
|
1
|
+
export{t as builder,n as command,r as description}from"../lint-CUwrJNIa.mjs";
|
|
@@ -36,16 +36,16 @@ Please update Git: https://git-scm.com/downloads`),nt=(e=process.platform)=>{swi
|
|
|
36
36
|
* Released under the MIT License.
|
|
37
37
|
*/
|
|
38
38
|
if(e===p.posix.sep||e===p.win32.sep)return p.posix.sep;let t=e.split(pt).join(p.posix.sep);return(e.startsWith(`\\\\?\\`)||e.startsWith(`\\\\.\\`))&&(t=t.replace(mt,`//$1`)),t.endsWith(p.posix.sep)&&(t=t.slice(0,-1)),t},ht=K(`lint-staged:generateTasks`),gt=({config:e,cwd:t=process.cwd(),files:n,relative:r=!1})=>{ht(`Generating tasks`);let i=n.map(e=>({filepath:X(p.relative(t,e.filepath)),status:e.status}));return Object.entries(e).map(([e,n])=>{let a=e.startsWith(`../`),o=i.filter(e=>a?!0:!e.filepath.startsWith(`..`)&&!p.isAbsolute(e.filepath)),s={pattern:e,commands:n,fileList:ft(o,e,t).map(e=>({filepath:X(r?e.filepath:p.resolve(t,e.filepath)),status:e.status}))};return ht(`Generated task:
|
|
39
|
-
%O`,s),s})},_t={SIGINT:`SIGINT`,SIGKILL:`SIGKILL`},vt=(e=process)=>{let t=new AbortController;return e.on(_t.SIGINT,()=>{t.abort(_t.SIGINT)}),t};function yt(e,t,n){
|
|
40
|
-
`))}else n.quiet||(r===`SIGINT`?n.output.push(z(`\n${Y()} Task interrupted: ${e}`)):r===`SIGKILL`?n.output.push(z(`\n${Y()} Task killed: ${e}`)):i&&n.output.push(z(`\n${Y()} Task failed to spawn: ${e}`),r))},
|
|
41
|
-
`}catch(i){let o=i instanceof Error&&i.code||`FAILED`;throw n!==!0&&e.abort(_t.SIGKILL),
|
|
39
|
+
%O`,s),s})},_t={SIGINT:`SIGINT`,SIGKILL:`SIGKILL`},vt=(e=process)=>{let t=new AbortController;return e.on(_t.SIGINT,()=>{t.abort(_t.SIGINT)}),t};function yt(e,t,n){let r=[];t&&r.push(t),n&&r.push(n);let i=``,a=null,o=!1,s=0;for(;s<e.length;){let t=e[s];a?t===a?a=null:i+=t:t===`"`||t===`'`?(a=t,o=!0):/\s/.test(t)?o&&=(r.push(i),i=``,!1):(i+=t,o=!0),s++}return o&&r.push(i),r}const bt=f(a),xt=async e=>{await bt(`taskkill /pid ${e} /T /F`)},St=async e=>{process.kill(-e,`SIGKILL`)},Ct=async(e,t=process.platform===`win32`)=>{try{t?await xt(e):await St(e)}catch{}},wt=Symbol(`ApplyEmptyCommitError`),Tt=/* @__PURE__ */ Error(`Configuration could not be found`),Et=/* @__PURE__ */ Error(`Configuration should be an object or a function`),Dt=/* @__PURE__ */ Error(`Configuration should not be empty`),Ot=Symbol(`GetStagedFilesError`),kt=Symbol(`IntentToAddError`),Z=Symbol(`GitError`),At=Symbol(`GitRepoError`),jt=Symbol(`HideUnstagedChangesError`),Mt=/* @__PURE__ */ Error(`Invalid Options`),Nt=Symbol(`RestoreMergeStatusError`),Pt=Symbol(`RestoreOriginalStateError`),Ft=Symbol(`RestoreUnstagedChangesError`),It=Symbol(`TaskError`),Lt=Symbol(`FailOnChangesError`),Rt=({failOnChanges:e=!1,hideAll:t=!1,hideUnstaged:n=!1,hidePartiallyStaged:r=!(t||n),quiet:i=!1,revert:a=!0}={})=>{let o={backupHash:void 0,errors:/* @__PURE__ */ new Set([]),shouldFailOnChanges:e,hasFilesToHide:null,output:[],quiet:i,runId:O.randomBytes(4).toString(`hex`),shouldBackup:null,shouldHideAll:t,shouldHideUnstaged:n,shouldHidePartiallyStaged:r,shouldRevert:a,unstagedDiff:null,unstagedPatch:null};return o.shouldHideAll?(o.shouldHideUnstaged=!1,o.shouldHidePartiallyStaged=!1):o.shouldHideUnstaged&&(o.shouldHidePartiallyStaged=!1),o},zt=e=>e.shouldHidePartiallyStaged&&e.hasFilesToHide,Bt=e=>(e.shouldHideAll||e.shouldHideUnstaged||e.shouldHidePartiallyStaged)&&e.hasFilesToHide,Vt=e=>!!e.shouldBackup&&!!e.shouldHideAll,Ht=e=>{if(!e.shouldRevert||!e.shouldBackup)return!1;if(e.errors.has(Z))return Je();if(e.errors.has(It))return Ke()},Ut=e=>{if(e.errors.has(Z))return Je();if(!e.shouldRevert)return!1;if(e.errors.has(It))return Ke()},Wt=e=>!!e.shouldRevert&&!!e.shouldBackup&&(e.errors.has(Lt)||e.errors.has(It)||e.errors.has(Ft)),Gt=e=>{if(e.errors.has(Z)&&!e.errors.has(Ft))return Je()},Kt=e=>e.shouldBackup,qt=e=>{if(e.errors.has(Lt)&&!e.shouldRevert)return!0;if(e.errors.has(Ft)&&!e.shouldRevert||Gt(e)||e.errors.has(Pt))return Je()},Jt=K(`lint-staged:getSpawnedTask`),Yt=(e,t,n,r,i)=>{if(t){let r=i?z(`${Y()} ${e}:`):`${ke()} ${e}:`;n.output.push([...n.quiet?[]:[``,r],t].join(`
|
|
40
|
+
`))}else n.quiet||(r===`SIGINT`?n.output.push(z(`\n${Y()} Task interrupted: ${e}`)):r===`SIGKILL`?n.output.push(z(`\n${Y()} Task killed: ${e}`)):i&&n.output.push(z(`\n${Y()} Task failed to spawn: ${e}`),r))},Xt=(e,t,n,r=`FAILED`)=>(n.errors.add(It),Error(`${z(e)} ${H(`[${r}]`)}`,{cause:t})),Zt=/^git(\.exe)?/i,Qt=({abortController:e,command:t,continueOnError:n=!1,cwd:r=process.cwd(),files:i,topLevelDir:a,verbose:o=!1})=>{let[s,...c]=yt(t);Jt(`cmd:`,s),Jt(`args:`,c);let l={nodeOptions:{cwd:Zt.test(s)?a:r,env:P?{FORCE_COLOR:`true`}:{NO_COLOR:`true`}}};return Jt(`Tinyexec options:`,l),async(r=Rt())=>{let a=we(s,[...c,...i],l),u=()=>a.exitCode>0||a.process?.signalCode,d;e.signal.addEventListener(`abort`,async()=>{if(u()||!a.process)return;d=e.signal.reason;let t=a.process.pid;a.process.kill(e.signal.reason),await Ct(t)},{once:!0});let f=``;try{for await(let e of a)f+=e+`
|
|
41
|
+
`}catch(i){let o=i instanceof Error&&i.code||`FAILED`;throw n!==!0&&e.abort(_t.SIGKILL),Yt(t,f,r,o,a),Xt(t,a,r,o)}if(f=f.trimEnd(),u())throw n!==!0&&e.abort(_t.SIGKILL),a.process?.pid&&await Ct(a.process.pid),Yt(t,f,r,d,a),Xt(t,a,r,a.process?.signalCode??d);o&&Yt(t,f,r,d)}},$t=K(`lint-staged:getFunctionTasks`),en=e=>typeof e==`object`&&!Array.isArray(e),tn=async({abortController:e,command:t,continueOnError:n,files:r,verbose:i})=>($t(`Creating task for function %o`,t),[{title:t.title,task:async a=>{let o=[],s=(...e)=>{o.push(l(...e))};try{let e=r.map(e=>e.filepath);await t.task(e,{log:s})}catch(r){n!==!0&&e.abort(_t.SIGKILL),s(`
|
|
42
42
|
%O`,r);let i=o.join(`
|
|
43
|
-
`).trimEnd();throw
|
|
44
|
-
`).trimEnd(),a)}}]),
|
|
45
|
-
|
|
46
|
-
`);throw n.error($e(t,e)),Error(e)}return
|
|
47
|
-
`));t!==s&&(c=a.next().value,s=t),o.set(c,(o.get(c)??``)+e)}return o},
|
|
48
|
-
`),i=X(p.join(e,t));
|
|
49
|
-
%O`,E),E.length===0)return h||S.output.push(Ve()),S;if(D.length>0)throw S.errors.add(
|
|
50
|
-
`),t.warn(Ze(n.backupHash))):n.errors.has(
|
|
51
|
-
`)),at(n,t),!1}throw e}};export{
|
|
43
|
+
`).trimEnd();throw Yt(t.title,i,a,void 0,r),Xt(t.title,r,a)}i&&Yt(t.title,o.join(`
|
|
44
|
+
`).trimEnd(),a)}}]),nn=/\u0000$/,rn=e=>e?e.replace(nn,``).split(`\0`):[],an=K(`lint-staged:getIntentToAddFiles`),on=async({cwd:e})=>{let[t,n]=await Promise.all([De([`diff`,`--staged`,`--ita-visible-in-index`,`--name-only`,`-z`],{cwd:e}).then(rn),De([`diff`,`--staged`,`--ita-invisible-in-index`,`--name-only`,`-z`],{cwd:e}).then(rn)]),r=new Set(n),i=t.filter(e=>!r.has(e)).map(t=>X(p.join(e,t)));return an(`Detected ${i.length} files staged with "--intent-to-add":`,i),i},sn=()=>/(?<![\\$])({)(?:(?!(?<!\\),|\.\.|\{|\}).)*?(?<!\\)(})/g,cn=/{/,ln=/}/,un=e=>{let t=`${e}`,n=sn(),r=n.exec(t);for(;r;){let e=r[0],i=e.replace(cn,``).replace(ln,``);t=t.replace(e,i),n.lastIndex=0,r=n.exec(t)}return t},dn=/{{[^}{]*}}/,fn=e=>{let t=`${e}`,n=dn.exec(e)?.[0];if(n){let e=n.replace(`{{`,`{`).replace(`}}`,`}`);t=t.replace(n,e)}return t},pn=(e,t)=>{let n=fn(un(e));return n!==e&&t.warn(ze(e,n)),n},mn=K(`lint-staged:validateConfig`),hn=(e,t=0,n=!0)=>Array.isArray(e)?t<2&&e.every(e=>hn(e,t+1,n)):typeof e==`string`||n&&typeof e==`function`,gn=(e,t,n)=>{if(mn("Validating config from `%s`...",t),!e||typeof e!=`object`&&typeof e!=`function`)throw Et;if(typeof e==`function`)return{"*":e};if(Object.entries(e).length===0)throw Dt;let r=[],i=Object.entries(e).reduce((e,[t,i])=>{Array.isArray(i)?hn(i)||r.push(Fe(t,`Should be an array of strings or functions, or single-level nested array or strings of functions.`,i)):typeof i==`object`?(typeof i.title!=`string`||typeof i.task!=`function`)&&r.push(Fe(t,"Function task should contain `title` and `task` fields, where `title` should be a string and `task` should be a function.",i)):typeof i!=`string`&&typeof i!=`function`&&r.push(Fe(t,`Should be a string, a function, an object or an array of strings and functions.`,i));let a=pn(t,n);return Object.assign(e,{[a]:i})},{});if(r.length){let e=r.join(`
|
|
45
|
+
|
|
46
|
+
`);throw n.error($e(t,e)),Error(e)}return mn("Validated config from `%s`:\n%O",t,e),i},_n=(e,t,n)=>{try{return gn(e,t,n)}catch(e){throw n.error($e(t,e)),e}},vn=K(`lint-staged:getSpawnedTasks`),yn=async(e,t,n,r=0)=>{let i=typeof e==`function`,a=i?await e([...t]):e;if(!hn(a,r,!i))throw Error(Fe(i?`[Function]`:`[Commands]`,`Commands must be strings, with at most one nested array inside the sequential task list. Function results must preserve this nesting limit.`,a));if(Array.isArray(e))return[(await Promise.all(e.map(e=>yn(e,t,n,r+1)))).flat()];let o=e=>Array.isArray(e)?e.map(o):{command:e,files:i?[]:t},s=o(a),c=e=>Array.isArray(e)?e.every(c):e.command.length+(e.files.length?1+e.files.join(` `).length:0)<=n;if(!n||n===1/0||t.length<=1||c(s))return[s];let l=Math.ceil(t.length/2);return vn(`Splitting %d files for maxArgLength of %d`,t.length,n),(await Promise.all([yn(e,t.slice(0,l),n,r),yn(e,t.slice(l),n,r)])).flat()},bn=async(e,t,n)=>t.length===0?[]:(await yn(e,t,n)).flat(),xn=async({abortController:e,commands:t,continueOnError:n,cwd:r,files:i,maxArgLength:a,topLevelDir:o,verbose:s})=>{vn(`Creating tasks for commands %o`,t);let c=await bn(t,i.map(e=>e.filepath),a),l=t=>({title:t.command,task:Qt({abortController:e,command:t.command,continueOnError:n,cwd:r,files:t.files,topLevelDir:o,verbose:s})});return c.map(e=>Array.isArray(e)?e.map(l):l(e))},Sn=K(`lint-staged:file`),Cn=async e=>(Sn(`Ensuring directory exists: %s`,e),await C.mkdir(e,{recursive:!0}),e),wn=async e=>{Sn(`Removing directory: %s`,e);try{await C.rm(e,{recursive:!0,force:!0})}catch{}},Tn=async(e,t=!0)=>{Sn("Reading file `%s`",e);try{return await C.readFile(e)}catch(n){if(t&&n.code===`ENOENT`)return Sn("File `%s` doesn't exist, ignoring...",e),null;throw n}},En=async(e,t)=>{Sn("Writing file `%s`",e),await C.writeFile(e,t)},Dn=(e,t)=>{let n=t===void 0?`ACMR`:t.trim(),r=e===void 0?[`--staged`]:e.trim().split(` `);return[`diff`,`--diff-filter=${n}`,...r]},On=(e,t)=>e?e.slice(1).split(`\0:`).map(rn).flatMap(([e,n,r])=>{let[,i,,,a]=e.split(` `);if(i===`160000`||i===`120000`)return[];let o=a[0],s=r??n;return[{filepath:X(p.resolve(t,s)),status:o}]}):[],kn=async({all:e,cwd:t,gitConfigDir:n,diff:r,diffFilter:i})=>{try{if(e){let e=await De([`ls-files`,`--full-name`,`-z`]);return rn(e).map(e=>({filepath:X(p.resolve(t,e)),status:`X`}))}let a=async e=>{let n=await De([...e,`--ita-visible-in-index`,`--raw`,`-z`],{cwd:t});return On(n,t)},o=await a(Dn(r,i));if(r||o.length===0||!await Tn(p.resolve(n,`MERGE_HEAD`)))return o;let s=new Set((await a([`diff`,`--staged`,`MERGE_HEAD`])).map(({filepath:e})=>e));return o.filter(({filepath:e})=>s.has(e))}catch{return null}},Q=K(`lint-staged:runParallelTasks`),An=e=>e===!0||e===1/0?1/0:e===!1||e<1||!Number.isInteger(e)?1:e,jn=async(e,t,{abortController:n,concurrent:r=!0,logger:i})=>{let a=An(r);Q(`Running parallel tasks with concurrency:`,a);let o=t.length>1?` `:` `,s=[];for(let e of t){e.skip()?Q(`Skipped configuration:`,e.title):(Q(`Running configuration:`,e.title),t.length>1&&i?.log(H(`${o}${e.title}`)));for(let t of e.task)if(!e.skip()){if(t.skip())Q(`Skipped glob from configuration:`,e.title,t.title);else{Q(`Running glob:`,t.title),i?.log(H(`${o} ${t.title}`));for(let e of t.task)Array.isArray(e)?(Q(`Running ${e.length} parallel tasks:`,...e.map(e=>e.title)),e.forEach((t,n)=>{if(n===0)i?.log(`${o} ${Me()} ${J()} ${t.title}`);else{let r=n===e.length-1?Pe():Ne();i?.log(`${o} ${r} ${J()} ${t.title}`)}})):(Q(`Running task:`,e.title),i?.log(`${o} ${J()} ${e.title}`));s.push(t.task)}}}i?.log(``);let c=async({title:t,task:r})=>{if(n.signal.aborted)Q(`Skipped task because aborted:`,t),i?.warn(`${je()} ${t}`);else try{Q(`Running task:`,t),await r(e),Q(`Done running task:`,t),i?.log(`${Oe()} ${t}`)}catch{Q(`Failed to run task:`,t),i?.error(z(`${Y()} ${t}`))}},l=async e=>{for(let t of e)Array.isArray(t)?await Promise.all(t.map(c)):await c(t)},u=0,d=async()=>{for(;u<s.length;){let e=s[u++];await l(e)}},f=Math.min(s.length,a);Q(`Running workers with concurrency:`,f),await Promise.all(Array.from({length:f},d)),Q(`Done running workers`),i?.log(``)},$=K(`lint-staged:GitWorkflow`),Mn=/\x00/,Nn=(e,t=!0)=>e.reduce((e,n)=>{if(Mn.test(n)){let[r,i]=n.split(Mn);t&&e.push(i),e.push(r)}else e.push(n);return e},[]),Pn=`unstaged.patch`,Fn=[`--binary`,`--unified=0`,`--no-color`,`--no-ext-diff`,`--src-prefix=a/`,`--dst-prefix=b/`,`--patch`,`--submodule=short`],In=[`-v`,`--whitespace=nowarn`,`--recount`,`--unidiff-zero`],Ln=/^diff --git /m,Rn=e=>{if(!e)return/* @__PURE__ */ new Map;let[t,n]=e.split(`\0\0`),r=rn(t).filter((e,t)=>t%2==1),i=n.split(Ln).slice(1),a=r.values(),o=/* @__PURE__ */ new Map,s,c;for(let e of i){let t=e.slice(0,e.indexOf(`
|
|
47
|
+
`));t!==s&&(c=a.next().value,s=t),o.set(c,(o.get(c)??``)+e)}return o},zn=/^"(.*)"$/,Bn=e=>e.map(e=>e.replace(zn,`$1`)),Vn=/\x00(?=[ AMDRCU?!]{2} |$)/;var Hn=class{constructor({allowEmpty:e,diff:t,diffFilter:n,failOnChanges:r,gitConfigDir:i,logger:a,maxArgLength:o,topLevelDir:s}){this.execGit=(e,t={})=>De(e,{...t,cwd:s}),this.allowEmpty=e,this.diff=t,this.diffFilter=n,this.gitConfigDir=i,this.failOnChanges=!!r,this.logger=a,this.maxArgLength=o,this.topLevelDir=s,this.mergeHeadFilename=p.resolve(i,`MERGE_HEAD`),this.mergeModeFilename=p.resolve(i,`MERGE_MODE`),this.mergeMsgFilename=p.resolve(i,`MERGE_MSG`)}async backupMergeStatus(){$(`Backing up merge state...`),await Promise.all([Tn(this.mergeHeadFilename).then(e=>this.mergeHeadBuffer=e),Tn(this.mergeModeFilename).then(e=>this.mergeModeBuffer=e),Tn(this.mergeMsgFilename).then(e=>this.mergeMsgBuffer=e)]),$(`Done backing up merge state!`)}async restoreMergeStatus(e){$(`Restoring merge state...`);try{await Promise.all([this.mergeHeadBuffer&&En(this.mergeHeadFilename,this.mergeHeadBuffer),this.mergeModeBuffer&&En(this.mergeModeFilename,this.mergeModeBuffer),this.mergeMsgBuffer&&En(this.mergeMsgFilename,this.mergeMsgBuffer)]),$(`Done restoring merge state!`)}catch(t){throw e.errors.add(Z),e.errors.add(Nt),$(`Failed restoring merge state with error:`),$(t),t}}async getUnstagedFiles({onlyPartial:e=!1}={}){$(`Getting partially staged files...`);let t=(await this.execGit([`status`,`-z`,`--untracked-files=no`])).split(Vn).filter(t=>{let[n,r]=t,i=n!==` `,a=r!==` `;return e?i&&a:a}).map(e=>e.slice(3)).filter(Boolean);return $(`Found ${e?`partially staged`:`unstaged`} files:`,t),t.length?t:null}async listStashes(){return await this.execGit([`stash`,`list`,`--format="%H %s"`,`-z`]).then(rn).then(Bn)}async prepare(e){this.logger.log(H(`${J()} ${e.shouldBackup?`Backing up original state…`:`Preparing lint-staged…`}`));try{if(this.hiddenPath=p.join(this.gitConfigDir,`./lint-staged/${e.runId}`),e.shouldBackup&&await this.backupMergeStatus(),e.shouldHideUnstaged||e.shouldHideAll?(this.unstagedFiles=await this.getUnstagedFiles({onlyPartial:!1}),e.hasFilesToHide=!!this.unstagedFiles):e.shouldHidePartiallyStaged&&(this.unstagedFiles=await this.getUnstagedFiles({onlyPartial:!0}),e.hasFilesToHide=!!this.unstagedFiles),this.unstagedFiles){await Cn(this.hiddenPath),e.unstagedPatch=p.join(this.hiddenPath,Pn);let t=Nn(this.unstagedFiles);await this.execGit([`diff`,...Fn,`--output`,e.unstagedPatch,`--`,...t])}if(e.shouldBackup){let t=`lint-staged automatic backup (${e.runId})`;if(e.shouldHideUnstaged||e.shouldHideAll){let n=[`stash`,`push`,`--keep-index`,`--message`,t];e.shouldHideAll&&n.push(`--include-untracked`),await this.execGit(n),e.backupHash=(await this.listStashes()).find(t=>t.includes(e.runId))?.split(` `)[0],await this.restoreMergeStatus(e)}else e.backupHash=await this.execGit([`stash`,`create`]),await this.execGit([`stash`,`store`,`--quiet`,`--message`,t,e.backupHash]);$(`Created backup stash with commit hash %s`,e.backupHash)}this.logger.log(`${Oe()} ${e.shouldBackup?`Done backing up original state (${await this.execGit([`rev-parse`,`--short`,e.backupHash])})!`:`Done preparing lint-staged!`}`)}catch(t){e.errors.add(Z);let n=e.shouldBackup?`Failed to back up original state!`:`Failed to prepare lint-staged!`;this.logger.error(`${Y()} ${n}`),$(t)}}async hidePartiallyStagedChanges(e){this.logger.log(H(`${J()} Hiding unstaged changes to partially staged files…`));try{let e=Nn(this.unstagedFiles,!1);await this.execGit([`restore`,`--worktree`,`--`,...e]),this.logger.log(`${Oe()} Done hiding unstaged changes to partially staged files!`)}catch(t){e.errors.add(Z),e.errors.add(jt);let n=`${Y()} Failed to hude unstaged changes to partially staged files!`;this.logger.error(n),$(t)}}async runTasks(e,t,{abortController:n,concurrent:r}){this.logger.log(H(`${J()} Running tasks for ${this.diff?`changed`:`staged`} files…`));try{e.unstagedDiff=await this.execGit([`diff`,...Fn,`--raw`,`-z`,`--no-renames`,`--no-textconv`],{trim:!1})}catch(t){e.errors.add(Z),this.logger.error(`Failed to get diff of unstaged changes!`),$(t);return}let i=`${Y()} Failed to run tasks for ${this.diff?`changed`:`staged`} files!`;try{await jn(e,t,{abortController:n,concurrent:r,logger:this.logger}),this.logger.log(e.errors.has(It)?i:`${Oe()} Done running tasks for ${this.diff?`changed`:`staged`} files!`)}catch(t){e.errors.add(It),this.logger.error(i),$(t)}}async updateIndex(e){this.logger.log(H(`${J()} Staging changes from tasks…`));try{let t=await this.execGit([`diff`,...Fn,`--raw`,`-z`,`--no-renames`,`--no-textconv`],{trim:!1}),n=Rn(e.unstagedDiff),r=Rn(t),i=/* @__PURE__ */ new Set;for(let e of/* @__PURE__ */ new Set([...n.keys(),...r.keys()]))n.get(e)!==r.get(e)&&i.add(X(p.resolve(this.topLevelDir,e)));if(e.shouldFailOnChanges&&i.size>0){e.errors.add(Lt),this.logger.error(`${Y()} Tasks modified files and --fail-on-changes was used!`);return}if(i.size>0){let e=await bn(`git add --`,[...i],this.maxArgLength),t=process.env.GIT_INDEX_FILE?X(process.env.GIT_INDEX_FILE):process.env.GIT_INDEX_FILE,n=t?.endsWith(`.lock`)?X(await this.execGit([`rev-parse`,`--path-format=absolute`,`--git-path`,`index.lock`])):void 0;for(let{files:r}of e)$(`Updating active Git index: %s`,t),await this.execGit([`add`,`--`,...r]),$(`Done updating Git index: %s`,t),n&&t!==n&&($(`Updating default Git index again: %s`,n),await this.execGit([`add`,`--`,...r],{env:{GIT_INDEX_FILE:n}}),$(`Done updating default Git index lock: %s`,n))}if(!this.allowEmpty&&rn(await this.execGit([...Dn(this.diff,this.diffFilter),`--name-only`,`-z`])).length===0){e.errors.add(wt),this.logger.error(`${Y()} Prevented an empty git commit!`);return}this.logger.log(`${Oe()} Done staging changes from tasks!`)}catch(t){e.errors.add(Z),this.logger.log(`${Y()} Failed to stage changes from tasks!`),$(t)}}async restoreUnstagedChanges(e){this.logger.log(H(`${J()} Restoring unstaged changes…`));let t=p.join(this.hiddenPath,Pn);try{await this.execGit([`apply`,...In,t]),await wn(this.hiddenPath),e.unstagedPatch=null}catch(n){$(`Error while restoring changes:`),$(n),$(`Retrying with 3-way merge`);try{await this.execGit([`apply`,...In,`--3way`,t]),await wn(this.hiddenPath),e.unstagedPatch=null}catch(t){e.errors.add(Z),e.errors.add(Ft),this.logger.error(`${Y()} Failed to restore unstaged changes!`),$(t)}}}async restoreUntrackedFiles(e){this.logger.log(H(`${J()} Restoring untracked files…`));try{let t=`${e.backupHash}^3`,n=await this.execGit([`ls-tree`,`-r`,`--name-only`,`-z`,t]).then(rn);n.length?($(`Found untracked files: %s`,n),await this.execGit([`restore`,`--source`,t,`--`,...n.map(X)]),this.logger.log(`${Oe()} Done restoring untracked files!`)):this.logger.log(`${je()} ${H(`No untracked files to restore!`)}`)}catch(t){e.errors.add(Z),e.errors.add(Ft),this.logger.error(`${Y()} Failed to restore untracked files!`),$(t)}}async restoreOriginalState(e){this.logger.log(H(`${J()} Reverting to original state because of errors…`));try{$(`Restoring original state...`),await this.execGit([`reset`,`--hard`,`HEAD`]),await this.execGit([`stash`,`apply`,`--quiet`,`--index`,e.backupHash]),await this.restoreMergeStatus(e),await wn(this.hiddenPath),e.unstagedPatch=null,this.logger.log(`${Oe()} Done reverting to original state!`)}catch(t){e.errors.add(Z),e.errors.add(Pt),this.logger.error(`${Y()} Failed to revert to original state!`),$(t)}}async cleanup(e){this.logger.log(H(`${J()} Cleaning up temporary files…`));try{let t=(await this.listStashes()).findIndex(t=>t.startsWith(e.backupHash));t>-1?(await this.execGit([`stash`,`drop`,`--quiet`,String(t)]),this.logger.log(`${Oe()} Done cleaning up temporary files!`)):this.logger.error(`${Y()} lint-staged automatic backup is missing!`)}catch(t){e.errors.add(Z),this.logger.error(`${Y()} Failed to clean up temporary files!`),$(t)}}};const Un=K(`lint-staged:groupFilesByConfig`),Wn=async({configs:e,files:t,singleConfigMode:n})=>{Un(`Grouping %d files by %d configurations`,t.length,Object.keys(e).length);let r={},i=Object.entries(e);if(n){let e=i[0];if(e){let[n,i]=e;r[n]={config:i,files:t}}return r}let a=/* @__PURE__ */ new Map,o=1/0;for(let[e,[t,n]]of i.entries()){r[t]={config:n,files:[]};let i=p.dirname(t);a.has(i)||a.set(i,e),o===1/0&&Object.keys(n).some(e=>e.startsWith(`..`))&&(o=e)}let s=/* @__PURE__ */ new Map,c=e=>{let t=s.get(e);if(t!==void 0)return t;let n=a.get(e)??1/0,r=p.dirname(e);return r!==e&&(n=Math.min(n,c(r))),s.set(e,n),n};for(let e of new Set(t)){let t=c(p.dirname(e.filepath)),n=Math.min(t,o);if(n!==1/0){let[t]=i[n];r[t].files.push(e)}}return r},Gn=K(`lint-staged:resolveGitRepo`),Kn=async(e=process.cwd())=>{try{Gn("Resolving git repo from `%s`",e),Gn("Unset GIT_DIR (was `%s`)",process.env.GIT_DIR),delete process.env.GIT_DIR,Gn("Unset GIT_WORK_TREE (was `%s`)",process.env.GIT_WORK_TREE),delete process.env.GIT_WORK_TREE;let[t,n,r]=(await De([`rev-parse`,`--show-cdup`,`--show-toplevel`,`--absolute-git-dir`],{cwd:e})).split(`
|
|
48
|
+
`),i=X(p.join(e,t));Gn("Resolved git repository top-level directory to be `%s`",i);let a=p.relative(n,r),o=X(p.join(i,a));return Gn("Resolved git config directory to be `%s`",o),{topLevelDir:i,gitConfigDir:o}}catch(e){return Gn(`Failed to resolve git repo with error:`,e),{error:e,topLevelDir:null,gitConfigDir:null}}},qn=`lint-staged`,Jn=`package.json`,Yn=[`package.yaml`,`package.yml`],Xn=[Jn,...Yn,`.lintstagedrc`,`.lintstagedrc.json`,`.lintstagedrc.yaml`,`.lintstagedrc.yml`,`.lintstagedrc.mjs`,`.lintstagedrc.mts`,`.lintstagedrc.js`,`.lintstagedrc.ts`,`.lintstagedrc.cjs`,`.lintstagedrc.cts`,`lint-staged.config.mjs`,`lint-staged.config.mts`,`lint-staged.config.js`,`lint-staged.config.ts`,`lint-staged.config.cjs`,`lint-staged.config.cts`],Zn=n(import.meta.url);function Qn(e){try{return Zn.resolve(e)}catch{return e}}const $n=K(`lint-staged:loadConfig`),er=async e=>C.readFile(p.resolve(e),`utf-8`),tr=async e=>{let t=Jn.includes(p.basename(e));try{let n=await er(e),r=JSON.parse(n);return t?r[qn]:r}catch(t){if(p.basename(e)===`package.json`){$n(`Ignoring invalid JSON file %s`,e);return}throw t}},nr=async t=>{let n=Yn.includes(p.basename(t));try{let[r,i]=await Promise.all([import(`./dist-DZo1mBt4.mjs`).then(t=>/* @__PURE__ */ e(t.default,1)),er(t)]),a=r.parse(i);return n?a[qn]:a}catch(e){if(n){$n(`Ignoring invalid YAML file %s`,t);return}throw e}},rr=e=>import(i(e)).then(e=>e.default),ir=`noExt`,ar={[ir]:nr,".cjs":rr,".cts":rr,".js":rr,".json":tr,".mjs":rr,".mts":rr,".ts":rr,".yaml":nr,".yml":nr},or=async e=>{let t=p.resolve(e),n=p.extname(t)||ir,r=ar[n];return{config:await r(t),filepath:t}},sr=async(e,t)=>{try{$n("Loading configuration from `%s`...",e);let t=await or(Qn(e)),n=await t.config??null,r=t.filepath;return n?$n("Successfully loaded config from `%s`:\n%O",r,n):$n(`Found no config in %s`,r),{config:n,filepath:r}}catch(n){return $n("Failed to load configuration from `%s` with error:\n",e,n),t.error(Qe(e)),{}}},cr=K(`lint-staged:searchConfigs`),lr=Xn.map(e=>`:(glob)**/${e}`),ur=e=>e.split(`/`).length,dr=(e,t)=>ur(t)-ur(e)||e.localeCompare(t),fr=/^[HSMRCK?U] /,pr=async({cwd:e,topLevelDir:t})=>De([`ls-files`,`-z`,`--full-name`,`-t`,`--cached`,`--others`,`--exclude-standard`,`--`,...lr],{cwd:e}).then(rn).then(e=>{let n=e.flatMap(e=>{if(e.startsWith(`S `))return[];let n=e.replace(fr,``);return[X(p.join(t,n))]});return cr(`Found possible config files from git:`,n),n}),mr=async({cwd:e})=>{cr(`Listing possible configs from filesystem starting from "%s"...`,e);let t=(await Promise.allSettled(Xn.map(async t=>{let n=p.join(e,t);return await C.access(n,w.F_OK),n}))).flatMap(e=>e.status===`fulfilled`?[X(e.value)]:[]);if(t.length>0)return cr(`Found possible config files from filesystem:`,t),t;let n=p.dirname(e);return n===e?[]:mr({cwd:n})},hr=async({configObject:e,configPath:t,cwd:n=process.cwd(),topLevelDir:r=n},i)=>{if(cr(`Searching for configuration files...`),e)return cr(`Using single direct configuration object...`),{"":_n(e,`config object`,i)};if(t){cr(`Using single configuration path...`);let{config:e,filepath:n}=await sr(t,i);return e?{[t]:_n(e,n,i)}:{}}let a=/* @__PURE__ */ new Set,o=e=>{e.forEach(e=>{a.add(e)})};await Promise.all([pr({cwd:n,topLevelDir:r}).then(o),mr({cwd:n}).then(o)]);let s=[...a].toSorted(dr).reduce((e,t)=>Object.assign(e,{[t]:null}),{});await Promise.all(Object.keys(s).map(e=>sr(e,i).then(({config:t,filepath:n})=>{t&&(e!==n&&cr(`Config file "%s" resolved to "%s"`,e,n),s[e]=_n(t,n,i))})));let c=Object.entries(s).reduce((e,[t,n])=>(n&&Object.assign(e,{[t]:n}),e),{});return cr(`Found %d config files`,Object.keys(c).length),c},gr=K(`lint-staged:runAll`),_r=(e,t)=>{if(t){let t=()=>{};return{error:e.error,log:t,warn:t}}return e},vr=(e,t)=>Object.assign(Error(`lint-staged failed`,{cause:t}),{ctx:e}),yr=async({all:e,allowEmpty:t,concurrent:n,configObject:r,configPath:i,continueOnError:a,cwd:o,diff:s,diffFilter:c,failOnChanges:l,hideAll:u,hideUnstaged:d,hidePartiallyStaged:f,maxArgLength:m,quiet:h,relative:g,stash:ee,revert:_,verbose:v},y=console)=>{let b=_r(y,h);gr(`Running all tasks...`);let x=!!o;o=x?p.resolve(o):process.cwd(),gr("Using working directory `%s`",o);let S=Rt({failOnChanges:l,hideAll:u,hideUnstaged:d,hidePartiallyStaged:f,quiet:h,revert:_}),{topLevelDir:C,gitConfigDir:w}=await Kn(o);if(!C)throw h||S.output.push(Ie()),S.errors.add(At),vr(S,At);let T=await De([`log`,`-1`],{cwd:C}).then(()=>!0).catch(()=>!1);S.shouldBackup=T&&ee,S.shouldBackup||b.warn(Ue(e,T,s)),S.shouldHidePartiallyStaged||S.shouldHideUnstaged||S.shouldHideAll||b.warn(We());let[E,D,O]=await Promise.all([kn({all:e,cwd:C,diff:s,diffFilter:c,gitConfigDir:w}),on({cwd:C}),hr({configObject:r,configPath:i,cwd:o,topLevelDir:C},b)]);if(!E)throw h||S.output.push(Le()),S.errors.add(Ot),vr(S,Ot);if(gr(`Loaded list of staged files in git:
|
|
49
|
+
%O`,E),E.length===0)return h||S.output.push(Ve()),S;if(D.length>0)throw S.errors.add(kt),vr(S,D);let te=Object.keys(O).length;if(te===0)throw S.errors.add(Tt),vr(S,Tt);let ne=await Wn({configs:O,files:E,singleConfigMode:r||i!==void 0}),k=te>1,A=!1,j=[],M=vt();for(let[e,{config:t,files:n}]of Object.entries(ne)){let r=e?X(p.relative(o,e)):`Config object`,i=x||!k?o:p.dirname(e),s=await Promise.all(gt({config:t,cwd:i,files:n,relative:g}).map(e=>(en(e.commands)?tn({abortController:M,command:e.commands,continueOnError:a,files:e.fileList,verbose:v}):xn({abortController:M,commands:e.commands,continueOnError:a,cwd:i,files:e.fileList,maxArgLength:m,topLevelDir:C,verbose:v})).then(t=>{let n=e=>e.title.includes(`git add`);A||=t.some(e=>Array.isArray(e)?e.some(n):n(e));let r=e.fileList.length;return{title:`${e.pattern}${H(` — ${r} ${r===1?`file`:`files`}`)}`,task:t,skip:()=>r===0&&`${e.pattern}${H(` — no files`)}`}})));j.push({title:`${r}${H(` — ${n.length} ${n.length>1?`files`:`file`}`)}`,task:s,skip:()=>s.every(e=>e.skip())?`${r}${H(` — no tasks to run`)}`:!1})}if(A&&b.warn(Ge()),j.every(e=>e.skip()))return h||S.output.push(He()),S;let N=new Hn({allowEmpty:t,diff:s,diffFilter:c,failOnChanges:l,gitConfigDir:w,logger:b,maxArgLength:m,topLevelDir:C});if(await N.prepare(S),zt(S)&&await N.hidePartiallyStagedChanges(S),M.signal.aborted||S.errors.size>0?b.log(`${je()} ${H(`Skipped running tasks…`)}`):await N.runTasks(S,j,{abortController:M,concurrent:n}),Ht(S)?b.log(`${je()} ${H(`Skipped staging changes from tasks…`)}`):await N.updateIndex(S),Bt(S)&&(Ut(S)?b.log(`${je()} ${H(`Skipped restoring unstaged changes…`)}`):await N.restoreUnstagedChanges(S)),Vt(S)&&(Ut(S)?b.log(`${je()} ${H(`Skipped restoring untracked files…`)}`):await N.restoreUntrackedFiles(S)),Wt(S)&&(Gt(S)?b.log(`${je()} ${H(`Skipped reverting to original state because of errors…`)}`):await N.restoreOriginalState(S)),Kt(S)&&(qt(S)?b.log(`${je()} ${H(`Skipped cleaning up temporary files…`)}`):await N.cleanup(S)),S.errors.size>0)throw vr(S);return S},br=K(`lint-staged:validateOptions`),xr=e=>Number.isInteger(e)||e===1/0,Sr=async(e={},t)=>{br(`Validating options...`);let{concurrent:n,cwd:r,maxArgLength:i}=e;if(n!==void 0&&typeof n!=`boolean`&&(!xr(n)||n<1))throw t.error(Ye(`concurrent`,`${n}`,`Must be boolean, positive integer or Infinite`)),Mt;if(typeof r==`string`)try{let e=p.resolve(r);await C.access(e,y.F_OK)}catch(n){throw br(`Failed to validate options: %o`,e),t.error(Ye(`cwd`,r,n.message)),Mt}if(i!=null&&(!xr(i)||i<1))throw t.error(Ye(`maxArgLength`,`${i}`,`Must be positive integer, or Infinite`)),Mt;br(`Validated options: %o`,e)},Cr=async()=>JSON.parse(await C.readFile(new URL(`../package.json`,import.meta.url))).version,wr=K(`lint-staged`),Tr=async(e={},t=console)=>{let n=it(e);I(n.color),n.debug&&(re(t),wr("Running `lint-staged@%s` on Node.js %s (%s)",await Cr(),process.version,process.platform));let r=await De([`version`,`--build-options`],{cwd:n.cwd});if(wr(`%s`,r),!N(r))throw Error(tt(te,r),{cause:r});await Sr(n,t),wr("Unset GIT_LITERAL_PATHSPECS (was `%s`)",process.env.GIT_LITERAL_PATHSPECS),delete process.env.GIT_LITERAL_PATHSPECS;try{let e=await yr(n,t);return wr(`Tasks were executed successfully!`),at(e,t),!0}catch(e){if(e?.ctx?.errors){let{ctx:n}=e;return n.errors.has(Tt)?t.error(Be()):n.errors.has(kt)?t.error(Re(e.cause)):n.errors.has(wt)?t.warn(Xe()):n.errors.has(Lt)?(t.warn(qe()+`
|
|
50
|
+
`),t.warn(Ze(n.backupHash))):n.errors.has(Ft)?n.unstagedPatch&&(t.warn(et()),t.warn(n.unstagedPatch)):(n.errors.has(Z)||qt(n))&&(t.error(Je()),n.shouldBackup&&t.error(Ze(n.backupHash)+`
|
|
51
|
+
`)),at(n,t),!1}throw e}};export{Tr as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-Dn1JIVgp.mjs";import{execFile as t}from"node:child_process";import{promisify as n}from"node:util";import{resolve as r}from"node:path";import{readFile as i}from"node:fs/promises";import{readFileSync as a,statSync as o}from"fs";import{createRequire as s}from"module";import{isAbsolute as c,resolve as l}from"path";const u=process.cwd(),d=s(import.meta.url);function f(e,t=u){return e.startsWith(`.`)?l(t,e):c(e)?e:d.resolve(e)}function p(e){try{return o(f(e)),!0}catch{return!1}}function m(e){try{let t=a(f(e),`utf8`);return JSON.parse(t)}catch{return{}}}function h(e,t={}){let n=m(`./package.json`);if(e){let{[e]:r=t}=n;return r}return n}const g=n(t),_={"body-leading-blank":[1,`always`],"body-max-line-length":[2,`always`,100],"footer-leading-blank":[1,`always`],"footer-max-line-length":[2,`always`,100],"header-max-length":[2,`always`,100],"subject-case":[0],"subject-empty":[2,`never`],"subject-full-stop":[2,`never`,`.`],"type-case":[2,`always`,`lower-case`],"type-empty":[2,`never`],"type-enum":[2,`always`,[`build`,`chore`,`ci`,`docs`,`feat`,`fix`,`perf`,`refactor`,`revert`,`style`,`test`]],"scope-case":[0],"body-case":[0],"header-case":[0]};async function v(e=process.cwd()){let{stdout:t}=await g(`git`,[`rev-parse`,`--git-path`,`COMMIT_EDITMSG`],{cwd:e,encoding:`utf8`});return r(e,t.trim())}async function y(){return i(await v(),`utf8`)}async function b(){let e=await y(),t=await import(`./lint-CvrvpJvb.mjs`).then(e=>e.default.default||e.default),n=await import(`./lib-B9YSDxfE.mjs`).then(e=>e.default.default||e.default),r=await t(e,_);return{result:r,output:await n({results:[r]})}}function x(e){e.command(`commit`,`Lint git commit message`,{},()=>{b().then(({result:e,output:t})=>{e.valid?console.log(`Pass.`):(console.log(`Fail:`),console.log(t),process.exitCode=1)}).catch(e=>{console.error(e),process.exitCode=1})})}function S(e){let t=Object.entries(e).map(([e,t])=>[e,t.filter(Boolean)]).filter(([e,t])=>t.length);return t.length>0?Object.fromEntries(t):void 0}function C({garou:e,stylelint:t,eslint:n,prettier:r}){let i=process.stdin.isTTY?` --color`:``;return S({"*.{vue,html,htm,md}":[e&&`garou`,r&&`prettier -w -u${i}`,t&&`stylelint --fix -- ${i}`,n&&`eslint --fix ${i}`],"*.{ts,tsx,mts,cts}":[e&&`garou`,r&&`prettier -w -u${i}`,n&&`eslint --fix ${i}`],"*.{js,jsx,mjs,cjs,wxs,qs}":[e&&`garou`,r&&`prettier -w -u${i}`,n&&`eslint --fix ${i}`],"*.{c,sc,le,wx,q,tt,jx,ac}ss":[e&&`garou`,r&&`prettier -w -u${i}`,t&&`stylelint --fix -- ${i}`],"*.{json,yml,yaml,svg}":[e&&`garou`,r&&`prettier -w -u${i}`],"{*.{jsonc,webmanifest,editorconfig,toml},.{babel,npm}rc}":[r&&`prettier -w -u${i}`],"{*.jenkinsfile,{j,J}enkinsfile}":[r&&`prettier -w -u${i}`],"yarn.lock":[e&&`garou`]})}function w(){let e=h(`devDependencies`),t=`prettier`in e,n=`eslint`in e,r=`stylelint`in e;return{garou:`garou`in e,stylelint:r,eslint:n,prettier:t}}async function T(){let{default:e}=await import(`./lib-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-Dn1JIVgp.mjs";import{execFile as t}from"node:child_process";import{promisify as n}from"node:util";import{resolve as r}from"node:path";import{readFile as i}from"node:fs/promises";import{readFileSync as a,statSync as o}from"fs";import{createRequire as s}from"module";import{isAbsolute as c,resolve as l}from"path";const u=process.cwd(),d=s(import.meta.url);function f(e,t=u){return e.startsWith(`.`)?l(t,e):c(e)?e:d.resolve(e)}function p(e){try{return o(f(e)),!0}catch{return!1}}function m(e){try{let t=a(f(e),`utf8`);return JSON.parse(t)}catch{return{}}}function h(e,t={}){let n=m(`./package.json`);if(e){let{[e]:r=t}=n;return r}return n}const g=n(t),_={"body-leading-blank":[1,`always`],"body-max-line-length":[2,`always`,100],"footer-leading-blank":[1,`always`],"footer-max-line-length":[2,`always`,100],"header-max-length":[2,`always`,100],"subject-case":[0],"subject-empty":[2,`never`],"subject-full-stop":[2,`never`,`.`],"type-case":[2,`always`,`lower-case`],"type-empty":[2,`never`],"type-enum":[2,`always`,[`build`,`chore`,`ci`,`docs`,`feat`,`fix`,`perf`,`refactor`,`revert`,`style`,`test`]],"scope-case":[0],"body-case":[0],"header-case":[0]};async function v(e=process.cwd()){let{stdout:t}=await g(`git`,[`rev-parse`,`--git-path`,`COMMIT_EDITMSG`],{cwd:e,encoding:`utf8`});return r(e,t.trim())}async function y(){return i(await v(),`utf8`)}async function b(){let e=await y(),t=await import(`./lint-CvrvpJvb.mjs`).then(e=>e.default.default||e.default),n=await import(`./lib-B9YSDxfE.mjs`).then(e=>e.default.default||e.default),r=await t(e,_);return{result:r,output:await n({results:[r]})}}function x(e){e.command(`commit`,`Lint git commit message`,{},()=>{b().then(({result:e,output:t})=>{e.valid?console.log(`Pass.`):(console.log(`Fail:`),console.log(t),process.exitCode=1)}).catch(e=>{console.error(e),process.exitCode=1})})}function S(e){let t=Object.entries(e).map(([e,t])=>[e,t.filter(Boolean)]).filter(([e,t])=>t.length);return t.length>0?Object.fromEntries(t):void 0}function C({garou:e,stylelint:t,eslint:n,prettier:r}){let i=process.stdin.isTTY?` --color`:``;return S({"*.{vue,html,htm,md}":[e&&`garou`,r&&`prettier -w -u${i}`,t&&`stylelint --fix -- ${i}`,n&&`eslint --fix ${i}`],"*.{ts,tsx,mts,cts}":[e&&`garou`,r&&`prettier -w -u${i}`,n&&`eslint --fix ${i}`],"*.{js,jsx,mjs,cjs,wxs,qs}":[e&&`garou`,r&&`prettier -w -u${i}`,n&&`eslint --fix ${i}`],"*.{c,sc,le,wx,q,tt,jx,ac}ss":[e&&`garou`,r&&`prettier -w -u${i}`,t&&`stylelint --fix -- ${i}`],"*.{json,yml,yaml,svg}":[e&&`garou`,r&&`prettier -w -u${i}`],"{*.{jsonc,webmanifest,editorconfig,toml},.{babel,npm}rc}":[r&&`prettier -w -u${i}`],"{*.jenkinsfile,{j,J}enkinsfile}":[r&&`prettier -w -u${i}`],"yarn.lock":[e&&`garou`]})}function w(){let e=h(`devDependencies`),t=`prettier`in e,n=`eslint`in e,r=`stylelint`in e;return{garou:`garou`in e,stylelint:r,eslint:n,prettier:t}}async function T(){let{default:e}=await import(`./lib-BJGqA6IM.mjs`);return e({allowEmpty:!0,concurrent:!0,config:C(w()),cwd:process.cwd(),debug:!1,quiet:!1,relative:!1,stash:!0})}function E(e){e.command(`staged`,`Lint and format git staged files`,{},()=>{T().then(e=>{process.exitCode=+!e}).catch(e=>{console.error(e),process.exitCode=1})})}var D=/* @__PURE__ */ e({builder:()=>A,command:()=>O,description:()=>``});const O=`lint`,k=``;function A(e){x(e),E(e),e.demandCommand(1,"Typing `commit` or `staged`")}export{p as a,D as i,O as n,k as r,A as t};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nice-move/cli",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.3",
|
|
4
4
|
"description": "Frontend develop helper for frontend development",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@commitlint/format": "^21.2.3",
|
|
44
44
|
"@commitlint/lint": "^21.2.4",
|
|
45
45
|
"execa": "^10.2.1",
|
|
46
|
-
"lint-staged": "^17.6.
|
|
46
|
+
"lint-staged": "^17.6.1",
|
|
47
47
|
"settingz": "^0.2.0"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|