makesure开源项目

我要开发同款
匿名用户2021年11月09日
81阅读

技术信息

开源地址
https://gitee.com/J_Sky/jiance
授权协议
MIT License

作品详情

makesure

Simpletask/commadruerispiredbymakewithdeclarativegoalsaddepedecies.

Thesimplestwaytothikofthistoolistohaveawaytohave"shortcuts"(akagoals)tosomepiecesofscripts.Thiswayallowstocallthemeasilywithouttheeedtocalllogshelloe-liersistead.

ExampleMakesurefile:

@goaldowloaded@reached_if[[-fcode.tar.gz]]wgethttps://domai/code.tar.gz@goalextracted@depeds_odowloadedtarxzfcode.tar.gz@goalbuilt@depeds_oextractedpmistallpmrubuild@goaldeployed@depeds_obuiltscp-C-rbuild/*user@domai:~/www@goaldefault@depeds_odeployed

Nowtoruthewholebuildyoujustissue./makesurecommadiafolderwithMakesurefile(defaultgoalwillbecalled).

Youcaaswellcallsiglegoalexplicitly,example./makesurebuilt.

Alsopayattetioto@reached_ifdirective.Thisoeallowsskippiggoalifit'salreadysatisfied.Thisallowstospeedupsubsequetexecutios.

Bydefault,allscriptsisidegoalsareexecutedwithbash.Ifyouwattouseshjustadd@shellshdirectiveatstartoftheMakesurefile.

FeaturesZero-istallVeryportableVerysimple,olybaremiimumoftrulyeededfeatures.Youdo’teedtolearawholeewprogrammiglaguagetousethetool!Literallyit’sgoals+depedecies+hadfulofdirectives+bash/shell.Muchsaeradsimplermakeaalog.Abuchofusefulbuilt-ifacilities:timigthegoal'sexecutio,listiggoalsiabuildfile,ameastospeed-uprepeatedbuilds.Thesytaxofabuildfileisalsoavalidbash/shell(thoughsematicsisdifferet).ThiscatosomeextetbeiuseforeditigiIDE.Usage$./makesure-hmakesurever.0.9.13Usage:makesure[optios...][-fbuildfile][goals...]-f,--filebuildfilesetbuildfiletouse(defaultMakesurefile)-l,--listlistallavailableo-@privategoals-la,--list-alllistallavailablegoals-d,--resolvedlistresolveddepedeciestoreachgivegoals-D"var=val",--defie"var=val"override@defievalues-s,--siletsiletmode-olyoutputwhatgoalsoutput-t,--timigdisplayexecutiotimesforgoalsadtotal-x,--tracigeabletracigibash/shvia`set-x`-v,--versiopritversioadexit-h,--helpprithelpadexit-U,--selfupdateupdatemakesuretolatestversioIstallatio

Sicemakesureisatiyutilityrepresetedbyasiglefile,therecommededistallatiostrategyistokeepitlocaltoaprojectwhereit'sused(thismeasicoderepository).Notolythiselimiatestheeedforrepetitiveistallatioforeverydevoaproject,butalsoallowsusigseparatemakesureversioperprojectadupdateolyaseeded.

wget"https://raw.githubusercotet.com/xoixx/makesure/mai/makesure?toke=$(date+%s)"-Omakesure&&\chmod+xmakesure&&echo"makesure$(./makesure-v)istalled"Update

Updatesmakesureexecutabletolatestavailableversioi-place:

./makesure-UPrerequisitesOS

makesurewillruoayevirometwithPosixshellavailable.Testedadofficiallysupportedare:

LiuxMacOSWidows(viaGitBash)AWK

ThecoreofthistoolisimplemetediAWK.AlmostallmajorimplemetatiosofAWKwillwork.TestedadofficiallysupportedareGawk,BWK,mawk.ThismeasthatthedefaultAWKimplemetatioiyourOSwillwork.

ThetoolwillotworkwithBusyboxawk.

