@nice-move/cli
Version:
Frontend develop helper for frontend development
1 lines • 3.29 kB
JavaScript
import{__export as e}from"./chunk-CYNyJ7h0.mjs";import{resolve as t}from"node:path";import{isAbsolute as n,resolve as r}from"path";import{readFileSync as i,statSync as a}from"fs";import{createRequire as o}from"module";import{readFile as s}from"node:fs/promises";const c=process.cwd(),l=o(import.meta.url);function u(e,t=c){return e.startsWith(`.`)?r(t,e):n(e)?e:l.resolve(e)}function d(e){try{return a(u(e)),!0}catch{return!1}}function f(e){try{let t=i(u(e),`utf8`);return JSON.parse(t)}catch{return{}}}function p(e,t={}){let n=f(`./package.json`);if(e){let{[e]:r=t}=n;return r}return n}const m={"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]};function h(){return t(process.cwd(),`.git/COMMIT_EDITMSG`)}function g(){return s(h(),`utf8`)}async function _(){let e=await g(),t=await import(`./lint-Cidlfm-v.mjs`).then(e=>e.default.default||e.default),n=await import(`./lib-DYR86uKu.mjs`).then(e=>e.default.default||e.default),r=await t(e,m),i=await n({results:[r]});return{result:r,output:i}}function v(e){e.command(`commit`,`Lint git commit message`,{},()=>{_().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 y(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 b({garou:e,stylelint:t,eslint:n,prettier:r}){let i=process.stdin.isTTY?` --color`:``;return y({"*.{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 x(){let e=p(`devDependencies`),t=`prettier`in e,n=`eslint`in e,r=`stylelint`in e,i=`garou`in e;return{garou:i,stylelint:r,eslint:n,prettier:t}}async function S(){let{default:e}=await import(`./lib-Dzjqv24Q.mjs`),t=x(),n=b(t);return e({allowEmpty:!0,concurrent:!0,config:n,cwd:process.cwd(),debug:!1,quiet:!1,relative:!1,shell:!1,stash:!0})}function C(e){e.command(`staged`,`Lint and format git staged files`,{},()=>{S().then(e=>{process.exitCode=e?0:1}).catch(e=>{console.error(e),process.exitCode=1})})}var w={};e(w,{builder:()=>D,command:()=>T,description:()=>E});const T=`lint`,E=``;function D(e){v(e),C(e),e.demandCommand(1,"Typing `commit` or `staged`")}export{D as builder,T as command,E as description,d as isReachable,w as lint_exports};