CoceptsBuildfileisatextfileamedMakesurefile.Buildfilecosistsofapreludeadasetofgoals.Buildfileusesdirectives.Preludeisapieceofashellscript(cabeempty)thatgoesbeforegoals.Thepurposeofpreludeisto@defie(lik)globalvariablesvisibletogoals.Preludeolyrusoce.Agoalisalabeledpieceofshell.Agoalcadeclaredepedeciesoothergoals.Durigexecutioeachrefereceddepedecywillruolyocedespitetheumberofoccurrecesidepedecytree.Depedecieswillruiproperorderaccordigtotheiferredtopologicalorder.Depedecyloopswillbereportedaserror.Goalbodiesareexecutediseparateshellivocatios.Itmeas,youca’teasilypassvariablesfromoegoaltoaother.Thisisdoeopurposetoeforcedeclarativestyle.Bydefault,bothpreludeadgoalsareruwithbash.Youcachagetoshwith@shellshiprelude.Forcoveieceiallshellivocatios(prelude,goals,etc.)thecurretdirectoryisautomaticallysettotheoeofMakesurefile.Typically,thisistherootoftheproject.Thisallowsusigrelativepathswithoutbotherigofthewaythebuildisru.Goalcadeclare@reached_ifdirective(lik).Thisallowsskippiggoalexecutioifit'salreadysatisfied.Directives@optios

Olyvalid:iprelude(meaigbeforeay@goaldeclaratio).

Validoptios:timig,tracig,silet

@optiostimig

Willmeasureadlogeachgoalexecutiotime+totaltime.

ExampleMakesurefile:

@optiostimig@goala@depeds_obecho"Executiggoal'a'..."sleep1@goalbecho"Executiggoal'b'..."sleep2

Ruig:

$./makesureagoal'b'...Executiggoal'b'...goal'b'took2.003sgoal'a'...Executiggoal'a'...goal'a'took1.003stotaltime3.006s

SmallissueexistswiththisoptioomacOS.DuetoBSD'sdateotsupportig+%Nformattigoptio,thedefaultprecisiooftimigsis1sec.Tomakeit1msprecise(ifthisisimportat)justistallGawk(brewistallgawk).IthiscaseGawkbuilt-igettimeofdayfuctiowillbeused.

@optiostracig

Willtracetheexecutedshellscript.Thisactivatesset-xshelloptiouderthehood.

@optiossilet

Bydefaultmakesurelogsthegoalsbeigexecuted.Usethisoptioifthisisotdesired(youolyeedtheoutputofyourowcodeigoals).

@defie

Olyvalid:iprelude.

Usethisdirectivetodeclareglobalvariable(visibletoallgoals).Thevariablewillbedeclaredasevirometvariable(viaexport).

Example:

@defieA=hello@defieB="${A}world"

Variabledefiedwith@defiecabeoverriddewithavariablepassediivocatiovia-Dparameter.

Overalltheprecedeceforvariablesresolutiois(higherprioritytop):

./makesure-DVAR=1@defieVAR=2iMakesurefileVAR=3./makesure@shell

Olyvalid:iprelude.

Validoptios:bash(default),sh

Setstheshelliterpretertobeusedforexecutioofpreludeadgoals.

Example:

@shellsh@goal

Sytax#1:

@goalgoal_ame[@private]

Defiesagoal.@privatemodifierisoptioal.Whegoalisprivate,itwo'tshowi./makesure-l.Tolistallgoalsicludigprivateuse./makesure-la.

Liesthatgoafterthisdeclaratiolie(butbeforeext@goaldeclaratiolie)willbetreatedasashellscriptforthebodyofthegoal.Example:

@goalhelloecho"Helloworld"

HavigtheaboveiMakesurefilewillproduceextoutputwherawith./makesurehello

helloworld

Idetatioigoalbodyisoptioal,ulikemake,sobelowisperfectlyvalid:

@goalhelloecho"Helloworld"

Ivokig./makesurewithoutargumetswillattempttocallthegoalameddefault:

@goaldefaultecho"I'mdefaultgoal"

Sytax#2:

@goal[goal_ame]@glob<globpatter>[@private]

Thisoeiseasytoillustratewithaexample:

@goalprocess_file@glob*.txtecho$ITEM$INDEX$TOTAL

Isequivalettodeclarigthreegoals

@goalprocess_file@a.txt@privateechoa.txt02@goalprocess_file@b.txt@privateechob.txt12@goalprocess_file@depeds_oprocess_file@a.txt@depeds_oprocess_file@b.txt

iff

$lsa.txtb.txt

Forcoveiece,youcaomitameicaseofglobgoal:

@goal@glob*.txtecho$ITEM$INDEX$TOTAL

asequivaletfor

@goala.txt@privateechoa.txt02@goalb.txt@privateechob.txt12@goal*.txt@depeds_oa.txt@depeds_ob.txt

Soessetiallyoeglobgoaldeclaratioexpadstomultiplegoaldeclaratiosbasedofilespresetiprojectthatmatchtheglobpatter.Shellglobexpasiomechaismapplies.

Theusefulusecaseherewouldbetorepresetasetoftestfilesasasetofgoals.Theexamplecouldbefouditheproject'sowbuildfile.

Whythismaybeuseful?Imagieiyourodejsapplicatioyouhavetest1.js,test2.js,test3.js.NowyoucausethisMakesurefile

@goal@globtest*.jsecho"ruigtestfile$INDEXoutof$TOTAL..."ode$ITEM

tobeabletorueachtestidividually(./makesuretest2.jsforexample)adalltogether(./makesure'test*.js').

Icaseifyoueedtoglobthefileswithspacesitheirames,pleasechecktheamigrulessectiobelow.

@doc

Olyvalid:iside@goal.

Providesadescriptioforagoal.

ExampleMakesurefile:

@goalbuild@docbuildstheprojectecho"Buildig..."@goaltest@docteststheprojectecho"Testig..."

Ruig./makesure-lwillshow

Availablegoals:build:buildstheprojecttest:teststheproject@depeds_o

Olyvalid:iside@goal.

Sytax:

@depeds_ogoal1[goal2[goal3[...]]]

Declaresadepedecyoothergoal.

ExampleMakesurefile:

@goalaechoa@goalb@depeds_oaechob

Ruig./makesurebwillshow

goal'a'...agoal'b'...b

Youcadeclaremultipledepedeciesforagoal:

@goalaechoa@goalb@depeds_oaechob@goalcechoc@goald@depeds_obcechod

Ruig./makesuredwillshow

goal'a'...agoal'b'...bgoal'c'...cgoal'd'...d

Circulardepedecywillcauseaerror:

@goala@depeds_ob@goalb@depeds_oc@goalc@depeds_oa

Ruig./makesureawillshow

Thereisaloopigoaldepedeciesviaa->c@reached_if

Olyvalid:iside@goal.

Sytax:

@reached_if<coditio>

Allowsskippiggoalexecutioifit'salreadysatisfied.Thisallowstospeedupsubsequetexecutios.Olyoepergoalallowed.Thegoalwillbecosideredfulfilled(adthuswillotru)ifcoditioexecutedasashellscriptretursexitcode0.Aycoditioevaluatioisdoeolyoce.

ExampleMakesurefile:

@goalfile_created@reached_if[[-f./file.txt]]echo"Creatigfile..."echo"helloworld">./file.txt

Ifyouru./makesurefile_createdthefirsttime:

goal'file_created'...Creatigfile...

Ifyouru./makesurefile_createdthesecodtime:

goal'file_created'[alreadysatisfied].

Itisagoodpracticetoamegoalsthatdeclare@reached_ifipasttese.

@lib

Sytax:

@lib[lib_ame]

Helpswithcodereuse.Occasioallyyoueedtorusimilarcodeimultiplegoals.Themostobviousapproachwouldbetoplaceacodeitoshared.shadivokeitibothgoals.Thedowsideisthatowyoueedaadditioalfile(s)adthebuildfileisomoreself-cotaied.@libtotheresque!

Theusageissimple:

@liblib_amea(){echoHello$1}@goalhello_world@use_liblib_ameaWorld

Forsimplicitycaomitame:

@liba(){echoHello$1}@goalhello_world@use_libaWorld

Operatioally@use_libisjustsubstitutedbycotetofacorrespodig@lib'sbody,asiftheabovegoalisdeclaredlike:

@goalhello_worlda(){echoHello$1}aWorld@use_lib

Olyvalid:iside@goal.

Olysigle@use_libpergoalisallowed.

Namigrules

It'srecommededthatyouameyourgoalsusigalphaumericchars+uderscore.

However,it'spossibletoameagoalaywayyouwatprovidedthatyouapplyproperescapig:

@goal'amewithspaces'#allcharsbetwee''haveliteralmeaig,sameasishell,'itselfisotallowediit@goal$'amethatcotais\'siglequote'#ifyoueedtohave'iastrig,usedollar-strigsadescapeit@goalusual_ame

Now./makesure-lgives:

Availablegoals:'amewithspaces'$'amethatcotais\'siglequote'usual_ame

Note,howgoalamesarealreadyescapedioutput.Thisistomakeiteasierforyoutocallitdirectly:

./makesure$'amethatcotais\'siglequote'

Sameamigrulesapplytootherdirectives(like@doc).

Usuallyyouwo'teedthisescapigtricksofte,buttheycabeespeciallyiusefor@globgoalsiftherelevatfileshavespacesithem:

@goal@glob'filewithspaces*.txt'

Moreifoothistopiciscovereditheissue.

DesigpriciplesCovetioovercofiguratio.Miimalistic.Baremiimumoffeaturesthatcomposegoodwitheachother.Thereshouldbeoewaytodothethig.OverallZeofPytho.Thikhardbeforeaddigewfeature.Thikofadamageitcouldcauseusedimproperly.Thikofcogitivecomplexityititroduces.Olyaddafeaturegeericeoughtocoverlotsofusefulcasesisteadofjustsomecorercases.Let'sbetterhavealistofrecipesforthelatter.Dootitroduceujustifiedcomplexity.Usershouldotbeforcedtolearawholeewprogrammiglaguagetoworkwithatool.Istead,thetoolisbasedolimitedsetofsimplecocepts,likegoals+depedecies+hadfulofdirectives+familiarshelllaguage(bash/sh).Worseisbetter.Pricipleofleastsurprise.Testscoverageisamust.OmittedfeaturesGoalswithparameters,likeijustWedeliberatelydo'tsupportthisfeature.Theideaisthatthebuildfileshouldbeself-cotaied,sohavealltheiformatiotoruiit,oexteralparametersshouldberequired.Thisshouldbemucheasierforthefialusertoruabuild.Theotherreasoisthattheideaofgoalparameterizatiodoes'tplaywellwithdepedecies.Thetoolhoweverhaslimitedparameterizatiocapabilitiesvia./makesure-DVAR=value.IcludesThisisacosiderablecomplicatiotothetool.Also,itmakesthebuildfileotself-cotaied.Shellsotherthabash/shLessportablebuild.Ifyoueedtouse,say,pythoforagoalbody,it'suclearwhyyoueveeedmakesureatall.Besides,youalwayscajustusepytho-c"script".Customowprogrammiglaguage,likemakehasWethikthatthiswouldbeujustifiedcomplexity.Webelievethatthepowerofshelliseough.parallelexecutiomakesureisataskruer,otafull-fledgedbuildtool,likemake,ijaorbazel.Soifyoueedoe,justuseaproperbuildtoolofyourchoice.Developerotes

FidsomecotributoristructiosiDEVELOPER.md.

Similartoolsjusthttps://github.com/casey/justjustisahadywaytosaveadruproject-specificcommadsTaskfilehttps://github.com/adriacooey/TaskfileATaskfileisabash[...]scriptthatfollowsaspecificformat[...],sitsitherootofyourproject[...]adcotaisthetaskstobuildyourproject.Taskhttps://github.com/go-task/taskTaskisataskruer/buildtoolthataimstobesimpleradeasiertousetha,forexample,GNUMake.hakuhttps://github.com/VladimirMarkelov/hakuAtask/commadruerispiredby'make'guphttps://github.com/timbertso/gupGupisageeralpurpose,recursive,topdowsoftwarebuildsystem.redohttps://github.com/apewarr/redoredo-arecursivebuildsystem.Smaller,easier,morepowerful,admorereliablethamake.Tuphttps://github.com/gittup/tupTupisafile-basedbuildsystemforLiux,OSX,adWidows.Pleasehttps://github.com/thought-machie/pleasePleaseisacross-laguagebuildsystemwithaemphasisohighperformace,extesibilityadreproducibility.

功能介绍

makesure Simple task/command runner inspired by make with declarative goals and dependencies. The...

示例图片

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论