diff --git a/certs/2776-cert.pem b/certs/2776-cert.pem index 1a1bb5c..17f2190 100644 --- a/certs/2776-cert.pem +++ b/certs/2776-cert.pem @@ -1,31 +1,31 @@ -----BEGIN CERTIFICATE----- MIIFPzCCAycCAgH0MA0GCSqGSIb3DQEBCwUAMGYxCzAJBgNVBAYTAlVTMREwDwYD VQQIDAhJbGxpbm9pczEQMA4GA1UEBwwHQ2hpY2FnbzETMBEGA1UECgwKU2FmZW1v -YmlsZTEMMAoGA1UECwwDUEtJMQ8wDQYDVQQDDAZMZXZlbDEwHhcNMTkxMDI4MDky -MjA2WhcNMjkxMDI1MDkyMjA2WjBkMQswCQYDVQQGEwJVUzERMA8GA1UECAwISWxs +YmlsZTEMMAoGA1UECwwDUEtJMQ8wDQYDVQQDDAZMZXZlbDEwHhcNMTkxMDI4MDk1 +NDQ3WhcNMjkxMDI1MDk1NDQ3WjBkMQswCQYDVQQGEwJVUzERMA8GA1UECAwISWxs aW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xEzARBgNVBAoMClNhZmVtb2JpbGUxDDAK BgNVBAsMA1BLSTENMAsGA1UEAwwEMjc3NjCCAiIwDQYJKoZIhvcNAQEBBQADggIP -ADCCAgoCggIBALETaVdg2qEQPuYYECYrCfIRFNJKO97qeA9iO5QvkkkmT0v20kTF -hDQBcWuJDbEAtW94ECS9LPFAlhDPEOMa/YIsrMFURYNGWCkcVGwjFEZHn0KiWjU4 -rRlT43bgE8Ns62uzYykH+lWOBjD8Fg31dLI0ymg4RvLh0lEAjdeELvcX3qZUFEs6 -2d5S5VjXpI3UXLMxwJlw36KyWfk0iPi0aE7p3niwhlR2LQglbboMFley9nEbkXTe -ZcQSlkH5vqIcnTDFWrZbk0PLJ6mKIgSuN2gWZg8B1jRNhI2UqWvPW/I+8NZHesyM -QVnYzUJWsyUGK9j5F+b+tEaMSX2mcUgEpeR4S8h+Fb5Iryu9ssKchKyBxu7yj9PC -Bt/E1cT31i6Tv7EQ6iqg7H4Mv0sJAK/YaXPPh0xwcocDidNP7z/clj2CTtGmgXv5 -GPariW5v/wMQgFho7PyQM6h9pBzHAnT7RBEK3CAsyl4Sy3YxogBKi55sE+C3NpDr -eUk1TkjFtT4zq0tXTTOg/Sgds/qpUtObf2NJJ4lykjdk5PTLw7Uff79NiUeESp8J -Mh5fkhvIpuA/Ffmv0/qgsGSLbadT9dmLuOHNF0sFPqKWjrfQIdadMA+QBbS+BC94 -YIj18PAHN4n003qnPfBPuuHbtaWmSPfGlYmVPUacOAwwEfzVO4wTFGjDAgMBAAEw -DQYJKoZIhvcNAQELBQADggIBANgxypzg34sBC91pUNLGngp5XdTNJZQ2k2jbtkSm -/16PjPC0EbdaKVzBeD53ICu6v8r7333vLqMX1jln7SWdQSpTtc8AJwNuatxV8zo/ -mMsahnlD2ZoKa4f5pCVkPMBggkRVVgj9L8dQcChyrJPnQo3C7Kjg1dMNfPVmhYxs -5A8jSYwDHTIc4Yl+N+nZPf9bcscP0kmeaT/Tdx3eKf818ZKGaQ4ZMHQqB/9GChhH -8iTn5KssUCI1geY/8RFrBbF/qRW7LZjPY57EfGU0v1AMTJHqiMFJQbBJZgVV22dG -uM8Y/eR5+7Sm6PyABDN0V4dWYmUg/c2+lWuMP6qnM1xY7JwBcpEj+pmgX9sj1IGC -uY8zg4gRcDd9zRfym95zS+RczPP3eC8nb/cvgpkirFr02bUPDMhLgBtERzaeiP9r -XsvF4ny6TvGS8PPH5u1bE9rL/oAEi/AasZ/XZAdcFiI0aOXadf8qwNGN//985CJ9 -EL3RQT/EncLWrGDfsl11dhGgw+fVFfH3P102YRsobK0PwKE3H0WEs8mmaEysr/Jh -7ZPPs5ogOTsSvWgZrNBj9pq06N0+b8SZIL98CK63A4Dr0DH/VYLojE16oJQkbAQu -ksO6t6v/2uy+W2vJE0ghdNPbLFSUNcVwmPXb8Vm4bQv6NzbpLg8npsO1xG0ATJ7h -AKV5 +ADCCAgoCggIBANK8qZgFQfIvHZO7pUSfCf5fOWTV17xlR2LU9XkAc6BGakkzfpQu +XETcgLMhQNDDOYr6oOdu3QQCbpwX2OlYVM/TCg42ktStr8KhdAlt/IAhGyiDNSWZ +tj6Fz1Q+mqOSsSLnB1oh0Sj4Rb7VjZeyKTFx7yEsliBqozqS0PJRt6ns8BtXJZmU +I4XI5vsWaSZyk+ZWo3GrG30WNiQACYOg2onqGEbFPOVm4U2kw4x+VjU2FPnMU32S +s39CTqPJMtRXFtbRq1MTTB/3u3b2LZbq5X9YUc85MiCwN0VMMrTjoonvtugZdwBS +MHak5V1y0BLcJCxP4YAUnccKouuCkZOmr8dN92kZrv2rgcwF4mSgd7QoADEBgEAl +7vyfJSth+YXnVx3m0NASJCKhFqSGK7jiWBDIDOT+SsFpHR9ZAL9BshD6Xk8Ezgax +BlibZocoP0sH0a0Vl1HW+WS2EL4nHSe6nIq95QblRlbrWVsSqsYCr2mdi/qEDlZr +mwJAxwjO10nRuU54pMNq9qQyR9NMnDSO2qcpow4d8jjlJMMCgTQgL2zFPFLq2cgK +OfXhMCF0lmDNbAbPzlriXASqTaTbl3nDoMI4LXcA1kdz0vMjk2sKtTqPrKseYULh +mrZWgFkpgTzRHlr3arktiJYedM7XHu/FdXTmHx4ArZIMrLgJrLEY9DOVAgMBAAEw +DQYJKoZIhvcNAQELBQADggIBAD6W04weozD5JvKaqExvPwlBFQnMhj7/hZhLh18k +0MPFUBla+9dWUGBOjsIwjXMUHNyfR+q8LkwoXt3uqGd/aog5urfptDb3NXV0BBdy +EvkGePPaOg9VaztSFqIiyWaW85eF5Y/wQ+HigbJlL4tNHhnz+o+LzuqtjjsmaBMW +CabuQqMuW30MjPzdNVf5af16XYNpT8Yu0n+o5sCzrxt6+1iZu+nbfPcnfmKOTvJ1 +aNuXdcEwIVJJoBuUUoKCWaEm2waRuOovHJju/vjD5iS7DP4RBNnR+oaITAUZsEIA +bp4WJlT37IZJEIjNMbK45X/epGArcC/mrGI41nHmyYNaO1XLLuN4ih9+sHnaMzV3 +DTZLzRsJA0pGxMng1aCdlS0j4gBto+NP0AWa2b4FHVzH59upHKCYx8E7KsgTb1DY +7W8n+TFIPZWKvJ7E2eO0z9G3j3dkVJFs9ppUh2VGOEFMOiUa3ulL3x2Ce9kPTe0O +5gysuEhMWnieNf3lAr+WWNkJIP8AQLSMrJIIDcgdnxh2XmqpFlwLbkQHwwaOXHYL +KCZwpqGGiFQRr1aNGvLzSmRT6CJTafjxIm5DFiPUeFpXO/NzUEx5DHxgOSJCtlqA +PaniYd7yNMcqL5Z+jZRgoJFContC6x4BsX1O/tDxxeeSOGMPh2e/Oq3bXy7Ps3DA +t+YV -----END CERTIFICATE----- diff --git a/certs/2776-csr.pem b/certs/2776-csr.pem index 5353227..53183e1 100644 --- a/certs/2776-csr.pem +++ b/certs/2776-csr.pem @@ -2,26 +2,26 @@ MIIEqTCCApECAQAwZDELMAkGA1UEBhMCVVMxETAPBgNVBAgMCElsbGlub2lzMRAw DgYDVQQHDAdDaGljYWdvMRMwEQYDVQQKDApTYWZlbW9iaWxlMQwwCgYDVQQLDANQ S0kxDTALBgNVBAMMBDI3NzYwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC -AQCxE2lXYNqhED7mGBAmKwnyERTSSjve6ngPYjuUL5JJJk9L9tJExYQ0AXFriQ2x -ALVveBAkvSzxQJYQzxDjGv2CLKzBVEWDRlgpHFRsIxRGR59Colo1OK0ZU+N24BPD -bOtrs2MpB/pVjgYw/BYN9XSyNMpoOEby4dJRAI3XhC73F96mVBRLOtneUuVY16SN -1FyzMcCZcN+isln5NIj4tGhO6d54sIZUdi0IJW26DBZXsvZxG5F03mXEEpZB+b6i -HJ0wxVq2W5NDyyepiiIErjdoFmYPAdY0TYSNlKlrz1vyPvDWR3rMjEFZ2M1CVrMl -BivY+Rfm/rRGjEl9pnFIBKXkeEvIfhW+SK8rvbLCnISsgcbu8o/TwgbfxNXE99Yu -k7+xEOoqoOx+DL9LCQCv2Glzz4dMcHKHA4nTT+8/3JY9gk7RpoF7+Rj2q4lub/8D -EIBYaOz8kDOofaQcxwJ0+0QRCtwgLMpeEst2MaIASouebBPgtzaQ63lJNU5IxbU+ -M6tLV00zoP0oHbP6qVLTm39jSSeJcpI3ZOT0y8O1H3+/TYlHhEqfCTIeX5IbyKbg -PxX5r9P6oLBki22nU/XZi7jhzRdLBT6ilo630CHWnTAPkAW0vgQveGCI9fDwBzeJ -9NN6pz3wT7rh27Wlpkj3xpWJlT1GnDgMMBH81TuMExRowwIDAQABoAAwDQYJKoZI -hvcNAQELBQADggIBAJHZ8B4sV6m82O1hvIT0XQ9q1GkrM4g8tLvEm7nI4woPoNMV -DpKbuQwhECewzLDHpU6PxhCc6rHZ8FpMR8RqXtyKOz1eg0r7HzOC8zgH0SxITY3b -NGtHlCEpxuIt8zbFa5hFxlyufix4eq7gOL8krIokCZ1AXR47ASTvEcn7wwwtX/k0 -i0OcnD+ypV4xspxDcG9z4z1sAu13KfS0eYMnCEwWeJaBURY5SF7pLB5mlWeuAKxn -PpqeeJEd0AdAtldOMQd7ls/O+/XV8h0fV6mAo3HkwJ08kysg5cqo+C5Wwzckdyb+ -DWgsLIzBtJyS8Y2Vne5bYGPnmXjX1zBN/JQyQ8YRnTembLccSBCC8tlFz6247SVr -jgfJa2KLQm8Di/9EUeH5ZyqJnsdWkFaR6+y7rSOZXaDJgiG3NxCLWnSwxEMKuG5b -VjfduaYSSDWttFtiGnIh9y/NeKTZ5zRruHRCxRluLUw1VFV7OpwVwhyGSCs7zdDF -Qpxhcbc7Svfz8QhD+ZDtMhrcUrkstpaE9WSOls4tWIpoiQMIPXsW3IJpaJE8cVGi -9Hq7elkxt5pN67QzLDDDIbMxTL+gYjYCZwjgXoQVVOlv672HYtYv++I3rWlmHUF9 -Aq3LUE+UwtYI1I3SekigJSCn9k0c5/P173RkzK/iV1DyznIm40dyURd0ifYB +AQDSvKmYBUHyLx2Tu6VEnwn+Xzlk1de8ZUdi1PV5AHOgRmpJM36ULlxE3ICzIUDQ +wzmK+qDnbt0EAm6cF9jpWFTP0woONpLUra/CoXQJbfyAIRsogzUlmbY+hc9UPpqj +krEi5wdaIdEo+EW+1Y2Xsikxce8hLJYgaqM6ktDyUbep7PAbVyWZlCOFyOb7Fmkm +cpPmVqNxqxt9FjYkAAmDoNqJ6hhGxTzlZuFNpMOMflY1NhT5zFN9krN/Qk6jyTLU +VxbW0atTE0wf97t29i2W6uV/WFHPOTIgsDdFTDK046KJ77boGXcAUjB2pOVdctAS +3CQsT+GAFJ3HCqLrgpGTpq/HTfdpGa79q4HMBeJkoHe0KAAxAYBAJe78nyUrYfmF +51cd5tDQEiQioRakhiu44lgQyAzk/krBaR0fWQC/QbIQ+l5PBM4GsQZYm2aHKD9L +B9GtFZdR1vlkthC+Jx0nupyKveUG5UZW61lbEqrGAq9pnYv6hA5Wa5sCQMcIztdJ +0blOeKTDavakMkfTTJw0jtqnKaMOHfI45STDAoE0IC9sxTxS6tnICjn14TAhdJZg +zWwGz85a4lwEqk2k25d5w6DCOC13ANZHc9LzI5NrCrU6j6yrHmFC4Zq2VoBZKYE8 +0R5a92q5LYiWHnTO1x7vxXV05h8eAK2SDKy4CayxGPQzlQIDAQABoAAwDQYJKoZI +hvcNAQELBQADggIBAHPwaKOVXazkpF2bhPSZCCm9ZGS8h8U5WQLHxIl0az1MkOeE +JXfmPGIO5SJLac00wll0ScBrnWpUtQRuleuQE1KgybGT8nJwf7iyGTQsikM3Quex +HCzI47NaYhqficJXmrJt0uX3iP0E+kxUeJcpSXXAFGdAswtK1f+vwEkpe/5bxR/9 +4co8oAvzyyDdSGatooo/p8BjFj9gxSafhZpd32JzNM/JbVa9TEB4fa0BO1i2fBcq +KAdKv3NQKq7dp04m9ktVmQbj4yEQUKJUQq3JA04OOwkux2rkcg+YaMO3L8Hb0Ai7 +nHlqwfzTfh1h2k695FAlxMBL3qy6QhQk8/UHR2A0rPtjYGtsY5b+D+LK+kKg3W1V +7+uyoc0R6zasxuWSwAUdzTVrs8mOzAaNnqQs0ZRQq3kVV4pp/9Ja6+UT5A8KllxA +86yc5hs/CfB7l/yyDsdxHCgAD0itvoNQ0gV8YeAkysgIDEIHlVHt9bN0/VVnBo65 +6plm3QiGa66PW6L/AlngEfHSVzGtyroHzz4eBec2tzW5uC1X9I4IdAVRR4TOaPIQ +ML6CBKC5HqphFOHM9CC9ZmDHZZbbGrp6fr4XG6WnQOrNZo6RChcPLeUnDFzmS6no +jYJBgUqE3qJgckMMrSPmZ47sOfkwoX0X11178CwacxPG2Dp7GSlop+a3EYtv -----END CERTIFICATE REQUEST----- diff --git a/certs/2776-key.pem b/certs/2776-key.pem index 4f734b3..bd168be 100644 --- a/certs/2776-key.pem +++ b/certs/2776-key.pem @@ -1,51 +1,51 @@ -----BEGIN RSA PRIVATE KEY----- -MIIJKAIBAAKCAgEAsRNpV2DaoRA+5hgQJisJ8hEU0ko73up4D2I7lC+SSSZPS/bS -RMWENAFxa4kNsQC1b3gQJL0s8UCWEM8Q4xr9giyswVRFg0ZYKRxUbCMURkefQqJa -NTitGVPjduATw2zra7NjKQf6VY4GMPwWDfV0sjTKaDhG8uHSUQCN14Qu9xfeplQU -SzrZ3lLlWNekjdRcszHAmXDforJZ+TSI+LRoTuneeLCGVHYtCCVtugwWV7L2cRuR -dN5lxBKWQfm+ohydMMVatluTQ8snqYoiBK43aBZmDwHWNE2EjZSpa89b8j7w1kd6 -zIxBWdjNQlazJQYr2PkX5v60RoxJfaZxSASl5HhLyH4VvkivK72ywpyErIHG7vKP -08IG38TVxPfWLpO/sRDqKqDsfgy/SwkAr9hpc8+HTHByhwOJ00/vP9yWPYJO0aaB -e/kY9quJbm//AxCAWGjs/JAzqH2kHMcCdPtEEQrcICzKXhLLdjGiAEqLnmwT4Lc2 -kOt5STVOSMW1PjOrS1dNM6D9KB2z+qlS05t/Y0kniXKSN2Tk9MvDtR9/v02JR4RK -nwkyHl+SG8im4D8V+a/T+qCwZIttp1P12Yu44c0XSwU+opaOt9Ah1p0wD5AFtL4E -L3hgiPXw8Ac3ifTTeqc98E+64du1paZI98aViZU9Rpw4DDAR/NU7jBMUaMMCAwEA -AQKCAgAf+ixszh3NNjzVmoTYD6+lGjaTXzp+oAL8bDXsJccaFKP/SNxh9PVR2uzb -iY2CaGlbbugjalJCYvJ2qJ4ZFRewuVadNxWyhjKHggkw2gjgRDDbfKwjrk98Im0S -W5bWFMZS1btTfpBTgOlXUT6+WJQxVl0zAu61D9jGLf5va/x7PMFFciuUBlWv03J9 -X7vkrPPsnFB2pS6Nl/2thjIyD4pCrfMyAlbPy+OH9BJjpaknPzdH572VyE/CX8To -tywY5GfylcEy60il1nscH8jS5Y816c2WajN/kHwegTkzMegd0AX3/EKNy8pFamRu -1W9WgU3LyffqDBcMImtnGHaeldBLLBD4uNewE+mRIMgRNJ2q5+mi4qjs/rSm3GPw -U/dsmAv+pjFSAhXzq69RznOdscPnKOPMmFpdN+Qu3m05YNOLz3w+Te2LrgSCp4SV -+hpdIxHZoUoRIxrVkCh7COUgYaBgZUkXzs9h3aRJ8r9KbKj9Y8aC7eUeCAMID8m8 -5yyiCwTMdJbF9aMPfxcfoybRbsY1ZnpPqBbQb7f5csP3rXHrH92gqQ1lS9fMFLCp -geMkYvyUzU5MPIpJ/0sYeahbrMVFzQfVNNBRH653s99DnHoDkdIQFEmsKjjxeDxs -1jj4BM15LnXJ+aC1kBcDKECxbHKIQlCqDyyfY9SbxM82t/yX2QKCAQEA2MWymBEc -87NZvuols5VSgl0HzrpqZlINBStX07uhyHmMVDk6iTkzXZv9OkEVqn6W6g8PqaCQ -/ddaM8b768Km5wX1nLqzfmPiIJpsy/2vvgoKVmXKOlBQ5mH/q8IJrGv5GFemVyVc -KI0XwGpNBJx+WkKwsExdnsgADNxnEPpFvP+B+VSU3W5uKYqaW/eAAUmCoOCEpsyF -Pso2Dvs3e5URw+KUIttxhzoQaxmLDVo8fQDx10kXHraumvCLFnz9+PaFFw1BJMGJ -XKAdqIWg3E4AiyY0OGwvieQL+jjhAcpASEcT5lqxDgUV9Ooicg/upEctH+ezF0Ks -SqNy+eDq1tJwPwKCAQEA0R63e/mqRiyeT9Rx+s4B3Ih+Pvv8lcrlXzJnQm91z95d -nzWHsZqjUC3ZX8uPl/tTVEjxLIHZmArL8U4D6aAHR89zXP5GRYjq1oclfVJvhO1N -YI6Ktw3VBxwlxbLRebMrW4CquN8dXSocGZYSUd2ESjt3RRot0v8clLYL/vomOFsz -pvhTvVPSrKiXsU14YixFDW3X0SXrdXV1+imJ1MSH0X4GBFseVuDjvilkfB+ewjZu -4CeG42kefWk8lVyJLc9Daw2lUrsjC/QyO7S1CNA74oJ98LFn9MdLRZymo4fCNJ3s -Me4/a7PH3GZXEk8bJj5s90WaynGAVSIPkbOhA8XmfQKCAQEAhYuuTj7kvkJ0/MgV -uAA7V7Lml3aDDExqVw/vyLKkpfQz/sNPC7Egsv/hzty/80yPvtzOgms4SBo/KPzi -wMknt9YVDZx77lasvfdFJZtBhOt8mOOW5bwLSxN+xpsBCKdwS43cHX4Xu6fIxTL4 -Beo/cW36mnJBjwuZ9FJocK4u/pPOyANSvuREm/UWyae9xY07G8+WCYigYiGDklE0 -Sj95NVvGdX8J/wxHhyOyZeR8tWo6k64kvzg+c5fTqGQStylwrtXsly9gZ58BBoxk -oLSxYwiDTWthEitbMamO/WJTnfOkD9s5jvCVKVCBLhIgrDZpV2mQDLl3mXf+4nCt -XPFCUwKCAQBfle7AmEogcVybmLvQrEFlkG5EU+IMhgV6Egvo7hGnxjh9AXbY05o6 -l/p4Mw+bpKFeMUkr0t6nBKhb0BExxJgPVt+gbgmo1wCgtn2IXxniZKWtsPnu2j+5 -VEBfsXDWc/MpjBJ9Fl7RquHVQCd3jA1f8PZ/e4vemgVyZBPvpF+7+tQNSgzcyWfO -y/EqdgLEvP+DN+YiD3ck5V/bzQjXXE3IkBYn/45Kn9j5nunzYnCqzT647thVMkNh -h6zNiNKbQdXLJR2gRzGp0SD08ZCeSrBUxNjUIAMoe8AIPaZdsTwv2M+RsxkCHdcJ -Ay5hjA8Y2Afurr4mMuM6BqufKcA7fUXxAoIBAHt5r0yLEjW5YA5cUajY+FDwLm2Z -7y6aabb9kvQgPrH+rMUwQrniGnzUttsrCV5F7wAhX94vs42rh39vimAdeAzAYxE2 -3kfU95iEBjuKFhbki0eYDr1zkQaRvXll+Rq5KYWwJnDMNpGeEjVqo2gdXa8djl2B -9+QuJjXu347y41tRaFAk9LH0Lq9l2vQ45VL2NR6Cb5+pSwB57SPsrBcdZyP6/AJI -ItlkSkO3/C0+XjDOMBm9YgL5kehH1PIol+ZD21C3vr7Lxm6D64fsdh8MAU/KgSXa -q8/UtSwEYxfgr/3XWtQnOe56x/28djK7TkSKq4w6b7XFjLO4d0hq4xra/us= +MIIJKQIBAAKCAgEA0rypmAVB8i8dk7ulRJ8J/l85ZNXXvGVHYtT1eQBzoEZqSTN+ +lC5cRNyAsyFA0MM5ivqg527dBAJunBfY6VhUz9MKDjaS1K2vwqF0CW38gCEbKIM1 +JZm2PoXPVD6ao5KxIucHWiHRKPhFvtWNl7IpMXHvISyWIGqjOpLQ8lG3qezwG1cl +mZQjhcjm+xZpJnKT5lajcasbfRY2JAAJg6DaieoYRsU85WbhTaTDjH5WNTYU+cxT +fZKzf0JOo8ky1FcW1tGrUxNMH/e7dvYtlurlf1hRzzkyILA3RUwytOOiie+26Bl3 +AFIwdqTlXXLQEtwkLE/hgBSdxwqi64KRk6avx033aRmu/auBzAXiZKB3tCgAMQGA +QCXu/J8lK2H5hedXHebQ0BIkIqEWpIYruOJYEMgM5P5KwWkdH1kAv0GyEPpeTwTO +BrEGWJtmhyg/SwfRrRWXUdb5ZLYQvicdJ7qcir3lBuVGVutZWxKqxgKvaZ2L+oQO +VmubAkDHCM7XSdG5Tnikw2r2pDJH00ycNI7apymjDh3yOOUkwwKBNCAvbMU8UurZ +yAo59eEwIXSWYM1sBs/OWuJcBKpNpNuXecOgwjgtdwDWR3PS8yOTawq1Oo+sqx5h +QuGatlaAWSmBPNEeWvdquS2Ilh50ztce78V1dOYfHgCtkgysuAmssRj0M5UCAwEA +AQKCAgEArcv8Tiyf230x9mG+Bh7nngqoidm2h2A7hG2/WKCfu2H3TBGU5d5qKDx2 +Q8U78C/haBYU12leC216DW+5a5B2ucMBuwEVDSOFHY4L5a74nC8xd7LmBPGFFIFE +oOTUoexb/D3umU3kctZ2ptD2alH7mRSus3xS/78SiT8F5aKxRwnqZ5Hyp3s95Jrw +q8kqxROfmEqBl0AXdoz37668Kfth4HXYuZz3APZc/6zPvTGAJXhJyk3R2XFAacak +ln1bVzXP1zCqC+SRVpf32j9jD+D/jounRLCV/9F0c8lI1Fgb94hkH3zI4NHnuCF8 +LBqBMdyuVIE4p2nZSYsjG/nd15iTw9qZd8bOkKMrxsz5Ir60pKDgMYQ2xmRp3YIu +iImLzDkA3IRcoep/gXAr4pWyAznPGb2CUIkSUIOUKnVBcfG+dNXDLM1vbQCdx2qY +LD9wdMnNoG+1pXIjBPtlYpmZTdJxPQAA8PHgElW0BC0liYnRJlIhaj0zEL6Vt9Bf +kj3vhy8x6HdrDpXCZ0bo1l/pQcmDkHuvQL/KEGp6cUb+nj25zK80c3+XVKsHbZlc +82v4RHUHPHjJHnLdAK7Un97xDvj20INt19hvAqx+gtloKenE8wmng9sXYElMa7+T +ooEnfGwHXZfCUl8KjlpRGBiZbi7VCsJTj0kWSgXP/OD7XXcLvc0CggEBAPQecjz5 +kppfoD46mqFZ3vzSUc4lUElaTdzDPvg9j1v8rWejyxeqZJlc7+1iSJcwhsSSac13 +2Mq4qp6dlyc9vaUMQYbvsTBaWujzRYUzfMG409IWw1UuKOU9FscqRhVf0C9FJtoC +uiahlsA+kGWgZJW7/ya7QMZ+FTd5yEcFQk0u07tw31Q3FTx8YLDV4jRvD9nJ8F8P +dhMRQ9aQ/fwcmWDLecOikq+i9uiCLn6lJJrhG9rs1OuAYD9bjzjKRRKO3lXcTeE/ +0y3a15xVMhePIZH8p7lvwgOroKoHNtoUZ2Oxp7RJqd1o3F1lZf8kMpV+MTDeoQsx +t2Lh933alhe2CbMCggEBANz+TMZyHbLJS+nCE+BXjxJT8j+nhbn+ex9UjJIbKD1z +3e+b3ED9Xkx5LWRuoJBB8mlPy9J0p8lrdgOvKohAsg+khV4/Ngw2lXq2tXV/RQn0 +3CzMzZ3MWwqHdDUDa0ml+aLMG+sSB8GatZmvD6KRkc97sL5kStUHhlhXeaKsIyMi +s2slZb6//UGWNDikh1Jp/XsEbc0BiZZtEtLMiRV4jGNoWjw6MiVFb6qk3GCyz8FS +/M2qRrzTL2P43lcMGMLBu6ultt1n9L4BA+Eu7U3sY8Rehmue43jDz/LUyxSHCt3E +8SSsmXuXMh4Cwa1W6UXe8KcaRr4WoFo4PvZEMd7WGZcCggEBAIZm5NpxRae8kkrw +lQXUpxJm8ScgIA3irA+pZ1fg/LbWbNossbo709sj8eyuOe0TiH9dZOb83tztwvJF +LV0rfugJ0WHrQZCvjnHGzjXB3SQDEIwQgEa7fUSI16ubuK437DS6S+OnsLloKcl6 +KKHrJrXRpW67lbQy4peCcyO234QDDgua3zpMgWKlz85MU5gutXlg1vhfWNCyprjR +ZySQ0lkabdWqAjy06l+knNiZL4gd++oSjj+ClHsNe9L2egT3p615917Wdvw+CotF +1Khn40Gu6uELiLPgoDo8cpSquymGPCDklaMTApBhLUDFuxvXOFoBmITDQIYuhsZB +vHUdgkUCggEABeF+iYlf4PIaYw4XGVE7LXGucKM0m8552EuXsgum9nuu3EF5iwEz +ETXoT1PiUfRvTv4gnmkcTe/eJBr1NssB8giew/NKrOiG8c0K5yWL4MfzU/3fOuPF +SHJyVTbSFBOmoP5tf8PrEOvdCUnvUJQvHSZdfbONij25BYDOa9XI2ZaCz8ce/gR9 +6NDmcttt/nNzm2JyyZHQ53/fkFyBCWE72ylbvV6PFw7R+eiJNMmNXcenkpGFcGDu +Ueq9f/OCdSxSoi62vw2VJblBMSzeg8RWo1MgoJyJ0Rzk28Ft5g3x7BThlehB7VgI +rWPFY6d8ba+RF+FLIKPZgI0en88QxK1N4QKCAQA8HdPkHEflcoHIxNrgpUm6l0QG +s5VM/Tf0/s2QthXm6auEObXOcqo8uzyl9kbnFNIx73aPTPIFuhjRuqt4Qo2ZXWTa +pT7+yr/wd6AZZ+N9BX4POQXy48ZI7NSfe9xviaOD07WLaMOWA6FC+D4e3J4d3LVS +utSsz3q3S84/HOuvpN9w4kFYlLBvch3A+Ohyfd8TcRPPD4Df2CZ2a+P5X2d5nd7i +RpHbf40AnILt8A/Zmcui5V+8CTn3bw/CNA6umwgdn1CfqXR+0mlQRBDUOvg/T7iW +kb+6jgB0c/ZvLK3UDC9/GoXHRrHj2sEYMx4Kpp3KZK66+tJzgmdgghHR/ZrC -----END RSA PRIVATE KEY----- diff --git a/config/template.default.toml b/config/template.default.toml new file mode 100644 index 0000000..ce7430a --- /dev/null +++ b/config/template.default.toml @@ -0,0 +1,149 @@ +[mumble] +port = '5668' +host = 'presgold.linx.safemobile.com' + +[hub] +address = 'https://hub.presgold.linx.safemobile.com/' + +[api] +port = '' +host = 'presgold.linx.safemobile.com/api' +use_secure = true +accept_untrusted_certs = true + +[settings] +max_fails = 3 +send_voice = true +send_gps = true +gps_report_interval = 10000 # The interval in which the GPS is sent +gps_lat_start_point = 46.217802 +gps_lng_start_point = 24.776126 + +[assets] +ids = [ 2776 ] +#VOICE and GPS Stage +# ids = [ +# 65,1125 +# ] + +# VOICE and GPS Presgold +# ids = [ +# 2164 + # 2164,2165,2166,2167,2168,2169,2170,2171,2172,2173 + # 2174,2175,2176,2177,2178,2179,2180,2181,2182,2183, + # 2184,2185,2186,2187,2188,2189,2190,2191,2192,2193, + # 2194,2195,2196,2197,2198,2199,2200,2201,2202,2203, + # 2204,2205,2206,2207,2208,2209,2210,2211,2212,2213, + # 2214,2215,2216,2217,2218,2219,2220,2221,2222,2223, + # 2224,2225,2226,2227,2228,2229,2230,2231,2232,2233, + # 2234,2235,2236,2237,2238,2239,2240,2241,2242,2243, + # 2244,2245,2246,2247,2248,2249,2250,2251,2252,2253, + # 2254,2255,2256,2257,2258,2259,2260,2261,2262,2263 +# ] + +#VOICE and GPS Prestage +# ids = [1947] +# ids = [1947,1957] +# ids = [1947,1957,1967] +# 10 units +# ids = [1947,1957,1967,1977,1987,1997,2007,2017,2027,2037] # colinde 0-10 +# 20 units +# ids = [1947,1957,1967,1977,1987,1997,2007,2017,2027,2037,2047,2057,2067,2077,2087,2097,2107,2117,2127,2137] +# 30 units +# ids = [1947,1957,1967,1977,1987,1997,2007,2017,2027,2037,2047,2057,2067,2077,2087,2097,2107,2117,2127,2137,2147,2157,2167,2177,2187,2197,2207,2217,2227,2237] +# 50 units +# ids = [1947,1957,1967,1977,1987,1997,2007,2017,2027,2037,2047,2057,2067,2077,2087,2097,2107,2117,2127,2137,2147,2157,2167,2177,2187,2197,2207,2217,2227,2237,2247,2257,2267,2277,2287,2297,2307,2317,2327,2337,2347,2357,2367,2377,2387,2397,2407,2417,2427,2437] +# 70 units +# ids = [1947,1957,1967,1977,1987,1997,2007,2017,2027,2037,2047,2057,2067,2077,2087,2097,2107,2117,2127,2137,2147,2157,2167,2177,2187,2197,2207,2217,2227,2237,2247,2257,2267,2277,2287,2297,2307,2317,2327,2337,2347,2357,2367,2377,2387,2397,2407,2417,2427,2437,2447,2457,2467,2477,2487,2497,2507,2517,2527,2537,2547,2557,2567,2577,2587,2597,2597,2607,2617,2627,2637] + +#GPS Prestage +# 10 units +# ids = [3842,3843,3844,3845,3846,3847,3848,3849,3850,3851] +# 50 units +# ids = [3842,3843,3844,3845,3846,3847,3848,3849,3850,3851,3852,3853,3854,3855,3856,3857,3858,3859,3860,3861,3862,3863,3864,3865,3866,3867,3868,3869,3870,3871,3872,3873,3874,3875,3876,3877,3878,3879,3880,3881,3882,3883,3884,3885,3886,3887,3888,3889,3890,3891,3892] +# 100 units +# ids = [3842,3843,3844,3845,3846,3847,3848,3849,3850,3851,3852,3853,3854,3855,3856,3857,3858,3859,3860,3861,3862,3863,3864,3865,3866,3867,3868,3869,3870,3871,3872,3873,3874,3875,3876,3877,3878,3879,3880,3881,3882,3883,3884,3885,3886,3887,3888,3889,3890,3891,3892,3893,3894,3895,3896,3897,3898,3899,3900,3901,3902,3903,3904,3905,3906,3907,3908,3909,3910,3911,3912,3913,3914,3915,3916,3917,3918,3919,3920,3921,3922,3923,3924,3925,3926,3927,3928,3929,3930,3931,3932,3933,3934,3935,3936,3937,3938,3939,3940,3941,3942] +# 300 units +# ids = [3842,3843,3844,3845,3846,3847,3848,3849,3850,3851,3852,3853,3854,3855,3856,3857,3858,3859,3860,3861,3862,3863,3864,3865,3866,3867,3868,3869,3870,3871,3872,3873,3874,3875,3876,3877,3878,3879,3880,3881,3882,3883,3884,3885,3886,3887,3888,3889,3890,3891,3892,3893,3894,3895,3896,3897,3898,3899,3900,3901,3902,3903,3904,3905,3906,3907,3908,3909,3910,3911,3912,3913,3914,3915,3916,3917,3918,3919,3920,3921,3922,3923,3924,3925,3926,3927,3928,3929,3930,3931,3932,3933,3934,3935,3936,3937,3938,3939,3940,3941,3942,3893,3894,3895,3896,3897,3898,3899,3900,3901,3902,3903,3904,3905,3906,3907,3908,3909,3910,3911,3912,3913,3914,3915,3916,3917,3918,3919,3920,3921,3922,3923,3924,3925,3926,3927,3928,3929,3930,3931,3932,3933,3934,3935,3936,3937,3938,3939,3940,3941,3942,3943,3944,3945,3946,3947,3948,3949,3950,3951,3952,3953,3954,3955,3956,3957,3958,3959,3960,3961,3962,3963,3964,3965,3966,3967,3968,3969,3970,3971,3972,3973,3974,3975,3976,3977,3978,3979,3980,3981,3982,3983,3984,3985,3986,3987,3988,3989,3990,3991,3992,3993,3994,3995,3996,3997,3998,3999,4000,4001,4002,4003,4004,4005,4006,4007,4008,4009,4010,4011,4012,4013,4014,4015,4016,4017,4018,4019,4020,4021,4022,4023,4024,4025,4026,4027,4028,4029,4030,4031,4032,4033,4034,4035,4036,4037,4038,4039,4040,4041,4042,4043,4044,4045,4046,4047,4048,4049,4050,4051,4052,4053,4054,4055,4056,4057,4058,4059,4060,4061,4062,4063,4064,4065,4066,4067,4068,4069,4070,4071,4072,4073,4074,4075,4076,4077,4078,4079,4080,4081,4082,4083,4084,4085,4086,4087,4088,4089,4090,4091,4092,4093,4094,4095,4096,4097,4098,4099,4100,4101,4102,4103,4104,4105,4106,4107,4108,4109,4110,4111,4112,4113,4114,4115,4116,4117,4118,4119,4120,4121,4122,4123,4124,4125,4126,4127,4128,4129,4130,4131,4132,4133,4134,4135,4136,4137,4138,4139,4140,4141] + + +# audio-test-100 1947 colinde +# audio-test-110 1957 colinde2 +# audio-test-120 1967 colinde3 +# audio-test-130 1977 colinde4 +# audio-test-140 1987 colinde5 +# audio-test-150 1997 colinde6 +# audio-test-160 2007 colinde7 +# audio-test-170 2017 colinde8 +# audio-test-180 2027 colinde9 +# audio-test-190 2037 colinde10 + +# audio-test-200 2047 colinde11 +# audio-test-210 2057 colinde12 +# audio-test-220 2067 colinde13 +# audio-test-230 2077 colinde14 +# audio-test-240 2087 colinde15 +# audio-test-250 2097 colinde16 +# audio-test-260 2107 colinde17 +# audio-test-270 2117 colinde18 +# audio-test-280 2127 colinde19 +# audio-test-290 2137 colinde20 + +# audio-test-300 2147 colinde21 +# audio-test-310 2157 colinde22 +# audio-test-320 2167 colinde23 +# audio-test-330 2177 colinde24 +# audio-test-340 2187 colinde25 +# audio-test-350 2197 colinde26 +# audio-test-360 2207 colinde27 +# audio-test-370 2217 colinde28 +# audio-test-380 2227 colinde29 +# audio-test-390 2237 colinde30 + +# audio-test-400 2247 colinde31 +# audio-test-410 2257 colinde32 +# audio-test-420 2267 colinde33 +# audio-test-430 2277 colinde34 +# audio-test-440 2287 colinde35 +# audio-test-450 2297 colinde36 +# audio-test-460 2307 colinde37 +# audio-test-470 2317 colinde38 +# audio-test-480 2327 colinde39 +# audio-test-490 2337 colinde40 + +# audio-test-500 2347 colinde41 +# audio-test-510 2357 colinde42 +# audio-test-520 2367 colinde43 +# audio-test-530 2377 colinde44 +# audio-test-540 2387 colinde45 +# audio-test-550 2397 colinde46 +# audio-test-360 2407 colinde47 +# audio-test-570 2417 colinde48 +# audio-test-580 2427 colinde49 +# audio-test-590 2437 colinde50 + +# audio-test-600 2447 colinde51 +# audio-test-610 2457 colinde52 +# audio-test-620 2467 colinde53 +# audio-test-630 2477 colinde54 +# audio-test-640 2487 colinde55 +# audio-test-650 2497 colinde56 +# audio-test-660 2507 colinde57 +# audio-test-670 2517 colinde58 +# audio-test-680 2527 colinde59 +# audio-test-690 2537 colinde60 + +# audio-test-700 2547 colinde61 +# audio-test-710 2557 colinde62 +# audio-test-720 2567 colinde63 +# audio-test-730 2577 colinde64 +# audio-test-740 2587 colinde65 +# audio-test-750 2597 colinde66 +# audio-test-760 2607 colinde67 +# audio-test-770 2617 colinde68 +# audio-test-780 2627 colinde69 +# audio-test-790 2637 colinde70 + +[sounds] +sound = 'sound.mp3' +sounds_total_number = 20 \ No newline at end of file diff --git a/index.js b/index.js index 07f4b77..1832bb3 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,9 @@ +const argv = require('yargs').argv +if(argv.path) { process.env["NODE_CONFIG_DIR"] = argv.path; } const config = require('config'); -const Simulator = require('./src/simulator'); +const Simulator = require('./src/simulator'); +console.log(config) // Read configs. let configs = { mumble: config.get('mumble'), diff --git a/node_modules/ansi-regex/index.js b/node_modules/ansi-regex/index.js index b9574ed..c254480 100644 --- a/node_modules/ansi-regex/index.js +++ b/node_modules/ansi-regex/index.js @@ -1,4 +1,14 @@ 'use strict'; -module.exports = function () { - return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g; + +module.exports = options => { + options = Object.assign({ + onlyFirst: false + }, options); + + const pattern = [ + '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', + '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))' + ].join('|'); + + return new RegExp(pattern, options.onlyFirst ? undefined : 'g'); }; diff --git a/node_modules/ansi-regex/license b/node_modules/ansi-regex/license index 654d0bf..e7af2f7 100644 --- a/node_modules/ansi-regex/license +++ b/node_modules/ansi-regex/license @@ -1,21 +1,9 @@ -The MIT License (MIT) +MIT License Copyright (c) Sindre Sorhus (sindresorhus.com) -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/ansi-regex/package.json b/node_modules/ansi-regex/package.json index 7908002..cbf0b7b 100644 --- a/node_modules/ansi-regex/package.json +++ b/node_modules/ansi-regex/package.json @@ -1,27 +1,27 @@ { - "_from": "ansi-regex@^2.0.0", - "_id": "ansi-regex@2.1.1", + "_from": "ansi-regex@^4.1.0", + "_id": "ansi-regex@4.1.0", "_inBundle": false, - "_integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "_integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "_location": "/ansi-regex", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "ansi-regex@^2.0.0", + "raw": "ansi-regex@^4.1.0", "name": "ansi-regex", "escapedName": "ansi-regex", - "rawSpec": "^2.0.0", + "rawSpec": "^4.1.0", "saveSpec": null, - "fetchSpec": "^2.0.0" + "fetchSpec": "^4.1.0" }, "_requiredBy": [ "/strip-ansi" ], - "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "_shasum": "c3b33ab5ee360d86e0e628f0468ae7ef27d654df", - "_spec": "ansi-regex@^2.0.0", - "_where": "/home/sergiu/linx-audio-simulator/node_modules/strip-ansi", + "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "_shasum": "8b9f8f08cf1acb843756a839ca8c7e3168c51997", + "_spec": "ansi-regex@^4.1.0", + "_where": "/home/sergiu/linx-simulator2/node_modules/strip-ansi", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", @@ -34,11 +34,11 @@ "deprecated": false, "description": "Regular expression for matching ANSI escape codes", "devDependencies": { - "ava": "0.17.0", - "xo": "0.16.0" + "ava": "^0.25.0", + "xo": "^0.23.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=6" }, "files": [ "index.js" @@ -72,37 +72,14 @@ "pattern" ], "license": "MIT", - "maintainers": [ - { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - { - "name": "Joshua Appelman", - "email": "jappelman@xebia.com", - "url": "jbnicolai.com" - }, - { - "name": "JD Ballard", - "email": "i.am.qix@gmail.com", - "url": "github.com/qix-" - } - ], "name": "ansi-regex", "repository": { "type": "git", "url": "git+https://github.com/chalk/ansi-regex.git" }, "scripts": { - "test": "xo && ava --verbose", + "test": "xo && ava", "view-supported": "node fixtures/view-codes.js" }, - "version": "2.1.1", - "xo": { - "rules": { - "guard-for-in": 0, - "no-loop-func": 0 - } - } + "version": "4.1.0" } diff --git a/node_modules/ansi-regex/readme.md b/node_modules/ansi-regex/readme.md index 6a928ed..d19c446 100644 --- a/node_modules/ansi-regex/readme.md +++ b/node_modules/ansi-regex/readme.md @@ -1,12 +1,26 @@ # ansi-regex [![Build Status](https://travis-ci.org/chalk/ansi-regex.svg?branch=master)](https://travis-ci.org/chalk/ansi-regex) -> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) +> Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) + +--- + +
+ + Get professional support for this package with a Tidelift subscription + +
+ + Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. +
+
+ +--- ## Install ``` -$ npm install --save ansi-regex +$ npm install ansi-regex ``` @@ -15,25 +29,59 @@ $ npm install --save ansi-regex ```js const ansiRegex = require('ansi-regex'); -ansiRegex().test('\u001b[4mcake\u001b[0m'); +ansiRegex().test('\u001B[4mcake\u001B[0m'); //=> true ansiRegex().test('cake'); //=> false -'\u001b[4mcake\u001b[0m'.match(ansiRegex()); -//=> ['\u001b[4m', '\u001b[0m'] +'\u001B[4mcake\u001B[0m'.match(ansiRegex()); +//=> ['\u001B[4m', '\u001B[0m'] + +'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true})); +//=> ['\u001B[4m'] + +'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex()); +//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007'] ``` + +## API + +### ansiRegex([options]) + +Returns a regex for matching ANSI escape codes. + +#### options + +##### onlyFirst + +Type: `boolean`
+Default: `false` *(Matches any ANSI escape codes in a string)* + +Match only the first ANSI escape. + + ## FAQ ### Why do you test for codes not in the ECMA 48 standard? -Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. If I recall correctly, we test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them. +Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. We test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them. On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out. +## Security + +To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. + + +## Maintainers + +- [Sindre Sorhus](https://github.com/sindresorhus) +- [Josh Junon](https://github.com/qix-) + + ## License -MIT © [Sindre Sorhus](http://sindresorhus.com) +MIT diff --git a/node_modules/camelcase/index.js b/node_modules/camelcase/index.js index 929facb..579f99b 100644 --- a/node_modules/camelcase/index.js +++ b/node_modules/camelcase/index.js @@ -1,56 +1,76 @@ 'use strict'; -function preserveCamelCase(str) { - var isLastCharLower = false; +const preserveCamelCase = string => { + let isLastCharLower = false; + let isLastCharUpper = false; + let isLastLastCharUpper = false; - for (var i = 0; i < str.length; i++) { - var c = str.charAt(i); + for (let i = 0; i < string.length; i++) { + const character = string[i]; - if (isLastCharLower && (/[a-zA-Z]/).test(c) && c.toUpperCase() === c) { - str = str.substr(0, i) + '-' + str.substr(i); + if (isLastCharLower && /[a-zA-Z]/.test(character) && character.toUpperCase() === character) { + string = string.slice(0, i) + '-' + string.slice(i); isLastCharLower = false; + isLastLastCharUpper = isLastCharUpper; + isLastCharUpper = true; i++; + } else if (isLastCharUpper && isLastLastCharUpper && /[a-zA-Z]/.test(character) && character.toLowerCase() === character) { + string = string.slice(0, i - 1) + '-' + string.slice(i - 1); + isLastLastCharUpper = isLastCharUpper; + isLastCharUpper = false; + isLastCharLower = true; } else { - isLastCharLower = (c.toLowerCase() === c); + isLastCharLower = character.toLowerCase() === character && character.toUpperCase() !== character; + isLastLastCharUpper = isLastCharUpper; + isLastCharUpper = character.toUpperCase() === character && character.toLowerCase() !== character; } } - return str; -} + return string; +}; -module.exports = function () { - var str = [].map.call(arguments, function (str) { - return str.trim(); - }).filter(function (str) { - return str.length; - }).join('-'); +const camelCase = (input, options) => { + if (!(typeof input === 'string' || Array.isArray(input))) { + throw new TypeError('Expected the input to be `string | string[]`'); + } - if (!str.length) { + options = Object.assign({ + pascalCase: false + }, options); + + const postProcess = x => options.pascalCase ? x.charAt(0).toUpperCase() + x.slice(1) : x; + + if (Array.isArray(input)) { + input = input.map(x => x.trim()) + .filter(x => x.length) + .join('-'); + } else { + input = input.trim(); + } + + if (input.length === 0) { return ''; } - if (str.length === 1) { - return str; + if (input.length === 1) { + return options.pascalCase ? input.toUpperCase() : input.toLowerCase(); } - if (!(/[_.\- ]+/).test(str)) { - if (str === str.toUpperCase()) { - return str.toLowerCase(); - } + const hasUpperCase = input !== input.toLowerCase(); - if (str[0] !== str[0].toLowerCase()) { - return str[0].toLowerCase() + str.slice(1); - } - - return str; + if (hasUpperCase) { + input = preserveCamelCase(input); } - str = preserveCamelCase(str); + input = input + .replace(/^[_.\- ]+/, '') + .toLowerCase() + .replace(/[_.\- ]+(\w|$)/g, (_, p1) => p1.toUpperCase()) + .replace(/\d+(\w|$)/g, m => m.toUpperCase()); - return str - .replace(/^[_.\- ]+/, '') - .toLowerCase() - .replace(/[_.\- ]+(\w|$)/g, function (m, p1) { - return p1.toUpperCase(); - }); + return postProcess(input); }; + +module.exports = camelCase; +// TODO: Remove this for the next major release +module.exports.default = camelCase; diff --git a/node_modules/camelcase/license b/node_modules/camelcase/license index 654d0bf..e7af2f7 100644 --- a/node_modules/camelcase/license +++ b/node_modules/camelcase/license @@ -1,21 +1,9 @@ -The MIT License (MIT) +MIT License Copyright (c) Sindre Sorhus (sindresorhus.com) -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/camelcase/package.json b/node_modules/camelcase/package.json index a6c1bc7..31c28e4 100644 --- a/node_modules/camelcase/package.json +++ b/node_modules/camelcase/package.json @@ -1,47 +1,49 @@ { - "_from": "camelcase@^2.0.1", - "_id": "camelcase@2.1.1", + "_from": "camelcase@^5.0.0", + "_id": "camelcase@5.3.1", "_inBundle": false, - "_integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", + "_integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", "_location": "/camelcase", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "camelcase@^2.0.1", + "raw": "camelcase@^5.0.0", "name": "camelcase", "escapedName": "camelcase", - "rawSpec": "^2.0.1", + "rawSpec": "^5.0.0", "saveSpec": null, - "fetchSpec": "^2.0.1" + "fetchSpec": "^5.0.0" }, "_requiredBy": [ - "/yargs" + "/yargs-parser" ], - "_resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", - "_shasum": "7c1d16d679a1bbe59ca02cacecfb011e201f5a1f", - "_spec": "camelcase@^2.0.1", - "_where": "/home/sergiu/linx-audio-simulator/node_modules/yargs", + "_resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "_shasum": "e3c9b31569e106811df242f715725a1f4c494320", + "_spec": "camelcase@^5.0.0", + "_where": "/home/sergiu/linx-simulator2/node_modules/yargs-parser", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", - "url": "http://sindresorhus.com" + "url": "sindresorhus.com" }, "bugs": { "url": "https://github.com/sindresorhus/camelcase/issues" }, "bundleDependencies": false, "deprecated": false, - "description": "Convert a dash/dot/underscore/space separated string to camelCase: foo-bar → fooBar", + "description": "Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`", "devDependencies": { - "ava": "*", - "xo": "*" + "ava": "^1.4.1", + "tsd": "^0.7.1", + "xo": "^0.24.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=6" }, "files": [ - "index.js" + "index.js", + "index.d.ts" ], "homepage": "https://github.com/sindresorhus/camelcase#readme", "keywords": [ @@ -56,7 +58,9 @@ "separator", "string", "text", - "convert" + "convert", + "pascalcase", + "pascal-case" ], "license": "MIT", "name": "camelcase", @@ -65,7 +69,7 @@ "url": "git+https://github.com/sindresorhus/camelcase.git" }, "scripts": { - "test": "xo && ava" + "test": "xo && ava && tsd" }, - "version": "2.1.1" + "version": "5.3.1" } diff --git a/node_modules/camelcase/readme.md b/node_modules/camelcase/readme.md index 080b2a1..fde2726 100644 --- a/node_modules/camelcase/readme.md +++ b/node_modules/camelcase/readme.md @@ -1,12 +1,25 @@ # camelcase [![Build Status](https://travis-ci.org/sindresorhus/camelcase.svg?branch=master)](https://travis-ci.org/sindresorhus/camelcase) -> Convert a dash/dot/underscore/space separated string to camelCase: `foo-bar` → `fooBar` +> Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar` +--- + +
+ + Get professional support for 'camelcase' with a Tidelift subscription + +
+ + Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. +
+
+ +--- ## Install ``` -$ npm install --save camelcase +$ npm install camelcase ``` @@ -24,10 +37,10 @@ camelCase('foo_bar'); camelCase('Foo-Bar'); //=> 'fooBar' -camelCase('--foo.bar'); -//=> 'fooBar' +camelCase('Foo-Bar', {pascalCase: true}); +//=> 'FooBar' -camelCase('__foo__bar__'); +camelCase('--foo.bar', {pascalCase: false}); //=> 'fooBar' camelCase('foo bar'); @@ -38,20 +51,49 @@ console.log(process.argv[3]); camelCase(process.argv[3]); //=> 'fooBar' -camelCase('foo', 'bar'); +camelCase(['foo', 'bar']); //=> 'fooBar' -camelCase('__foo__', '--bar'); -//=> 'fooBar' +camelCase(['__foo__', '--bar'], {pascalCase: true}); +//=> 'FooBar' ``` +## API + +### camelCase(input, [options]) + +#### input + +Type: `string` `string[]` + +String to convert to camel case. + +#### options + +Type: `Object` + +##### pascalCase + +Type: `boolean`
+Default: `false` + +Uppercase the first character: `foo-bar` → `FooBar` + + +## Security + +To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. + + ## Related - [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module - [uppercamelcase](https://github.com/SamVerschueren/uppercamelcase) - Like this module, but to PascalCase instead of camelCase +- [titleize](https://github.com/sindresorhus/titleize) - Capitalize every word in string +- [humanize-string](https://github.com/sindresorhus/humanize-string) - Convert a camelized/dasherized/underscored string into a humanized one ## License -MIT © [Sindre Sorhus](http://sindresorhus.com) +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/cliui/CHANGELOG.md b/node_modules/cliui/CHANGELOG.md index ef6a35e..37f259a 100644 --- a/node_modules/cliui/CHANGELOG.md +++ b/node_modules/cliui/CHANGELOG.md @@ -2,6 +2,56 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +# [5.0.0](https://github.com/yargs/cliui/compare/v4.1.0...v5.0.0) (2019-04-10) + + +### Bug Fixes + +* Update wrap-ansi to fix compatibility with latest versions of chalk. ([#60](https://github.com/yargs/cliui/issues/60)) ([7bf79ae](https://github.com/yargs/cliui/commit/7bf79ae)) + + +### BREAKING CHANGES + +* Drop support for node < 6. + + + + +# [4.1.0](https://github.com/yargs/cliui/compare/v4.0.0...v4.1.0) (2018-04-23) + + +### Features + +* add resetOutput method ([#57](https://github.com/yargs/cliui/issues/57)) ([7246902](https://github.com/yargs/cliui/commit/7246902)) + + + + +# [4.0.0](https://github.com/yargs/cliui/compare/v3.2.0...v4.0.0) (2017-12-18) + + +### Bug Fixes + +* downgrades strip-ansi to version 3.0.1 ([#54](https://github.com/yargs/cliui/issues/54)) ([5764c46](https://github.com/yargs/cliui/commit/5764c46)) +* set env variable FORCE_COLOR. ([#56](https://github.com/yargs/cliui/issues/56)) ([7350e36](https://github.com/yargs/cliui/commit/7350e36)) + + +### Chores + +* drop support for node < 4 ([#53](https://github.com/yargs/cliui/issues/53)) ([b105376](https://github.com/yargs/cliui/commit/b105376)) + + +### Features + +* add fallback for window width ([#45](https://github.com/yargs/cliui/issues/45)) ([d064922](https://github.com/yargs/cliui/commit/d064922)) + + +### BREAKING CHANGES + +* officially drop support for Node < 4 + + + # [3.2.0](https://github.com/yargs/cliui/compare/v3.1.2...v3.2.0) (2016-04-11) diff --git a/node_modules/cliui/README.md b/node_modules/cliui/README.md index 028392c..deacfa0 100644 --- a/node_modules/cliui/README.md +++ b/node_modules/cliui/README.md @@ -10,9 +10,7 @@ easily create complex multi-column command-line-interfaces. ## Example ```js -var ui = require('cliui')({ - width: 80 -}) +var ui = require('cliui')() ui.div('Usage: $0 [command] [options]') @@ -48,7 +46,7 @@ console.log(ui.toString()) cliui exposes a simple layout DSL: -If you create a single `ui.row`, passing a string rather than an +If you create a single `ui.div`, passing a string rather than an object: * `\n`: characters will be interpreted as new rows. @@ -88,6 +86,7 @@ cliui = require('cliui') ### cliui({width: integer}) Specify the maximum width of the UI being generated. +If no width is provided, cliui will try to get the current window's width and use it, and if that doesn't work, width will be set to `80`. ### cliui({wrap: boolean}) @@ -99,6 +98,7 @@ Create a row with any number of columns, a column can either be a string, or an object with the following options: +* **text:** some text to place in the column. * **width:** the width of a column. * **align:** alignment, `right` or `center`. * **padding:** `[top, right, bottom, left]`. @@ -108,3 +108,8 @@ options: Similar to `div`, except the next row will be appended without a new line being created. + +### cliui.resetOutput() + +Resets the UI elements of the current cliui instance, maintaining the values +set for `width` and `wrap`. diff --git a/node_modules/cliui/index.js b/node_modules/cliui/index.js index e501e78..b42d982 100644 --- a/node_modules/cliui/index.js +++ b/node_modules/cliui/index.js @@ -21,6 +21,10 @@ UI.prototype.span = function () { cols.span = true } +UI.prototype.resetOutput = function () { + this.rows = [] +} + UI.prototype.div = function () { if (arguments.length === 0) this.div('') if (this.wrap && this._shouldApplyLayoutDSL.apply(this, arguments)) { @@ -209,7 +213,7 @@ UI.prototype._rasterize = function (row) { row.forEach(function (col, c) { // leave room for left and right padding. col.width = widths[c] - if (_this.wrap) wrapped = wrap(col.text, _this._negatePadding(col), {hard: true}).split('\n') + if (_this.wrap) wrapped = wrap(col.text, _this._negatePadding(col), { hard: true }).split('\n') else wrapped = col.text.split('\n') if (col.border) { @@ -282,6 +286,10 @@ function _minWidth (col) { return minWidth } +function getWindowWidth () { + if (typeof process === 'object' && process.stdout && process.stdout.columns) return process.stdout.columns +} + function alignRight (str, width) { str = str.trim() var padding = '' @@ -310,7 +318,7 @@ module.exports = function (opts) { opts = opts || {} return new UI({ - width: (opts || {}).width || 80, + width: (opts || {}).width || getWindowWidth() || 80, wrap: typeof opts.wrap === 'boolean' ? opts.wrap : true }) } diff --git a/node_modules/cliui/package.json b/node_modules/cliui/package.json index 4e495b4..b3a5c3b 100644 --- a/node_modules/cliui/package.json +++ b/node_modules/cliui/package.json @@ -1,27 +1,27 @@ { - "_from": "cliui@^3.0.3", - "_id": "cliui@3.2.0", + "_from": "cliui@^5.0.0", + "_id": "cliui@5.0.0", "_inBundle": false, - "_integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "_integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", "_location": "/cliui", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "cliui@^3.0.3", + "raw": "cliui@^5.0.0", "name": "cliui", "escapedName": "cliui", - "rawSpec": "^3.0.3", + "rawSpec": "^5.0.0", "saveSpec": null, - "fetchSpec": "^3.0.3" + "fetchSpec": "^5.0.0" }, "_requiredBy": [ "/yargs" ], - "_resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", - "_shasum": "120601537a916d29940f934da3b48d585a39213d", - "_spec": "cliui@^3.0.3", - "_where": "/home/sergiu/linx-audio-simulator/node_modules/yargs", + "_resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "_shasum": "deefcfdb2e800784aa34f46fa08e06851c7bbbc5", + "_spec": "cliui@^5.0.0", + "_where": "/home/sergiu/linx-simulator2/node_modules/yargs", "author": { "name": "Ben Coe", "email": "ben@npmjs.com" @@ -43,20 +43,23 @@ } }, "dependencies": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wrap-ansi": "^2.0.0" + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" }, "deprecated": false, "description": "easily create complex multi-column command-line-interfaces", "devDependencies": { - "chai": "^3.5.0", - "chalk": "^1.1.2", - "coveralls": "^2.11.8", - "mocha": "^2.4.5", - "nyc": "^6.4.0", - "standard": "^6.0.8", - "standard-version": "^2.1.2" + "chai": "^4.2.0", + "chalk": "^2.4.2", + "coveralls": "^3.0.3", + "mocha": "^6.0.2", + "nyc": "^13.3.0", + "standard": "^12.0.1", + "standard-version": "^5.0.2" + }, + "engine": { + "node": ">=6" }, "files": [ "index.js" @@ -81,8 +84,8 @@ "scripts": { "coverage": "nyc --reporter=text-lcov mocha | coveralls", "pretest": "standard", - "test": "nyc mocha", - "version": "standard-version" + "release": "standard-version", + "test": "nyc mocha" }, "standard": { "ignore": [ @@ -92,5 +95,5 @@ "it" ] }, - "version": "3.2.0" + "version": "5.0.0" } diff --git a/node_modules/is-fullwidth-code-point/index.js b/node_modules/is-fullwidth-code-point/index.js index a7d3e38..d506327 100644 --- a/node_modules/is-fullwidth-code-point/index.js +++ b/node_modules/is-fullwidth-code-point/index.js @@ -1,46 +1,46 @@ 'use strict'; -var numberIsNan = require('number-is-nan'); - -module.exports = function (x) { - if (numberIsNan(x)) { +/* eslint-disable yoda */ +module.exports = x => { + if (Number.isNaN(x)) { return false; } - // https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1369 - // code points are derived from: // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt - if (x >= 0x1100 && ( - x <= 0x115f || // Hangul Jamo - 0x2329 === x || // LEFT-POINTING ANGLE BRACKET - 0x232a === x || // RIGHT-POINTING ANGLE BRACKET - // CJK Radicals Supplement .. Enclosed CJK Letters and Months - (0x2e80 <= x && x <= 0x3247 && x !== 0x303f) || - // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A - 0x3250 <= x && x <= 0x4dbf || - // CJK Unified Ideographs .. Yi Radicals - 0x4e00 <= x && x <= 0xa4c6 || - // Hangul Jamo Extended-A - 0xa960 <= x && x <= 0xa97c || - // Hangul Syllables - 0xac00 <= x && x <= 0xd7a3 || - // CJK Compatibility Ideographs - 0xf900 <= x && x <= 0xfaff || - // Vertical Forms - 0xfe10 <= x && x <= 0xfe19 || - // CJK Compatibility Forms .. Small Form Variants - 0xfe30 <= x && x <= 0xfe6b || - // Halfwidth and Fullwidth Forms - 0xff01 <= x && x <= 0xff60 || - 0xffe0 <= x && x <= 0xffe6 || - // Kana Supplement - 0x1b000 <= x && x <= 0x1b001 || - // Enclosed Ideographic Supplement - 0x1f200 <= x && x <= 0x1f251 || - // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane - 0x20000 <= x && x <= 0x3fffd)) { + if ( + x >= 0x1100 && ( + x <= 0x115f || // Hangul Jamo + x === 0x2329 || // LEFT-POINTING ANGLE BRACKET + x === 0x232a || // RIGHT-POINTING ANGLE BRACKET + // CJK Radicals Supplement .. Enclosed CJK Letters and Months + (0x2e80 <= x && x <= 0x3247 && x !== 0x303f) || + // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A + (0x3250 <= x && x <= 0x4dbf) || + // CJK Unified Ideographs .. Yi Radicals + (0x4e00 <= x && x <= 0xa4c6) || + // Hangul Jamo Extended-A + (0xa960 <= x && x <= 0xa97c) || + // Hangul Syllables + (0xac00 <= x && x <= 0xd7a3) || + // CJK Compatibility Ideographs + (0xf900 <= x && x <= 0xfaff) || + // Vertical Forms + (0xfe10 <= x && x <= 0xfe19) || + // CJK Compatibility Forms .. Small Form Variants + (0xfe30 <= x && x <= 0xfe6b) || + // Halfwidth and Fullwidth Forms + (0xff01 <= x && x <= 0xff60) || + (0xffe0 <= x && x <= 0xffe6) || + // Kana Supplement + (0x1b000 <= x && x <= 0x1b001) || + // Enclosed Ideographic Supplement + (0x1f200 <= x && x <= 0x1f251) || + // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane + (0x20000 <= x && x <= 0x3fffd) + ) + ) { return true; } return false; -} +}; diff --git a/node_modules/is-fullwidth-code-point/package.json b/node_modules/is-fullwidth-code-point/package.json index 5d823b6..a213123 100644 --- a/node_modules/is-fullwidth-code-point/package.json +++ b/node_modules/is-fullwidth-code-point/package.json @@ -1,27 +1,27 @@ { - "_from": "is-fullwidth-code-point@^1.0.0", - "_id": "is-fullwidth-code-point@1.0.0", + "_from": "is-fullwidth-code-point@^2.0.0", + "_id": "is-fullwidth-code-point@2.0.0", "_inBundle": false, - "_integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "_integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "_location": "/is-fullwidth-code-point", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "is-fullwidth-code-point@^1.0.0", + "raw": "is-fullwidth-code-point@^2.0.0", "name": "is-fullwidth-code-point", "escapedName": "is-fullwidth-code-point", - "rawSpec": "^1.0.0", + "rawSpec": "^2.0.0", "saveSpec": null, - "fetchSpec": "^1.0.0" + "fetchSpec": "^2.0.0" }, "_requiredBy": [ "/string-width" ], - "_resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "_shasum": "ef9e31386f031a7f0d643af82fde50c457ef00cb", - "_spec": "is-fullwidth-code-point@^1.0.0", - "_where": "/home/sergiu/linx-audio-simulator/node_modules/string-width", + "_resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "_shasum": "a3b30a5c4f199183167aaab93beefae3ddfb654f", + "_spec": "is-fullwidth-code-point@^2.0.0", + "_where": "/home/sergiu/linx-simulator2/node_modules/string-width", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", @@ -31,17 +31,14 @@ "url": "https://github.com/sindresorhus/is-fullwidth-code-point/issues" }, "bundleDependencies": false, - "dependencies": { - "number-is-nan": "^1.0.0" - }, "deprecated": false, "description": "Check if the character represented by a given Unicode code point is fullwidth", "devDependencies": { - "ava": "0.0.4", - "code-point-at": "^1.0.0" + "ava": "*", + "xo": "*" }, "engines": { - "node": ">=0.10.0" + "node": ">=4" }, "files": [ "index.js" @@ -71,7 +68,10 @@ "url": "git+https://github.com/sindresorhus/is-fullwidth-code-point.git" }, "scripts": { - "test": "node test.js" + "test": "xo && ava" }, - "version": "1.0.0" + "version": "2.0.0", + "xo": { + "esnext": true + } } diff --git a/node_modules/is-fullwidth-code-point/readme.md b/node_modules/is-fullwidth-code-point/readme.md index 4936464..093b028 100644 --- a/node_modules/is-fullwidth-code-point/readme.md +++ b/node_modules/is-fullwidth-code-point/readme.md @@ -13,7 +13,7 @@ $ npm install --save is-fullwidth-code-point ## Usage ```js -var isFullwidthCodePoint = require('is-fullwidth-code-point'); +const isFullwidthCodePoint = require('is-fullwidth-code-point'); isFullwidthCodePoint('谢'.codePointAt()); //=> true @@ -36,4 +36,4 @@ Type: `number` ## License -MIT © [Sindre Sorhus](http://sindresorhus.com) +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/string-width/index.js b/node_modules/string-width/index.js index b9bec62..33c9d6c 100644 --- a/node_modules/string-width/index.js +++ b/node_modules/string-width/index.js @@ -1,36 +1,38 @@ 'use strict'; -var stripAnsi = require('strip-ansi'); -var codePointAt = require('code-point-at'); -var isFullwidthCodePoint = require('is-fullwidth-code-point'); +const stripAnsi = require('strip-ansi'); +const isFullwidthCodePoint = require('is-fullwidth-code-point'); +const emojiRegex = require('emoji-regex')(); -// https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1345 -module.exports = function (str) { - if (typeof str !== 'string' || str.length === 0) { +module.exports = input => { + input = input.replace(emojiRegex, ' '); + + if (typeof input !== 'string' || input.length === 0) { return 0; } - var width = 0; + input = stripAnsi(input); - str = stripAnsi(str); + let width = 0; - for (var i = 0; i < str.length; i++) { - var code = codePointAt(str, i); + for (let i = 0; i < input.length; i++) { + const code = input.codePointAt(i); - // ignore control characters - if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) { + // Ignore control characters + if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) { continue; } - // surrogates - if (code >= 0x10000) { + // Ignore combining characters + if (code >= 0x300 && code <= 0x36F) { + continue; + } + + // Surrogates + if (code > 0xFFFF) { i++; } - if (isFullwidthCodePoint(code)) { - width += 2; - } else { - width++; - } + width += isFullwidthCodePoint(code) ? 2 : 1; } return width; diff --git a/node_modules/string-width/license b/node_modules/string-width/license index 654d0bf..e7af2f7 100644 --- a/node_modules/string-width/license +++ b/node_modules/string-width/license @@ -1,21 +1,9 @@ -The MIT License (MIT) +MIT License Copyright (c) Sindre Sorhus (sindresorhus.com) -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/string-width/package.json b/node_modules/string-width/package.json index 34d6058..ec88781 100644 --- a/node_modules/string-width/package.json +++ b/node_modules/string-width/package.json @@ -1,29 +1,29 @@ { - "_from": "string-width@^1.0.1", - "_id": "string-width@1.0.2", + "_from": "string-width@^3.0.0", + "_id": "string-width@3.1.0", "_inBundle": false, - "_integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "_integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", "_location": "/string-width", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "string-width@^1.0.1", + "raw": "string-width@^3.0.0", "name": "string-width", "escapedName": "string-width", - "rawSpec": "^1.0.1", + "rawSpec": "^3.0.0", "saveSpec": null, - "fetchSpec": "^1.0.1" + "fetchSpec": "^3.0.0" }, "_requiredBy": [ "/cliui", "/wrap-ansi", "/yargs" ], - "_resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "_shasum": "118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3", - "_spec": "string-width@^1.0.1", - "_where": "/home/sergiu/linx-audio-simulator/node_modules/yargs", + "_resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "_shasum": "22767be21b62af1081574306f69ac51b62203961", + "_spec": "string-width@^3.0.0", + "_where": "/home/sergiu/linx-simulator2/node_modules/yargs", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", @@ -34,18 +34,18 @@ }, "bundleDependencies": false, "dependencies": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" }, "deprecated": false, "description": "Get the visual width of a string - the number of columns required to display it", "devDependencies": { - "ava": "*", - "xo": "*" + "ava": "^1.0.1", + "xo": "^0.23.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=6" }, "files": [ "index.js" @@ -86,5 +86,5 @@ "scripts": { "test": "xo && ava" }, - "version": "1.0.2" + "version": "3.1.0" } diff --git a/node_modules/string-width/readme.md b/node_modules/string-width/readme.md index 1ab42c9..d39d95f 100644 --- a/node_modules/string-width/readme.md +++ b/node_modules/string-width/readme.md @@ -2,7 +2,7 @@ > Get the visual width of a string - the number of columns required to display it -Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width. +Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width. Useful to be able to measure the actual width of command-line output. @@ -10,7 +10,7 @@ Useful to be able to measure the actual width of command-line output. ## Install ``` -$ npm install --save string-width +$ npm install string-width ``` @@ -27,6 +27,9 @@ stringWidth('\u001b[1m古\u001b[22m'); stringWidth('a'); //=> 1 + +stringWidth('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007'); +// => 5 ``` diff --git a/node_modules/strip-ansi/index.js b/node_modules/strip-ansi/index.js index 099480f..9788c96 100644 --- a/node_modules/strip-ansi/index.js +++ b/node_modules/strip-ansi/index.js @@ -1,6 +1,7 @@ 'use strict'; -var ansiRegex = require('ansi-regex')(); +const ansiRegex = require('ansi-regex'); -module.exports = function (str) { - return typeof str === 'string' ? str.replace(ansiRegex, '') : str; -}; +const stripAnsi = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string; + +module.exports = stripAnsi; +module.exports.default = stripAnsi; diff --git a/node_modules/strip-ansi/license b/node_modules/strip-ansi/license index 654d0bf..e7af2f7 100644 --- a/node_modules/strip-ansi/license +++ b/node_modules/strip-ansi/license @@ -1,21 +1,9 @@ -The MIT License (MIT) +MIT License Copyright (c) Sindre Sorhus (sindresorhus.com) -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/strip-ansi/package.json b/node_modules/strip-ansi/package.json index 04d8c69..685ea47 100644 --- a/node_modules/strip-ansi/package.json +++ b/node_modules/strip-ansi/package.json @@ -1,29 +1,29 @@ { - "_from": "strip-ansi@^3.0.1", - "_id": "strip-ansi@3.0.1", + "_from": "strip-ansi@^5.2.0", + "_id": "strip-ansi@5.2.0", "_inBundle": false, - "_integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "_integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", "_location": "/strip-ansi", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "strip-ansi@^3.0.1", + "raw": "strip-ansi@^5.2.0", "name": "strip-ansi", "escapedName": "strip-ansi", - "rawSpec": "^3.0.1", + "rawSpec": "^5.2.0", "saveSpec": null, - "fetchSpec": "^3.0.1" + "fetchSpec": "^5.2.0" }, "_requiredBy": [ "/cliui", "/string-width", "/wrap-ansi" ], - "_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "_shasum": "6a385fb8853d952d5ff05d0e8aaf94278dc63dcf", - "_spec": "strip-ansi@^3.0.1", - "_where": "/home/sergiu/linx-audio-simulator/node_modules/cliui", + "_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "_shasum": "8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae", + "_spec": "strip-ansi@^5.2.0", + "_where": "/home/sergiu/linx-simulator2/node_modules/cliui", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", @@ -34,19 +34,21 @@ }, "bundleDependencies": false, "dependencies": { - "ansi-regex": "^2.0.0" + "ansi-regex": "^4.1.0" }, "deprecated": false, - "description": "Strip ANSI escape codes", + "description": "Strip ANSI escape codes from a string", "devDependencies": { - "ava": "*", - "xo": "*" + "ava": "^1.3.1", + "tsd-check": "^0.5.0", + "xo": "^0.24.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=6" }, "files": [ - "index.js" + "index.js", + "index.d.ts" ], "homepage": "https://github.com/chalk/strip-ansi#readme", "keywords": [ @@ -74,30 +76,13 @@ "text" ], "license": "MIT", - "maintainers": [ - { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - { - "name": "Joshua Boy Nicolai Appelman", - "email": "joshua@jbna.nl", - "url": "jbna.nl" - }, - { - "name": "JD Ballard", - "email": "i.am.qix@gmail.com", - "url": "github.com/qix-" - } - ], "name": "strip-ansi", "repository": { "type": "git", "url": "git+https://github.com/chalk/strip-ansi.git" }, "scripts": { - "test": "xo && ava" + "test": "xo && ava && tsd-check" }, - "version": "3.0.1" + "version": "5.2.0" } diff --git a/node_modules/strip-ansi/readme.md b/node_modules/strip-ansi/readme.md index cb7d9ff..8681fe8 100644 --- a/node_modules/strip-ansi/readme.md +++ b/node_modules/strip-ansi/readme.md @@ -1,33 +1,61 @@ # strip-ansi [![Build Status](https://travis-ci.org/chalk/strip-ansi.svg?branch=master)](https://travis-ci.org/chalk/strip-ansi) -> Strip [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) +> Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string +--- + +
+ + Get professional support for 'strip-ansi' with a Tidelift subscription + +
+ + Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. +
+
+ +--- ## Install ``` -$ npm install --save strip-ansi +$ npm install strip-ansi ``` ## Usage ```js -var stripAnsi = require('strip-ansi'); +const stripAnsi = require('strip-ansi'); -stripAnsi('\u001b[4mcake\u001b[0m'); -//=> 'cake' +stripAnsi('\u001B[4mUnicorn\u001B[0m'); +//=> 'Unicorn' + +stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007'); +//=> 'Click' ``` +## Security + +To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. + + ## Related - [strip-ansi-cli](https://github.com/chalk/strip-ansi-cli) - CLI for this module +- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Streaming version of this module - [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes - [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes - [chalk](https://github.com/chalk/chalk) - Terminal string styling done right +## Maintainers + +- [Sindre Sorhus](https://github.com/sindresorhus) +- [Josh Junon](https://github.com/qix-) + + ## License -MIT © [Sindre Sorhus](http://sindresorhus.com) +MIT diff --git a/node_modules/wrap-ansi/index.js b/node_modules/wrap-ansi/index.js index ff62543..5038bb0 100755 --- a/node_modules/wrap-ansi/index.js +++ b/node_modules/wrap-ansi/index.js @@ -1,68 +1,42 @@ 'use strict'; -var stringWidth = require('string-width'); -var stripAnsi = require('strip-ansi'); +const stringWidth = require('string-width'); +const stripAnsi = require('strip-ansi'); +const ansiStyles = require('ansi-styles'); -var ESCAPES = [ - '\u001b', - '\u009b' -]; +const ESCAPES = new Set([ + '\u001B', + '\u009B' +]); -var END_CODE = 39; +const END_CODE = 39; -var ESCAPE_CODES = { - 0: 0, - 1: 22, - 2: 22, - 3: 23, - 4: 24, - 7: 27, - 8: 28, - 9: 29, - 30: 39, - 31: 39, - 32: 39, - 33: 39, - 34: 39, - 35: 39, - 36: 39, - 37: 39, - 90: 39, - 40: 49, - 41: 49, - 42: 49, - 43: 49, - 44: 49, - 45: 49, - 46: 49, - 47: 49 -}; +const wrapAnsi = code => `${ESCAPES.values().next().value}[${code}m`; -function wrapAnsi(code) { - return ESCAPES[0] + '[' + code + 'm'; -} +// Calculate the length of words split on ' ', ignoring +// the extra characters added by ansi escape codes +const wordLengths = string => string.split(' ').map(character => stringWidth(character)); -// calculate the length of words split on ' ', ignoring -// the extra characters added by ansi escape codes. -function wordLengths(str) { - return str.split(' ').map(function (s) { - return stringWidth(s); - }); -} +// Wrap a long word across multiple rows +// Ansi escape codes do not count towards length +const wrapWord = (rows, word, columns) => { + const characters = [...word]; -// wrap a long word across multiple rows. -// ansi escape codes do not count towards length. -function wrapWord(rows, word, cols) { - var insideEscape = false; - var visible = stripAnsi(rows[rows.length - 1]).length; + let insideEscape = false; + let visible = stringWidth(stripAnsi(rows[rows.length - 1])); - for (var i = 0; i < word.length; i++) { - var x = word[i]; + for (const [index, character] of characters.entries()) { + const characterLength = stringWidth(character); - rows[rows.length - 1] += x; + if (visible + characterLength <= columns) { + rows[rows.length - 1] += character; + } else { + rows.push(character); + visible = 0; + } - if (ESCAPES.indexOf(x) !== -1) { + if (ESCAPES.has(character)) { insideEscape = true; - } else if (insideEscape && x === 'm') { + } else if (insideEscape && character === 'm') { insideEscape = false; continue; } @@ -71,98 +45,144 @@ function wrapWord(rows, word, cols) { continue; } - visible++; + visible += characterLength; - if (visible >= cols && i < word.length - 1) { + if (visible === columns && index < characters.length - 1) { rows.push(''); visible = 0; } } - // it's possible that the last row we copy over is only - // ansi escape characters, handle this edge-case. + // It's possible that the last row we copy over is only + // ansi escape characters, handle this edge-case if (!visible && rows[rows.length - 1].length > 0 && rows.length > 1) { rows[rows.length - 2] += rows.pop(); } -} +}; -// the wrap-ansi module can be invoked -// in either 'hard' or 'soft' wrap mode. -// -// 'hard' will never allow a string to take up more -// than cols characters. -// -// 'soft' allows long words to expand past the column length. -function exec(str, cols, opts) { - var options = opts || {}; +// Trims spaces from a string ignoring invisible sequences +const stringVisibleTrimSpacesRight = str => { + const words = str.split(' '); + let last = words.length; - var pre = ''; - var ret = ''; - var escapeCode; - - var lengths = wordLengths(str); - var words = str.split(' '); - var rows = ['']; - - for (var i = 0, word; (word = words[i]) !== undefined; i++) { - var rowLength = stringWidth(rows[rows.length - 1]); - - if (rowLength) { - rows[rows.length - 1] += ' '; - rowLength++; + while (last > 0) { + if (stringWidth(words[last - 1]) > 0) { + break; } - // in 'hard' wrap mode, the length of a line is - // never allowed to extend past 'cols'. - if (lengths[i] > cols && options.hard) { - if (rowLength) { + last--; + } + + if (last === words.length) { + return str; + } + + return words.slice(0, last).join(' ') + words.slice(last).join(''); +}; + +// The wrap-ansi module can be invoked +// in either 'hard' or 'soft' wrap mode +// +// 'hard' will never allow a string to take up more +// than columns characters +// +// 'soft' allows long words to expand past the column length +const exec = (string, columns, options = {}) => { + if (options.trim !== false && string.trim() === '') { + return ''; + } + + let pre = ''; + let ret = ''; + let escapeCode; + + const lengths = wordLengths(string); + let rows = ['']; + + for (const [index, word] of string.split(' ').entries()) { + if (options.trim !== false) { + rows[rows.length - 1] = rows[rows.length - 1].trimLeft(); + } + + let rowLength = stringWidth(rows[rows.length - 1]); + + if (index !== 0) { + if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) { + // If we start with a new word but the current row length equals the length of the columns, add a new row + rows.push(''); + rowLength = 0; + } + + if (rowLength > 0 || options.trim === false) { + rows[rows.length - 1] += ' '; + rowLength++; + } + } + + // In 'hard' wrap mode, the length of a line is + // never allowed to extend past 'columns' + if (options.hard && lengths[index] > columns) { + const remainingColumns = (columns - rowLength); + const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns); + const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns); + if (breaksStartingNextLine < breaksStartingThisLine) { rows.push(''); } - wrapWord(rows, word, cols); + + wrapWord(rows, word, columns); continue; } - if (rowLength + lengths[i] > cols && rowLength > 0) { - if (options.wordWrap === false && rowLength < cols) { - wrapWord(rows, word, cols); + if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) { + if (options.wordWrap === false && rowLength < columns) { + wrapWord(rows, word, columns); continue; } rows.push(''); } + if (rowLength + lengths[index] > columns && options.wordWrap === false) { + wrapWord(rows, word, columns); + continue; + } + rows[rows.length - 1] += word; } - pre = rows.map(function (r) { - return r.trim(); - }).join('\n'); + if (options.trim !== false) { + rows = rows.map(stringVisibleTrimSpacesRight); + } - for (var j = 0; j < pre.length; j++) { - var y = pre[j]; + pre = rows.join('\n'); - ret += y; + for (const [index, character] of [...pre].entries()) { + ret += character; - if (ESCAPES.indexOf(y) !== -1) { - var code = parseFloat(/[0-9][^m]*/.exec(pre.slice(j, j + 4))); + if (ESCAPES.has(character)) { + const code = parseFloat(/\d[^m]*/.exec(pre.slice(index, index + 4))); escapeCode = code === END_CODE ? null : code; } - if (escapeCode && ESCAPE_CODES[escapeCode]) { - if (pre[j + 1] === '\n') { - ret += wrapAnsi(ESCAPE_CODES[escapeCode]); - } else if (y === '\n') { + const code = ansiStyles.codes.get(Number(escapeCode)); + + if (escapeCode && code) { + if (pre[index + 1] === '\n') { + ret += wrapAnsi(code); + } else if (character === '\n') { ret += wrapAnsi(escapeCode); } } } return ret; -} - -// for each line break, invoke the method separately. -module.exports = function (str, cols, opts) { - return String(str).split('\n').map(function (substr) { - return exec(substr, cols, opts); - }).join('\n'); +}; + +// For each newline, invoke the method separately +module.exports = (string, columns, options) => { + return String(string) + .normalize() + .split('\n') + .map(line => exec(line, columns, options)) + .join('\n'); }; diff --git a/node_modules/wrap-ansi/license b/node_modules/wrap-ansi/license index 654d0bf..e7af2f7 100644 --- a/node_modules/wrap-ansi/license +++ b/node_modules/wrap-ansi/license @@ -1,21 +1,9 @@ -The MIT License (MIT) +MIT License Copyright (c) Sindre Sorhus (sindresorhus.com) -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/wrap-ansi/package.json b/node_modules/wrap-ansi/package.json index 398319b..1fc63ce 100644 --- a/node_modules/wrap-ansi/package.json +++ b/node_modules/wrap-ansi/package.json @@ -1,27 +1,27 @@ { - "_from": "wrap-ansi@^2.0.0", - "_id": "wrap-ansi@2.1.0", + "_from": "wrap-ansi@^5.1.0", + "_id": "wrap-ansi@5.1.0", "_inBundle": false, - "_integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "_integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", "_location": "/wrap-ansi", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "wrap-ansi@^2.0.0", + "raw": "wrap-ansi@^5.1.0", "name": "wrap-ansi", "escapedName": "wrap-ansi", - "rawSpec": "^2.0.0", + "rawSpec": "^5.1.0", "saveSpec": null, - "fetchSpec": "^2.0.0" + "fetchSpec": "^5.1.0" }, "_requiredBy": [ "/cliui" ], - "_resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", - "_shasum": "d8fc3d284dd05794fe84973caecdd1cf824fdd85", - "_spec": "wrap-ansi@^2.0.0", - "_where": "/home/sergiu/linx-audio-simulator/node_modules/cliui", + "_resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "_shasum": "1fd1f67235d5b6d0fee781056001bfb694c03b09", + "_spec": "wrap-ansi@^5.1.0", + "_where": "/home/sergiu/linx-simulator2/node_modules/cliui", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", @@ -32,22 +32,22 @@ }, "bundleDependencies": false, "dependencies": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" }, "deprecated": false, "description": "Wordwrap a string with ANSI escape codes", "devDependencies": { - "ava": "^0.16.0", - "chalk": "^1.1.0", - "coveralls": "^2.11.4", - "has-ansi": "^2.0.0", - "nyc": "^6.2.1", - "strip-ansi": "^3.0.0", - "xo": "*" + "ava": "^1.2.1", + "chalk": "^2.4.2", + "coveralls": "^3.0.3", + "has-ansi": "^3.0.0", + "nyc": "^13.3.0", + "xo": "^0.24.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=6" }, "files": [ "index.js" @@ -81,36 +81,13 @@ "text" ], "license": "MIT", - "maintainers": [ - { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - { - "name": "Joshua Appelman", - "email": "jappelman@xebia.com", - "url": "jbnicolai.com" - }, - { - "name": "JD Ballard", - "email": "i.am.qix@gmail.com", - "url": "github.com/qix-" - }, - { - "name": "Benjamin Coe", - "email": "ben@npmjs.com", - "url": "github.com/bcoe" - } - ], "name": "wrap-ansi", "repository": { "type": "git", "url": "git+https://github.com/chalk/wrap-ansi.git" }, "scripts": { - "coveralls": "nyc report --reporter=text-lcov | coveralls", "test": "xo && nyc ava" }, - "version": "2.1.0" + "version": "5.1.0" } diff --git a/node_modules/wrap-ansi/readme.md b/node_modules/wrap-ansi/readme.md index 59fc96b..73b87de 100644 --- a/node_modules/wrap-ansi/readme.md +++ b/node_modules/wrap-ansi/readme.md @@ -1,12 +1,12 @@ # wrap-ansi [![Build Status](https://travis-ci.org/chalk/wrap-ansi.svg?branch=master)](https://travis-ci.org/chalk/wrap-ansi) [![Coverage Status](https://coveralls.io/repos/github/chalk/wrap-ansi/badge.svg?branch=master)](https://coveralls.io/github/chalk/wrap-ansi?branch=master) -> Wordwrap a string with [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) +> Wordwrap a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) ## Install ``` -$ npm install --save wrap-ansi +$ npm install wrap-ansi ``` @@ -24,6 +24,20 @@ console.log(wrapAnsi(input, 20)); +--- + +
+ + Get professional support for this package with a Tidelift subscription + +
+ + Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. +
+
+ +--- + ## API @@ -45,6 +59,8 @@ Number of columns to wrap the text to. #### options +Type: `Object` + ##### hard Type: `boolean`
@@ -59,6 +75,13 @@ Default: `true` By default, an attempt is made to split words at spaces, ensuring that they don't extend past the configured columns. If wordWrap is `false`, each column will instead be completely filled splitting words as necessary. +##### trim + +Type: `boolean`
+Default: `true` + +Whitespace on all lines is removed by default. Set this option to `false` if you don't want to trim. + ## Related @@ -68,6 +91,18 @@ By default, an attempt is made to split words at spaces, ensuring that they don' - [jsesc](https://github.com/mathiasbynens/jsesc) - Generate ASCII-only output from Unicode strings. Useful for creating test fixtures. +## Maintainers + +- [Sindre Sorhus](https://github.com/sindresorhus) +- [Josh Junon](https://github.com/qix-) +- [Benjamin Coe](https://github.com/bcoe) + + +## Security + +To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. + + ## License -MIT © [Sindre Sorhus](https://sindresorhus.com) +MIT diff --git a/node_modules/y18n/README.md b/node_modules/y18n/README.md index 9859458..826474f 100644 --- a/node_modules/y18n/README.md +++ b/node_modules/y18n/README.md @@ -4,6 +4,7 @@ [![Coverage Status][coveralls-image]][coveralls-url] [![NPM version][npm-image]][npm-url] [![js-standard-style][standard-image]][standard-url] +[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) The bare-bones internationalization library used by yargs. @@ -23,6 +24,19 @@ output: `my awesome string foo` +_using tagged template literals_ + +```js +var __ = require('y18n').__ +var str = 'foo' + +console.log(__`my awesome string ${str}`) +``` + +output: + +`my awesome string foo` + _pluralization support:_ ```js @@ -60,6 +74,10 @@ Create an instance of y18n with the config provided, options include: Print a localized string, `%s` will be replaced with `arg`s. +This function can also be used as a tag for a template literal. You can use it +like this: __`hello ${'world'}`. This will be equivalent to +`__('hello %s', 'world')`. + ### y18n.\_\_n(singularString, pluralString, count, arg, arg, arg) Print a localized string with appropriate pluralization. If `%d` is provided diff --git a/node_modules/y18n/index.js b/node_modules/y18n/index.js index 91b159e..d720681 100644 --- a/node_modules/y18n/index.js +++ b/node_modules/y18n/index.js @@ -16,6 +16,9 @@ function Y18N (opts) { } Y18N.prototype.__ = function () { + if (typeof arguments[0] !== 'string') { + return this._taggedLiteral.apply(this, arguments) + } var args = Array.prototype.slice.call(arguments) var str = args.shift() var cb = function () {} // start with noop. @@ -40,6 +43,19 @@ Y18N.prototype.__ = function () { return util.format.apply(util, [this.cache[this.locale][str] || str].concat(args)) } +Y18N.prototype._taggedLiteral = function (parts) { + var args = arguments + var str = '' + parts.forEach(function (part, i) { + var arg = args[i + 1] + str += part + if (typeof arg !== 'undefined') { + str += '%s' + } + }) + return this.__.apply(null, [str].concat([].slice.call(arguments, 1))) +} + Y18N.prototype._enqueueWrite = function (work) { this.writeQueue.push(work) if (this.writeQueue.length === 1) this._processWriteQueue() diff --git a/node_modules/y18n/package.json b/node_modules/y18n/package.json index b71b29b..edf054a 100644 --- a/node_modules/y18n/package.json +++ b/node_modules/y18n/package.json @@ -1,27 +1,27 @@ { - "_from": "y18n@^3.2.0", - "_id": "y18n@3.2.1", + "_from": "y18n@^4.0.0", + "_id": "y18n@4.0.0", "_inBundle": false, - "_integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", + "_integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "_location": "/y18n", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "y18n@^3.2.0", + "raw": "y18n@^4.0.0", "name": "y18n", "escapedName": "y18n", - "rawSpec": "^3.2.0", + "rawSpec": "^4.0.0", "saveSpec": null, - "fetchSpec": "^3.2.0" + "fetchSpec": "^4.0.0" }, "_requiredBy": [ "/yargs" ], - "_resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", - "_shasum": "6d15fba884c08679c0d77e88e7759e811e07fa41", - "_spec": "y18n@^3.2.0", - "_where": "/home/sergiu/linx-audio-simulator/node_modules/yargs", + "_resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "_shasum": "95ef94f85ecc81d007c264e190a120f0a3c8566b", + "_spec": "y18n@^4.0.0", + "_where": "/home/sergiu/linx-simulator2/node_modules/yargs", "author": { "name": "Ben Coe", "email": "ben@npmjs.com" @@ -33,12 +33,13 @@ "deprecated": false, "description": "the bare-bones internationalization library used by yargs", "devDependencies": { - "chai": "^3.4.1", - "coveralls": "^2.11.6", - "mocha": "^2.3.4", - "nyc": "^6.1.1", + "chai": "^4.0.1", + "coveralls": "^3.0.0", + "mocha": "^4.0.1", + "nyc": "^11.0.1", "rimraf": "^2.5.0", - "standard": "^5.4.1" + "standard": "^10.0.0-beta.0", + "standard-version": "^4.2.0" }, "files": [ "index.js" @@ -59,7 +60,8 @@ "scripts": { "coverage": "nyc report --reporter=text-lcov | coveralls", "pretest": "standard", + "release": "standard-version", "test": "nyc mocha" }, - "version": "3.2.1" + "version": "4.0.0" } diff --git a/node_modules/yargs/CHANGELOG.md b/node_modules/yargs/CHANGELOG.md index 6c0cb51..2ab9416 100644 --- a/node_modules/yargs/CHANGELOG.md +++ b/node_modules/yargs/CHANGELOG.md @@ -1,4 +1,889 @@ -## Change Log +# Changelog + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [14.2.0](https://github.com/yargs/yargs/compare/v14.1.0...v14.2.0) (2019-10-07) + + +### Bug Fixes + +* async middleware was called twice ([#1422](https://github.com/yargs/yargs/issues/1422)) ([9a42b63](https://github.com/yargs/yargs/commit/9a42b63)) +* fix promise check to accept any spec conform object ([#1424](https://github.com/yargs/yargs/issues/1424)) ([0be43d2](https://github.com/yargs/yargs/commit/0be43d2)) +* groups were not being maintained for nested commands ([#1430](https://github.com/yargs/yargs/issues/1430)) ([d38650e](https://github.com/yargs/yargs/commit/d38650e)) +* **docs:** broken markdown link ([#1426](https://github.com/yargs/yargs/issues/1426)) ([236e24e](https://github.com/yargs/yargs/commit/236e24e)) +* support merging deeply nested configuration ([#1423](https://github.com/yargs/yargs/issues/1423)) ([bae66fe](https://github.com/yargs/yargs/commit/bae66fe)) + + +### Features + +* **deps:** introduce yargs-parser with support for unknown-options-as-args ([#1440](https://github.com/yargs/yargs/issues/1440)) ([4d21520](https://github.com/yargs/yargs/commit/4d21520)) + +## [14.1.0](https://github.com/yargs/yargs/compare/v14.0.0...v14.1.0) (2019-09-06) + + +### Bug Fixes + +* **docs:** fix incorrect parserConfiguration documentation ([2a99124](https://github.com/yargs/yargs/commit/2a99124)) +* detect zsh when zsh isnt run as a login prompt ([#1395](https://github.com/yargs/yargs/issues/1395)) ([8792d13](https://github.com/yargs/yargs/commit/8792d13)) +* populate correct value on yargs.parsed and stop warning on access ([#1412](https://github.com/yargs/yargs/issues/1412)) ([bb0eb52](https://github.com/yargs/yargs/commit/bb0eb52)) +* showCompletionScript was logging script twice ([#1388](https://github.com/yargs/yargs/issues/1388)) ([07c8537](https://github.com/yargs/yargs/commit/07c8537)) +* strict() should not ignore hyphenated arguments ([#1414](https://github.com/yargs/yargs/issues/1414)) ([b774b5e](https://github.com/yargs/yargs/commit/b774b5e)) +* **docs:** formalize existing callback argument to showHelp ([#1386](https://github.com/yargs/yargs/issues/1386)) ([d217764](https://github.com/yargs/yargs/commit/d217764)) + + +### Features + +* make it possible to merge configurations when extending other config. ([#1411](https://github.com/yargs/yargs/issues/1411)) ([5d7ad98](https://github.com/yargs/yargs/commit/5d7ad98)) + +## [14.0.0](https://github.com/yargs/yargs/compare/v13.3.0...v14.0.0) (2019-07-30) + + +### ⚠ BREAKING CHANGES + +* we now only officially support yargs.$0 parameter and discourage direct access to yargs.parsed +* previously to this fix methods like `yargs.getOptions()` contained the state of the last command to execute. +* do not allow additional positionals in strict mode + +### Bug Fixes + +* calling parse multiple times now appropriately maintains state ([#1137](https://github.com/yargs/yargs/issues/1137)) ([#1369](https://github.com/yargs/yargs/issues/1369)) ([026b151](https://github.com/yargs/yargs/commit/026b151)) +* prefer user supplied script name in usage ([#1383](https://github.com/yargs/yargs/issues/1383)) ([28c74b9](https://github.com/yargs/yargs/commit/28c74b9)) +* **deps:** use decamelize from npm instead of vendored copy ([#1377](https://github.com/yargs/yargs/issues/1377)) ([015eeb9](https://github.com/yargs/yargs/commit/015eeb9)) +* **examples:** fix usage-options.js to reflect current API ([#1375](https://github.com/yargs/yargs/issues/1375)) ([6e5b76b](https://github.com/yargs/yargs/commit/6e5b76b)) +* do not allow additional positionals in strict mode ([35d777c](https://github.com/yargs/yargs/commit/35d777c)) +* properties accessed on singleton now reflect current state of instance ([#1366](https://github.com/yargs/yargs/issues/1366)) ([409d35b](https://github.com/yargs/yargs/commit/409d35b)) +* tolerate null prototype for config objects with `extends` ([#1376](https://github.com/yargs/yargs/issues/1376)) ([3d26d11](https://github.com/yargs/yargs/commit/3d26d11)), closes [#1372](https://github.com/yargs/yargs/issues/1372) +* yargs.parsed now populated before returning, when yargs.parse() called with no args (#1382) ([e3981fd](https://github.com/yargs/yargs/commit/e3981fd)), closes [#1382](https://github.com/yargs/yargs/issues/1382) + +### Features + +* adds support for multiple epilog messages ([#1384](https://github.com/yargs/yargs/issues/1384)) ([07a5554](https://github.com/yargs/yargs/commit/07a5554)) +* allow completionCommand to be set via showCompletionScript ([#1385](https://github.com/yargs/yargs/issues/1385)) ([5562853](https://github.com/yargs/yargs/commit/5562853)) + +## [13.3.0](https://www.github.com/yargs/yargs/compare/v13.2.4...v13.3.0) (2019-06-10) + + +### Bug Fixes + +* **deps:** yargs-parser update addressing several parsing bugs ([#1357](https://www.github.com/yargs/yargs/issues/1357)) ([e230d5b](https://www.github.com/yargs/yargs/commit/e230d5b)) + + +### Features + +* **i18n:** swap out os-locale dependency for simple inline implementation ([#1356](https://www.github.com/yargs/yargs/issues/1356)) ([4dfa19b](https://www.github.com/yargs/yargs/commit/4dfa19b)) +* support defaultDescription for positional arguments ([812048c](https://www.github.com/yargs/yargs/commit/812048c)) + +### [13.2.4](https://github.com/yargs/yargs/compare/v13.2.3...v13.2.4) (2019-05-13) + + +### Bug Fixes + +* **i18n:** rename unclear 'implication failed' to 'missing dependent arguments' ([#1317](https://github.com/yargs/yargs/issues/1317)) ([bf46813](https://github.com/yargs/yargs/commit/bf46813)) + + + +### [13.2.3](https://github.com/yargs/yargs/compare/v13.2.2...v13.2.3) (2019-05-05) + + +### Bug Fixes + +* **deps:** upgrade cliui for compatibility with latest chalk. ([#1330](https://github.com/yargs/yargs/issues/1330)) ([b20db65](https://github.com/yargs/yargs/commit/b20db65)) +* address issues with dutch translation ([#1316](https://github.com/yargs/yargs/issues/1316)) ([0295132](https://github.com/yargs/yargs/commit/0295132)) + + +### Tests + +* accept differently formatted output ([#1327](https://github.com/yargs/yargs/issues/1327)) ([c294d1b](https://github.com/yargs/yargs/commit/c294d1b)) + + + +## [13.2.2](https://github.com/yargs/yargs/compare/v13.2.1...v13.2.2) (2019-03-06) + + + +## [13.2.1](https://github.com/yargs/yargs/compare/v13.2.0...v13.2.1) (2019-02-18) + + +### Bug Fixes + +* add zsh script to files array ([3180224](https://github.com/yargs/yargs/commit/3180224)) +* support options/sub-commands in zsh completion ([0a96394](https://github.com/yargs/yargs/commit/0a96394)) + + +# [13.2.0](https://github.com/yargs/yargs/compare/v13.1.0...v13.2.0) (2019-02-15) + + +### Features + +* zsh auto completion ([#1292](https://github.com/yargs/yargs/issues/1292)) ([16c5d25](https://github.com/yargs/yargs/commit/16c5d25)), closes [#1156](https://github.com/yargs/yargs/issues/1156) + + + +# [13.1.0](https://github.com/yargs/yargs/compare/v13.0.0...v13.1.0) (2019-02-12) + + +### Features + +* add applyBeforeValidation, for applying sync middleware before validation ([5be206a](https://github.com/yargs/yargs/commit/5be206a)) + + + + +# [13.0.0](https://github.com/yargs/yargs/compare/v12.0.5...v13.0.0) (2019-02-02) + + +### Bug Fixes + +* **deps:** Update os-locale to avoid security vulnerability ([#1270](https://github.com/yargs/yargs/issues/1270)) ([27bf739](https://github.com/yargs/yargs/commit/27bf739)) +* **validation:** Use the error as a message when none exists otherwise ([#1268](https://github.com/yargs/yargs/issues/1268)) ([0510fe6](https://github.com/yargs/yargs/commit/0510fe6)) +* better bash path completion ([#1272](https://github.com/yargs/yargs/issues/1272)) ([da75ea2](https://github.com/yargs/yargs/commit/da75ea2)) +* middleware added multiple times due to reference bug ([#1282](https://github.com/yargs/yargs/issues/1282)) ([64af518](https://github.com/yargs/yargs/commit/64af518)) + + +### Chores + +* ~drop Node 6 from testing matrix ([#1287](https://github.com/yargs/yargs/issues/1287)) ([ef16792](https://github.com/yargs/yargs/commit/ef16792))~ + * _opting to not drop Node 6 support until April, [see](https://github.com/nodejs/Release)._ +* update dependencies ([#1284](https://github.com/yargs/yargs/issues/1284)) ([f25de4f](https://github.com/yargs/yargs/commit/f25de4f)) + + +### Features + +* Add `.parserConfiguration()` method, deprecating package.json config ([#1262](https://github.com/yargs/yargs/issues/1262)) ([3c6869a](https://github.com/yargs/yargs/commit/3c6869a)) +* adds config option for sorting command output ([#1256](https://github.com/yargs/yargs/issues/1256)) ([6916ce9](https://github.com/yargs/yargs/commit/6916ce9)) +* options/positionals with leading '+' and '0' no longer parse as numbers ([#1286](https://github.com/yargs/yargs/issues/1286)) ([e9dc3aa](https://github.com/yargs/yargs/commit/e9dc3aa)) +* support promises in middleware ([f3a4e4f](https://github.com/yargs/yargs/commit/f3a4e4f)) + + +### BREAKING CHANGES + +* options with leading '+' or '0' now parse as strings +* dropping Node 6 which hits end of life in April 2019 +* see [yargs-parser@12.0.0 CHANGELOG](https://github.com/yargs/yargs-parser/blob/master/CHANGELOG.md#breaking-changes) +* we now warn if the yargs stanza package.json is used. + + + + +## [12.0.5](https://github.com/yargs/yargs/compare/v12.0.4...v12.0.5) (2018-11-19) + + +### Bug Fixes + +* allows camel-case, variadic arguments, and strict mode to be combined ([#1247](https://github.com/yargs/yargs/issues/1247)) ([eacc035](https://github.com/yargs/yargs/commit/eacc035)) + + + + +## [12.0.4](https://github.com/yargs/yargs/compare/v12.0.3...v12.0.4) (2018-11-10) + + +### Bug Fixes + +* don't load config when processing positionals ([5d0dc92](https://github.com/yargs/yargs/commit/5d0dc92)) + + + + +## [12.0.3](https://github.com/yargs/yargs/compare/v12.0.2...v12.0.3) (2018-10-06) + + +### Bug Fixes + +* $0 contains first arg in bundled electron apps ([#1206](https://github.com/yargs/yargs/issues/1206)) ([567820b](https://github.com/yargs/yargs/commit/567820b)) +* accept single function for middleware ([66fd6f7](https://github.com/yargs/yargs/commit/66fd6f7)), closes [#1214](https://github.com/yargs/yargs/issues/1214) [#1214](https://github.com/yargs/yargs/issues/1214) +* hide `hidden` options from help output even if they are in a group ([#1221](https://github.com/yargs/yargs/issues/1221)) ([da54028](https://github.com/yargs/yargs/commit/da54028)) +* improve Norwegian Bokmål translations ([#1208](https://github.com/yargs/yargs/issues/1208)) ([a458fa4](https://github.com/yargs/yargs/commit/a458fa4)) +* improve Norwegian Nynorsk translations ([#1207](https://github.com/yargs/yargs/issues/1207)) ([d422eb5](https://github.com/yargs/yargs/commit/d422eb5)) + + + + +## [12.0.2](https://github.com/yargs/yargs/compare/v12.0.1...v12.0.2) (2018-09-04) + + +### Bug Fixes + +* middleware should work regardless of when method is called ([664b265](https://github.com/yargs/yargs/commit/664b265)), closes [#1178](https://github.com/yargs/yargs/issues/1178) +* translation not working when using __ with a single parameter ([#1183](https://github.com/yargs/yargs/issues/1183)) ([f449aea](https://github.com/yargs/yargs/commit/f449aea)) +* upgrade os-locale to version that addresses license issue ([#1195](https://github.com/yargs/yargs/issues/1195)) ([efc0970](https://github.com/yargs/yargs/commit/efc0970)) + + + + +## [12.0.1](https://github.com/yargs/yargs/compare/v12.0.0...v12.0.1) (2018-06-29) + + + + +# [12.0.0](https://github.com/yargs/yargs/compare/v11.1.0...v12.0.0) (2018-06-26) + + +### Bug Fixes + +* .argv and .parse() now invoke identical code path ([#1126](https://github.com/yargs/yargs/issues/1126)) ([f13ebf4](https://github.com/yargs/yargs/commit/f13ebf4)) +* remove the trailing white spaces from the help output ([#1090](https://github.com/yargs/yargs/issues/1090)) ([3f0746c](https://github.com/yargs/yargs/commit/3f0746c)) +* **completion:** Avoid default command and recommendations during completion ([#1123](https://github.com/yargs/yargs/issues/1123)) ([036e7c5](https://github.com/yargs/yargs/commit/036e7c5)) + + +### Chores + +* test Node.js 6, 8 and 10 ([#1160](https://github.com/yargs/yargs/issues/1160)) ([84f9d2b](https://github.com/yargs/yargs/commit/84f9d2b)) +* upgrade to version of yargs-parser that does not populate value for unset boolean ([#1104](https://github.com/yargs/yargs/issues/1104)) ([d4705f4](https://github.com/yargs/yargs/commit/d4705f4)) + + +### Features + +* add support for global middleware, useful for shared tasks like metrics ([#1119](https://github.com/yargs/yargs/issues/1119)) ([9d71ac7](https://github.com/yargs/yargs/commit/9d71ac7)) +* allow setting scriptName $0 ([#1143](https://github.com/yargs/yargs/issues/1143)) ([a2f2eae](https://github.com/yargs/yargs/commit/a2f2eae)) +* remove `setPlaceholderKeys` ([#1105](https://github.com/yargs/yargs/issues/1105)) ([6ee2c82](https://github.com/yargs/yargs/commit/6ee2c82)) + + +### BREAKING CHANGES + +* Options absent from `argv` (not set via CLI argument) are now absent from the parsed result object rather than being set with `undefined` +* drop Node 4 from testing matrix, such that we'll gradually start drifting away from supporting Node 4. +* yargs-parser does not populate 'false' when boolean flag is not passed +* tests that assert against help output will need to be updated + + + + +# [11.1.0](https://github.com/yargs/yargs/compare/v11.0.0...v11.1.0) (2018-03-04) + + +### Bug Fixes + +* choose correct config directory when require.main does not exist ([#1056](https://github.com/yargs/yargs/issues/1056)) ([a04678c](https://github.com/yargs/yargs/commit/a04678c)) + + +### Features + +* allow hidden options to be displayed with --show-hidden ([#1061](https://github.com/yargs/yargs/issues/1061)) ([ea862ae](https://github.com/yargs/yargs/commit/ea862ae)) +* extend *.rc files in addition to json ([#1080](https://github.com/yargs/yargs/issues/1080)) ([11691a6](https://github.com/yargs/yargs/commit/11691a6)) + + + + +# [11.0.0](https://github.com/yargs/yargs/compare/v10.1.2...v11.0.0) (2018-01-22) + + +### Bug Fixes + +* Set implicit nargs=1 when type=number requiresArg=true ([#1050](https://github.com/yargs/yargs/issues/1050)) ([2b56812](https://github.com/yargs/yargs/commit/2b56812)) + + +### Features + +* requiresArg is now simply an alias for nargs(1) ([#1054](https://github.com/yargs/yargs/issues/1054)) ([a3ddacc](https://github.com/yargs/yargs/commit/a3ddacc)) + + +### BREAKING CHANGES + +* requiresArg now has significantly different error output, matching nargs. + + + + +## [10.1.2](https://github.com/yargs/yargs/compare/v10.1.1...v10.1.2) (2018-01-17) + + +### Bug Fixes + +* requiresArg should only be enforced if argument exists ([#1043](https://github.com/yargs/yargs/issues/1043)) ([fbf41ae](https://github.com/yargs/yargs/commit/fbf41ae)) + + + + +## [10.1.1](https://github.com/yargs/yargs/compare/v10.1.0...v10.1.1) (2018-01-09) + + +### Bug Fixes + +* Add `dirname` sanity check on `findUp` ([#1036](https://github.com/yargs/yargs/issues/1036)) ([331d103](https://github.com/yargs/yargs/commit/331d103)) + + + + +# [10.1.0](https://github.com/yargs/yargs/compare/v10.0.3...v10.1.0) (2018-01-01) + + +### Bug Fixes + +* 'undefined' should be taken to mean no argument was provided ([#1015](https://github.com/yargs/yargs/issues/1015)) ([c679e90](https://github.com/yargs/yargs/commit/c679e90)) + + +### Features + +* add missing simple chinese locale strings ([#1004](https://github.com/yargs/yargs/issues/1004)) ([3cc24ec](https://github.com/yargs/yargs/commit/3cc24ec)) +* add Norwegian Nynorsk translations ([#1028](https://github.com/yargs/yargs/issues/1028)) ([a5ac213](https://github.com/yargs/yargs/commit/a5ac213)) +* async command handlers ([#1001](https://github.com/yargs/yargs/issues/1001)) ([241124b](https://github.com/yargs/yargs/commit/241124b)) +* middleware ([#881](https://github.com/yargs/yargs/issues/881)) ([77b8dbc](https://github.com/yargs/yargs/commit/77b8dbc)) + + + + +## [10.0.3](https://github.com/yargs/yargs/compare/v10.0.2...v10.0.3) (2017-10-21) + + +### Bug Fixes + +* parse array rather than string, so that quotes are safe ([#993](https://github.com/yargs/yargs/issues/993)) ([c351685](https://github.com/yargs/yargs/commit/c351685)) + + + + +## [10.0.2](https://github.com/yargs/yargs/compare/v10.0.1...v10.0.2) (2017-10-21) + + +### Bug Fixes + +* fix tiny spacing issue with usage ([#992](https://github.com/yargs/yargs/issues/992)) ([7871327](https://github.com/yargs/yargs/commit/7871327)) + + + + +## [10.0.1](https://github.com/yargs/yargs/compare/v10.0.0...v10.0.1) (2017-10-19) + + +### Bug Fixes + +* help strings for nested commands were missing parent commands ([#990](https://github.com/yargs/yargs/issues/990)) ([cd1ca15](https://github.com/yargs/yargs/commit/cd1ca15)) +* use correct completion command in generated completion script ([#988](https://github.com/yargs/yargs/issues/988)) ([3c8ac1d](https://github.com/yargs/yargs/commit/3c8ac1d)) + + + + +# [10.0.0](https://github.com/yargs/yargs/compare/v9.1.0...v10.0.0) (2017-10-18) + + +### Bug Fixes + +* config and normalize can be disabled with false ([#952](https://github.com/yargs/yargs/issues/952)) ([3bb8771](https://github.com/yargs/yargs/commit/3bb8771)) +* less eager help command execution ([#972](https://github.com/yargs/yargs/issues/972)) ([8c1d7bf](https://github.com/yargs/yargs/commit/8c1d7bf)) +* the positional argument parse was clobbering global flag arguments ([#984](https://github.com/yargs/yargs/issues/984)) ([7e58453](https://github.com/yargs/yargs/commit/7e58453)) + + +### Features + +* .usage() can now be used to configure a default command ([#975](https://github.com/yargs/yargs/issues/975)) ([7269531](https://github.com/yargs/yargs/commit/7269531)) +* hidden options are now explicitly indicated using "hidden" flag ([#962](https://github.com/yargs/yargs/issues/962)) ([280d0d6](https://github.com/yargs/yargs/commit/280d0d6)) +* introduce .positional() for configuring positional arguments ([#967](https://github.com/yargs/yargs/issues/967)) ([cb16460](https://github.com/yargs/yargs/commit/cb16460)) +* replace $0 with file basename ([#983](https://github.com/yargs/yargs/issues/983)) ([20bb99b](https://github.com/yargs/yargs/commit/20bb99b)) + + +### BREAKING CHANGES + +* .usage() no longer accepts an options object as the second argument. It can instead be used as an alias for configuring a default command. +* previously hidden options were simply implied using a falsy description +* help command now only executes if it's the last positional in argv._ + + + + +# [9.1.0](https://github.com/yargs/yargs/compare/v9.0.1...v9.1.0) (2017-09-25) + + +### Bug Fixes + +* **command:** Run default cmd even if the only cmd ([#950](https://github.com/yargs/yargs/issues/950)) ([7b22203](https://github.com/yargs/yargs/commit/7b22203)) + + +### Features + +* multiple usage calls are now collected, not replaced ([#958](https://github.com/yargs/yargs/issues/958)) ([74a38b2](https://github.com/yargs/yargs/commit/74a38b2)) + + + + +## [9.0.1](https://github.com/yargs/yargs/compare/v9.0.0...v9.0.1) (2017-09-17) + + +### Bug Fixes + +* implications fails only displayed once ([#954](https://github.com/yargs/yargs/issues/954)) ([ac8088b](https://github.com/yargs/yargs/commit/ac8088b)) + + + + +# [9.0.0](https://github.com/yargs/yargs/compare/v8.0.2...v9.0.0) (2017-09-03) + + +### Bug Fixes + +* 'undefined' default value for choices resulted in validation failing ([782b896](https://github.com/yargs/yargs/commit/782b896)) +* address bug with handling of arrays of implications ([c240661](https://github.com/yargs/yargs/commit/c240661)) +* defaulting keys to 'undefined' interfered with conflicting key logic ([a8e0cff](https://github.com/yargs/yargs/commit/a8e0cff)) +* don't bother calling JSON.stringify() on string default values ([#891](https://github.com/yargs/yargs/issues/891)) ([628be21](https://github.com/yargs/yargs/commit/628be21)) +* exclude positional arguments from completion output ([#927](https://github.com/yargs/yargs/issues/927)) ([71c7ec7](https://github.com/yargs/yargs/commit/71c7ec7)) +* strict mode should not fail for hidden options ([#949](https://github.com/yargs/yargs/issues/949)) ([0e0c58d](https://github.com/yargs/yargs/commit/0e0c58d)) + + +### Features + +* allow implies and conflicts to accept array values ([#922](https://github.com/yargs/yargs/issues/922)) ([abdc7da](https://github.com/yargs/yargs/commit/abdc7da)) +* allow parse with no arguments as alias for yargs.argv ([#944](https://github.com/yargs/yargs/issues/944)) ([a9f03e7](https://github.com/yargs/yargs/commit/a9f03e7)) +* enable .help() and .version() by default ([#912](https://github.com/yargs/yargs/issues/912)) ([1ef44e0](https://github.com/yargs/yargs/commit/1ef44e0)) +* to allow both undefined and nulls, for benefit of TypeScript ([#945](https://github.com/yargs/yargs/issues/945)) ([792564d](https://github.com/yargs/yargs/commit/792564d)) + + +### BREAKING CHANGES + +* version() and help() are now enabled by default, and show up in help output; the implicit help command can no longer be enabled/disabled independently from the help command itself (which can now be disabled). +* parse() now behaves as an alias for .argv, unless a parseCallback is provided. + + + + +## [8.0.2](https://github.com/yargs/yargs/compare/v8.0.1...v8.0.2) (2017-06-12) + + + + +## [8.0.1](https://github.com/yargs/yargs/compare/v8.0.0...v8.0.1) (2017-05-02) + + + + +# [8.0.0](https://github.com/yargs/yargs/compare/v7.1.0...v8.0.0) (2017-05-01) + + +### Bug Fixes + +* commands are now applied in order, from left to right ([#857](https://github.com/yargs/yargs/issues/857)) ([baba863](https://github.com/yargs/yargs/commit/baba863)) +* help now takes precedence over command recommendation ([#866](https://github.com/yargs/yargs/issues/866)) ([17e3567](https://github.com/yargs/yargs/commit/17e3567)) +* positional arguments now work if no handler is provided to inner command ([#864](https://github.com/yargs/yargs/issues/864)) ([e28ded3](https://github.com/yargs/yargs/commit/e28ded3)) + + +### Chores + +* upgrade yargs-parser ([#867](https://github.com/yargs/yargs/issues/867)) ([8f9c6c6](https://github.com/yargs/yargs/commit/8f9c6c6)) + + +### Features + +* allow extends to inherit from a module ([#865](https://github.com/yargs/yargs/issues/865)) ([89456d9](https://github.com/yargs/yargs/commit/89456d9)) +* allow strict mode to be disabled ([#840](https://github.com/yargs/yargs/issues/840)) ([6f78c05](https://github.com/yargs/yargs/commit/6f78c05)) + + +### BREAKING CHANGES + +* extends functionality now always loads the JSON provided, rather than reading from a specific key +* Node 4+ is now required; this will allow us to start updating our dependencies. +* the first argument to strict() is now used to enable/disable its functionality, rather than controlling whether or not it is global. + + + + +# [7.1.0](https://github.com/yargs/yargs/compare/v7.0.2...v7.1.0) (2017-04-13) + + +### Bug Fixes + +* fix demandOption no longer treats 'false' as truthy ([#829](https://github.com/yargs/yargs/issues/829)) ([c748dd2](https://github.com/yargs/yargs/commit/c748dd2)) +* get terminalWidth in non interactive mode no longer causes a validation exception ([#837](https://github.com/yargs/yargs/issues/837)) ([360e301](https://github.com/yargs/yargs/commit/360e301)) +* we shouldn't output help if we've printed a prior help-like message ([#847](https://github.com/yargs/yargs/issues/847)) ([17e89bd](https://github.com/yargs/yargs/commit/17e89bd)) + + +### Features + +* add support for numeric commands ([#825](https://github.com/yargs/yargs/issues/825)) ([fde0564](https://github.com/yargs/yargs/commit/fde0564)) + + + + +## [7.0.2](https://github.com/yargs/yargs/compare/v7.0.1...v7.0.2) (2017-03-10) + + +### Bug Fixes + +* populating placeholder arguments broke validation ([b3eb2fe](https://github.com/yargs/yargs/commit/b3eb2fe)) + + + + +## [7.0.1](https://github.com/yargs/yargs/compare/v7.0.0...v7.0.1) (2017-03-03) + + +### Bug Fixes + +* --help with default command should print top-level help ([#810](https://github.com/yargs/yargs/issues/810)) ([9c03fa4](https://github.com/yargs/yargs/commit/9c03fa4)) + + + + +# [7.0.0](https://github.com/yargs/yargs/compare/v6.6.0...v7.0.0) (2017-02-26) + + +### Bug Fixes + +* address min/max validation message regression ([#750](https://github.com/yargs/yargs/issues/750)) ([2e5ce0f](https://github.com/yargs/yargs/commit/2e5ce0f)) +* address positional argument strict() bug introduced in [#766](https://github.com/yargs/yargs/issues/766) ([#784](https://github.com/yargs/yargs/issues/784)) ([a8528e6](https://github.com/yargs/yargs/commit/a8528e6)) +* console.warn() rather than throwing errors when api signatures are incorrect ([#804](https://github.com/yargs/yargs/issues/804)) ([a607061](https://github.com/yargs/yargs/commit/a607061)) +* context should override parsed argv ([#786](https://github.com/yargs/yargs/issues/786)) ([0997288](https://github.com/yargs/yargs/commit/0997288)) +* context variables are now recognized in strict() mode ([#796](https://github.com/yargs/yargs/issues/796)) ([48575cd](https://github.com/yargs/yargs/commit/48575cd)) +* errors were not bubbling appropriately from sub-commands to top-level ([#802](https://github.com/yargs/yargs/issues/802)) ([8a992f5](https://github.com/yargs/yargs/commit/8a992f5)) +* positional arguments of sub-commands threw strict() exception ([#805](https://github.com/yargs/yargs/issues/805)) ([f3f074b](https://github.com/yargs/yargs/commit/f3f074b)) +* pull in yargs-parser with modified env precedence ([#787](https://github.com/yargs/yargs/issues/787)) ([e0fbbe5](https://github.com/yargs/yargs/commit/e0fbbe5)) +* running parse() multiple times on the same yargs instance caused exception if help() enabled ([#790](https://github.com/yargs/yargs/issues/790)) ([07e39b7](https://github.com/yargs/yargs/commit/07e39b7)) +* use path.resolve() to support node 0.10 ([#797](https://github.com/yargs/yargs/issues/797)) ([49a93fc](https://github.com/yargs/yargs/commit/49a93fc)) + + +### Features + +* add conflicts and implies shorthands. ([#753](https://github.com/yargs/yargs/issues/753)) ([bd1472b](https://github.com/yargs/yargs/commit/bd1472b)) +* add traditional Chinese translation ([#780](https://github.com/yargs/yargs/issues/780)) ([6ab6a95](https://github.com/yargs/yargs/commit/6ab6a95)) +* allow provided config object to extend other configs ([#779](https://github.com/yargs/yargs/issues/779)) ([3280dd0](https://github.com/yargs/yargs/commit/3280dd0)) +* function argument validation ([#773](https://github.com/yargs/yargs/issues/773)) ([22ed9bb](https://github.com/yargs/yargs/commit/22ed9bb)) +* if only one column is provided for examples, allow it to take up the entire line ([#749](https://github.com/yargs/yargs/issues/749)) ([7931652](https://github.com/yargs/yargs/commit/7931652)) +* introduce custom yargs error object ([#765](https://github.com/yargs/yargs/issues/765)) ([8308efa](https://github.com/yargs/yargs/commit/8308efa)) +* introduces support for default commands, using the '*' identifier ([#785](https://github.com/yargs/yargs/issues/785)) ([d78a0f5](https://github.com/yargs/yargs/commit/d78a0f5)) +* rethink how options are inherited by commands ([#766](https://github.com/yargs/yargs/issues/766)) ([ab1fa4b](https://github.com/yargs/yargs/commit/ab1fa4b)) + + +### BREAKING CHANGES + +* `extends` key in config file is now used for extending other config files +* environment variables now take precedence over config files. +* context now takes precedence over argv and defaults +* the arguments passed to functions are now validated, there's a good chance this will throw exceptions for a few folks who are using the API in an unexpected way. +* by default options, and many of yargs' parsing helpers will now default to being applied globally; such that they are no-longer reset before being passed into commands. +* yargs will no longer aggressively suppress errors, allowing errors that are not generated internally to bubble. + + + + +# [6.6.0](https://github.com/yargs/yargs/compare/v6.5.0...v6.6.0) (2016-12-29) + + +### Bug Fixes + +* [object Object] was accidentally being populated on options object ([#736](https://github.com/yargs/yargs/issues/736)) ([f755e27](https://github.com/yargs/yargs/commit/f755e27)) +* do not use cwd when resolving package.json for yargs parsing config ([#726](https://github.com/yargs/yargs/issues/726)) ([9bdaab7](https://github.com/yargs/yargs/commit/9bdaab7)) + + +### Features + +* implement conflicts() for defining mutually exclusive arguments; thanks [@madcampos](https://github.com/madcampos)! ([#741](https://github.com/yargs/yargs/issues/741)) ([5883779](https://github.com/yargs/yargs/commit/5883779)) +* split demand() into demandCommand()/demandOption() ([#740](https://github.com/yargs/yargs/issues/740)) ([66573c8](https://github.com/yargs/yargs/commit/66573c8)) +* support for positional argument aliases ([#727](https://github.com/yargs/yargs/issues/727)) ([27e1a57](https://github.com/yargs/yargs/commit/27e1a57)) + + + + +# [6.5.0](https://github.com/yargs/yargs/compare/v6.4.0...v6.5.0) (2016-12-01) + + +### Bug Fixes + +* still freeze/unfreeze if parse() is called in isolation ([#717](https://github.com/yargs/yargs/issues/717)) ([30a9492](https://github.com/yargs/yargs/commit/30a9492)) + + +### Features + +* pull in yargs-parser introducing additional settings ([#688](https://github.com/yargs/yargs/issues/688)), and fixing [#716](https://github.com/yargs/yargs/issues/716) ([#722](https://github.com/yargs/yargs/issues/722)) ([702995a](https://github.com/yargs/yargs/commit/702995a)) + + + + +# [6.4.0](https://github.com/yargs/yargs/compare/v6.3.0...v6.4.0) (2016-11-13) + + +### Bug Fixes + +* **locales:** correct some Russian translations ([#691](https://github.com/yargs/yargs/issues/691)) ([a980671](https://github.com/yargs/yargs/commit/a980671)) + + +### Features + +* **locales:** Added Belarusian translation ([#690](https://github.com/yargs/yargs/issues/690)) ([68dac1f](https://github.com/yargs/yargs/commit/68dac1f)) +* **locales:** Create nl.json ([#687](https://github.com/yargs/yargs/issues/687)) ([46ce1bb](https://github.com/yargs/yargs/commit/46ce1bb)) +* update to yargs-parser that addresses [#598](https://github.com/yargs/yargs/issues/598), [#617](https://github.com/yargs/yargs/issues/617) ([#700](https://github.com/yargs/yargs/issues/700)) ([54cb31d](https://github.com/yargs/yargs/commit/54cb31d)) +* yargs is now passed as the third-argument to fail handler ([#613](https://github.com/yargs/yargs/issues/613)) ([21b74f9](https://github.com/yargs/yargs/commit/21b74f9)) + + +### Performance Improvements + +* normalizing package data is an expensive operation ([#705](https://github.com/yargs/yargs/issues/705)) ([49cf533](https://github.com/yargs/yargs/commit/49cf533)) + + + + +# [6.3.0](https://github.com/yargs/yargs/compare/v6.2.0...v6.3.0) (2016-10-19) + + +### Bug Fixes + +* **command:** subcommands via commandDir() now supported for parse(msg, cb) ([#678](https://github.com/yargs/yargs/issues/678)) ([6b85cc6](https://github.com/yargs/yargs/commit/6b85cc6)) + + +### Features + +* **locales:** Add Thai locale file ([#679](https://github.com/yargs/yargs/issues/679)) ([c05e36b](https://github.com/yargs/yargs/commit/c05e36b)) + + + + +# [6.2.0](https://github.com/yargs/yargs/compare/v6.1.1...v6.2.0) (2016-10-16) + + +### Bug Fixes + +* stop applying parser to context object ([#675](https://github.com/yargs/yargs/issues/675)) ([3fe9b8f](https://github.com/yargs/yargs/commit/3fe9b8f)) + + +### Features + +* add new pt_BR translations ([#674](https://github.com/yargs/yargs/issues/674)) ([5615a82](https://github.com/yargs/yargs/commit/5615a82)) +* Italian translations for 'did you mean' and 'aliases' ([#673](https://github.com/yargs/yargs/issues/673)) ([81984e6](https://github.com/yargs/yargs/commit/81984e6)) + + + + +## [6.1.1](https://github.com/yargs/yargs/compare/v6.1.0...v6.1.1) (2016-10-15) + + +### Bug Fixes + +* freeze was not resetting configObjects to initial state; addressed performance issue raised by [@nexdrew](https://github.com/nexdrew). ([#670](https://github.com/yargs/yargs/issues/670)) ([ae4bcd4](https://github.com/yargs/yargs/commit/ae4bcd4)) + + + + +# [6.1.0](https://github.com/yargs/yargs/compare/v6.0.0...v6.1.0) (2016-10-15) + + +### Bug Fixes + +* **locales:** change some translations ([#667](https://github.com/yargs/yargs/issues/667)) ([aa966c5](https://github.com/yargs/yargs/commit/aa966c5)) +* **locales:** conform hi locale to y18n.__n expectations ([#666](https://github.com/yargs/yargs/issues/666)) ([22adb18](https://github.com/yargs/yargs/commit/22adb18)) + + +### Features + +* initial support for command aliases ([#647](https://github.com/yargs/yargs/issues/647)) ([127a040](https://github.com/yargs/yargs/commit/127a040)) +* **command:** add camelcase commands to argv ([#658](https://github.com/yargs/yargs/issues/658)) ([b1cabae](https://github.com/yargs/yargs/commit/b1cabae)) +* **locales:** add Hindi translations ([9290912](https://github.com/yargs/yargs/commit/9290912)) +* **locales:** add Hungarian translations ([be92327](https://github.com/yargs/yargs/commit/be92327)) +* **locales:** Japanese translations for 'did you mean' and 'aliases' ([#651](https://github.com/yargs/yargs/issues/651)) ([5eb78fc](https://github.com/yargs/yargs/commit/5eb78fc)) +* **locales:** Polish translations for 'did you mean' and 'aliases' ([#650](https://github.com/yargs/yargs/issues/650)) ([c951c0e](https://github.com/yargs/yargs/commit/c951c0e)) +* reworking yargs API to make it easier to run in headless environments, e.g., Slack ([#646](https://github.com/yargs/yargs/issues/646)) ([f284c29](https://github.com/yargs/yargs/commit/f284c29)) +* Turkish translations for 'did you mean' and 'aliases' ([#660](https://github.com/yargs/yargs/issues/660)) ([072fd45](https://github.com/yargs/yargs/commit/072fd45)) + + + + +# [6.0.0](https://github.com/yargs/yargs/compare/v5.0.0...v6.0.0) (2016-09-30) + + +### Bug Fixes + +* changed parsing of the command string to ignore extra spaces ([#600](https://github.com/yargs/yargs/issues/600)) ([e8e5a72](https://github.com/yargs/yargs/commit/e8e5a72)) +* drop lodash.assign ([#641](https://github.com/yargs/yargs/issues/641)) ([ad3146f](https://github.com/yargs/yargs/commit/ad3146f)) +* for args that have skipValidation set to `true`, check if the parsed arg is `true` ([#619](https://github.com/yargs/yargs/issues/619)) ([658a34c](https://github.com/yargs/yargs/commit/658a34c)) +* upgrade standard, and fix appveyor config so that it works with newest standard ([#607](https://github.com/yargs/yargs/issues/607)) ([c301f42](https://github.com/yargs/yargs/commit/c301f42)) + + +### Chores + +* upgrade yargs-parser ([#633](https://github.com/yargs/yargs/issues/633)) ([cc1224e](https://github.com/yargs/yargs/commit/cc1224e)) + + +### Features + +* make opts object optional for .option() ([#624](https://github.com/yargs/yargs/issues/624)) ([4f29de6](https://github.com/yargs/yargs/commit/4f29de6)) + + +### Performance Improvements + +* defer windowWidth() to improve perf for non-help usage ([#610](https://github.com/yargs/yargs/issues/610)) ([cbc3636](https://github.com/yargs/yargs/commit/cbc3636)) + + +### BREAKING CHANGES + +* coerce is now applied as a final step after other parsing is complete + + + + +# [5.0.0](https://github.com/yargs/yargs/compare/v4.8.1...v5.0.0) (2016-08-14) + + +### Bug Fixes + +* **default:** Remove undocumented alias of default() ([#469](https://github.com/yargs/yargs/issues/469)) ([b8591b2](https://github.com/yargs/yargs/commit/b8591b2)) +* remove deprecated zh.json ([#578](https://github.com/yargs/yargs/issues/578)) ([317c62c](https://github.com/yargs/yargs/commit/317c62c)) + + +### Features + +* .help() API can now enable implicit help command ([#574](https://github.com/yargs/yargs/issues/574)) ([7645019](https://github.com/yargs/yargs/commit/7645019)) +* **command:** builder function no longer needs to return the yargs instance ([#549](https://github.com/yargs/yargs/issues/549)) ([eaa2873](https://github.com/yargs/yargs/commit/eaa2873)) +* add coerce api ([#586](https://github.com/yargs/yargs/issues/586)) ([1d53ccb](https://github.com/yargs/yargs/commit/1d53ccb)) +* adds recommendCommands() for command suggestions ([#580](https://github.com/yargs/yargs/issues/580)) ([59474dc](https://github.com/yargs/yargs/commit/59474dc)) +* apply .env() globally ([#553](https://github.com/yargs/yargs/issues/553)) ([be65728](https://github.com/yargs/yargs/commit/be65728)) +* apply default builder to command() and apply fail() handlers globally ([#583](https://github.com/yargs/yargs/issues/583)) ([0aaa68b](https://github.com/yargs/yargs/commit/0aaa68b)) +* update yargs-parser to version 3.1.0 ([#581](https://github.com/yargs/yargs/issues/581)) ([882a127](https://github.com/yargs/yargs/commit/882a127)) + + +### Performance Improvements + +* defer requiring most external libs until needed ([#584](https://github.com/yargs/yargs/issues/584)) ([f9b0ed4](https://github.com/yargs/yargs/commit/f9b0ed4)) + + +### BREAKING CHANGES + +* fail is now applied globally. +* we now default to an empty builder function when command is executed with no builder. +* yargs-parser now better handles negative integer values, at the cost of handling numeric option names, e.g., -1 hello +* default: removed undocumented `defaults` alias for `default`. +* introduces a default `help` command which outputs help, as an alternative to a help flag. +* interpret demand() numbers as relative to executing command ([#582](https://github.com/yargs/yargs/issues/582)) ([927810c](https://github.com/yargs/yargs/commit/927810c)) + + + + +## [4.8.1](https://github.com/yargs/yargs/compare/v4.8.0...v4.8.1) (2016-07-16) + + +### Bug Fixes + +* **commandDir:** make dir relative to caller instead of require.main.filename ([#548](https://github.com/yargs/yargs/issues/548)) ([3c2e479](https://github.com/yargs/yargs/commit/3c2e479)) +* add config lookup for .implies() ([#556](https://github.com/yargs/yargs/issues/556)) ([8d7585c](https://github.com/yargs/yargs/commit/8d7585c)) +* cache pkg lookups by path to avoid returning the wrong one ([#552](https://github.com/yargs/yargs/issues/552)) ([fea7e0b](https://github.com/yargs/yargs/commit/fea7e0b)) +* positional arguments were not being handled appropriately by parse() ([#559](https://github.com/yargs/yargs/issues/559)) ([063a866](https://github.com/yargs/yargs/commit/063a866)) +* pull in [@nexdrew](https://github.com/nexdrew)'s fixes to yargs-parser ([#560](https://github.com/yargs/yargs/issues/560)) ([c77c080](https://github.com/yargs/yargs/commit/c77c080)), closes [#560](https://github.com/yargs/yargs/issues/560) + + + + +# [4.8.0](https://github.com/yargs/yargs/compare/v4.7.1...v4.8.0) (2016-07-09) + + +### Bug Fixes + +* drop unused camelcase dependency fixes [#516](https://github.com/yargs/yargs/issues/516) ([#525](https://github.com/yargs/yargs/issues/525)) ([365fb9a](https://github.com/yargs/yargs/commit/365fb9a)), closes [#516](https://github.com/yargs/yargs/issues/516) [#525](https://github.com/yargs/yargs/issues/525) +* fake a tty in tests, so that we can use the new set-blocking ([#512](https://github.com/yargs/yargs/issues/512)) ([a54c742](https://github.com/yargs/yargs/commit/a54c742)) +* ignore invalid package.json during read-pkg-up ([#546](https://github.com/yargs/yargs/issues/546)) ([e058c87](https://github.com/yargs/yargs/commit/e058c87)) +* keep both zh and zh_CN until yargs[@5](https://github.com/5).x ([0f8faa7](https://github.com/yargs/yargs/commit/0f8faa7)) +* lazy-load package.json and cache. get rid of pkg-conf dependency. ([#544](https://github.com/yargs/yargs/issues/544)) ([2609b2e](https://github.com/yargs/yargs/commit/2609b2e)) +* we now respect the order of _ when applying commands ([#537](https://github.com/yargs/yargs/issues/537)) ([ed86b78](https://github.com/yargs/yargs/commit/ed86b78)) + + +### Features + +* add .commandDir(dir) to API to apply all command modules from a relative directory ([#494](https://github.com/yargs/yargs/issues/494)) ([b299dff](https://github.com/yargs/yargs/commit/b299dff)) +* **command:** derive missing command string from module filename ([#527](https://github.com/yargs/yargs/issues/527)) ([20d4b8a](https://github.com/yargs/yargs/commit/20d4b8a)) +* builder is now optional for a command module ([#545](https://github.com/yargs/yargs/issues/545)) ([8d6ad6e](https://github.com/yargs/yargs/commit/8d6ad6e)) + + + + +## [4.7.1](https://github.com/yargs/yargs/compare/v4.7.0...v4.7.1) (2016-05-15) + + +### Bug Fixes + +* switch to using `const` rather than `var` ([#499](https://github.com/yargs/yargs/pull/499)) +* make stdout flush on newer versions of Node.js ([#501](https://github.com/yargs/yargs/issues/501)) ([9f8c6f4](https://github.com/yargs/yargs/commit/9f8c6f4)) + + + + +# [4.7.0](https://github.com/yargs/yargs/compare/v4.6.0...v4.7.0) (2016-05-02) + + +### Bug Fixes + +* **pkgConf:** fix aliases issues in .pkgConf() ([#478](https://github.com/yargs/yargs/issues/478))([b900502](https://github.com/yargs/yargs/commit/b900502)) + + +### Features + +* **completion:** allow to get completions for any string, not just process.argv ([#470](https://github.com/yargs/yargs/issues/470))([74fcfbc](https://github.com/yargs/yargs/commit/74fcfbc)) +* **configuration:** Allow to directly pass a configuration object to .config() ([#480](https://github.com/yargs/yargs/issues/480))([e0a7e05](https://github.com/yargs/yargs/commit/e0a7e05)) +* **validation:** Add .skipValidation() method ([#471](https://github.com/yargs/yargs/issues/471))([d72badb](https://github.com/yargs/yargs/commit/d72badb)) + + + + +# [4.6.0](https://github.com/yargs/yargs/compare/v4.5.0...v4.6.0) (2016-04-11) + + +### Bug Fixes + +* **my brand!:** I agree with [@osher](https://github.com/osher) lightweight isn't a huge selling point of ours any longer, see [#468](https://github.com/yargs/yargs/issues/468) ([c46d7e1](https://github.com/yargs/yargs/commit/c46d7e1)) + +### Features + +* switch to standard-version for release management ([f70f801](https://github.com/yargs/yargs/commit/f70f801)) +* upgrade to version of yargs-parser that introduces some slick new features, great work [@elas7](https://github.com/elas7). update cliui, replace win-spawn, replace badge. ([#475](https://github.com/yargs/yargs/issues/475)) ([f915dd4](https://github.com/yargs/yargs/commit/f915dd4)) + + + + +# [4.5.0](https://github.com/yargs/yargs/compare/v4.4.0...v4.5.0) (2016-04-05) + + +### Bug Fixes + +* **windows:** handle $0 better on Windows platforms ([eb6e03f](https://github.com/yargs/yargs/commit/eb6e03f)) + +### Features + +* **commands:** implemented variadic positional arguments ([51d926e](https://github.com/yargs/yargs/commit/51d926e)) +* **completion:** completion now better handles aliases, and avoids duplicating keys. ([86416c8](https://github.com/yargs/yargs/commit/86416c8)) +* **config:** If invoking .config() without parameters, set a default option ([0413dd1](https://github.com/yargs/yargs/commit/0413dd1)) +* **conventional-changelog:** switching to using conventional-changelog for generating the changelog ([a2b5a2a](https://github.com/yargs/yargs/commit/a2b5a2a)) + + + +### v4.4.0 (2016/04/03 21:10 +07:00) + +- [#454](https://github.com/yargs/yargs/pull/454) fix demand() when second argument is an array (@elas7) +- [#452](https://github.com/yargs/yargs/pull/452) fix code example for `.help()` docs (@maxrimue) +- [#450](https://github.com/yargs/yargs/pull/450) fix for bash completion trailing space edge-case (@elas7) +- [#448](https://github.com/yargs/yargs/pull/448) allow a method to be passed to `showHelp`, rather than a log-level (@osher) +- [#446](https://github.com/yargs/yargs/pull/446) update yargs-parser, y18n, nyc, cliui, pkg-conf (@bcoe) +- [#436](https://github.com/yargs/yargs/pull/436) the rebase method is only used by tests, do not export it in two places (@elas7) +- [#428](https://github.com/yargs/yargs/pull/428) initial support for subcommands (@nexdrew) + +### v4.3.2 (2016/3/20 15:07 +07:00) + +- [#445](https://github.com/yargs/yargs/pull/445) strict mode was failing if no commands were registered (@nexdrew) +- [#443](https://github.com/yargs/yargs/pull/443) adds Italian translation \o/ (@madrisan) +- [#441](https://github.com/yargs/yargs/pull/441) remove duplicate keys from array options configuration (@elas7) +- [#437](https://github.com/yargs/yargs/pull/437) standardize tests for .command() (@lrlna) + +### v4.3.0 (2016/3/12 14:19 +07:00) + +- [#432](https://github.com/yargs/yargs/pull/432) non-singleton version of yargs (@bcoe) +- [#422, #425, #420] translations for number (@zkat, @rilut, @maxrimue, @watilde) +- [#414](https://github.com/yargs/yargs/pull/414) all command options can be defined in module now (@nexdrew) + +### v4.2.0 (2016/2/22 11:02 +07:00) + +- [#395](https://github.com/yargs/yargs/pull/395) do not reset groups if they contain + global keys (@novemberborn) +- [#393](https://github.com/yargs/yargs/pull/393) use sane default for usage strings (@nexdrew) +- [#392](https://github.com/yargs/yargs/pull/392) resetting wrap() was causing layout issues + with commands (@nexdrew) +- [#391](https://github.com/yargs/yargs/pull/391) commands were being added multiple times (@nexdrew) + +### v4.0.0 (2016/2/14 1:27 +07:00) + +- [#384](https://github.com/bcoe/yargs/pull/384) add new number type to yargs (@lrlna, @maxrimue) +- [#382](https://github.com/bcoe/yargs/pull/382) pass error as extra parameter to fail (@gajus) +- [#378](https://github.com/bcoe/yargs/pull/378) introduces the pkgConf feature, which tells + yargs to load default argument values from a key on a project's package.json (@bcoe) +- [#376](https://github.com/bcoe/yargs/pull/376) **breaking change**, make help() method signature + more consistent with other commands (@maxrimue) +- [#368](https://github.com/bcoe/yargs/pull/368) **breaking change**, overhaul to command handling API: + introducing named positional arguments, commands as modules, introduces the concept of global options (options that don't reset). (@nexdrew, @bcoe). +- [#364](https://github.com/bcoe/yargs/pull/364) add the slick new yargs website to the package.json (@iarna). +- [#357](https://github.com/bcoe/yargs/pull/357) .strict() now requires that a valid command is provided (@lrlna) +- [#356](https://github.com/bcoe/yargs/pull/356) pull the parsing bits of yargs into the separate module yargs-parser. Various parsing options can now be turned on and off using configuration (@bcoe). +- [#330](https://github.com/bcoe/yargs/pull/330) **breaking change**, fix inconsistencies with `.version()` API. (@maxrimue). ### v3.32.0 (2016/1/14 10:13 +07:00) @@ -14,7 +899,7 @@ - [#308](https://github.com/bcoe/yargs/pull/308) Yargs now handles environment variables (@nexdrew) - [#302](https://github.com/bcoe/yargs/pull/302) Add Indonesian translation (@rilut) - [#300](https://github.com/bcoe/yargs/pull/300) Add Turkish translation (@feyzo) -- [#298](https://github.com/bcoe/yargs/pull/298) Add Norwegian Bokmål translation (@sindresorhus) +- [#298](https://github.com/bcoe/yargs/pull/298) Add Norwegian Bokmål translation (@sindresorhus) - [#297](https://github.com/bcoe/yargs/pull/297) Fix for layout of cjk characters (@disjukr) - [#296](https://github.com/bcoe/yargs/pull/296) Add Korean translation (@disjukr) diff --git a/node_modules/yargs/LICENSE b/node_modules/yargs/LICENSE index 432d1ae..747ab11 100644 --- a/node_modules/yargs/LICENSE +++ b/node_modules/yargs/LICENSE @@ -1,4 +1,5 @@ Copyright 2010 James Halliday (mail@substack.net) +Modified work Copyright 2014 Contributors (ben@npmjs.com) This project is free software released under the MIT/X11 license: diff --git a/node_modules/yargs/README.md b/node_modules/yargs/README.md index 3649538..679a3ee 100644 --- a/node_modules/yargs/README.md +++ b/node_modules/yargs/README.md @@ -1,1243 +1,136 @@ -yargs -======== +

+ +

+

Yargs

+

+ Yargs be a node.js library fer hearties tryin' ter parse optstrings +

-Yargs be a node.js library fer hearties tryin' ter parse optstrings. - -With yargs, ye be havin' a map that leads straight to yer treasure! Treasure of course, being a simple option hash. +
[![Build Status][travis-image]][travis-url] -[![Dependency Status][gemnasium-image]][gemnasium-url] [![Coverage Status][coveralls-image]][coveralls-url] [![NPM version][npm-image]][npm-url] -[![Windows Tests][windows-image]][windows-url] +[![js-standard-style][standard-image]][standard-url] +[![Conventional Commits][conventional-commits-image]][conventional-commits-url] +[![Slack][slack-image]][slack-url] -> Yargs is the official successor to optimist. Please feel free to submit issues and pull requests. If you'd like to contribute and don't know where to start, have a look at [the issue list](https://github.com/bcoe/yargs/issues) :) +## Description : +Yargs helps you build interactive command line tools, by parsing arguments and generating an elegant user interface. -examples -======== +It gives you: -With yargs, the options be just a hash! -------------------------------------------------------------------- +* commands and (grouped) options (`my-program.js serve --port=5000`). +* a dynamically generated help menu based on your arguments. -plunder.js: +> + +* bash-completion shortcuts for commands and options. +* and [tons more](/docs/api.md). + +## Installation + +Stable version: +```bash +npm i yargs +``` + +Bleeding edge version with the most recent features: +```bash +npm i yargs@next +``` + +## Usage : + +### Simple Example ````javascript #!/usr/bin/env node -var argv = require('yargs').argv; +const argv = require('yargs').argv if (argv.ships > 3 && argv.distance < 53.5) { - console.log('Plunder more riffiwobbles!'); -} -else { - console.log('Retreat from the xupptumblers!'); -} -```` - -*** - - $ ./plunder.js --ships=4 --distance=22 - Plunder more riffiwobbles! - - $ ./plunder.js --ships 12 --distance 98.7 - Retreat from the xupptumblers! - -![Joe was one optimistic pirate.](http://i.imgur.com/4WFGVJ9.png) - -But don't walk the plank just yet! There be more! You can do short options: -------------------------------------------------- - -short.js: - -````javascript -#!/usr/bin/env node -var argv = require('yargs').argv; -console.log('(%d,%d)', argv.x, argv.y); -```` - -*** - - $ ./short.js -x 10 -y 21 - (10,21) - -And booleans, both long, short, and even grouped: ----------------------------------- - -bool.js: - -````javascript -#!/usr/bin/env node -var argv = require('yargs').argv; - -if (argv.s) { - process.stdout.write(argv.fr ? 'Le perroquet dit: ' : 'The parrot says: '); -} -console.log( - (argv.fr ? 'couac' : 'squawk') + (argv.p ? '!' : '') -); -```` - -*** - - $ ./bool.js -s - The parrot says: squawk - - $ ./bool.js -sp - The parrot says: squawk! - - $ ./bool.js -sp --fr - Le perroquet dit: couac! - -And non-hyphenated options too! Just use `argv._`! -------------------------------------------------- - -nonopt.js: - -````javascript -#!/usr/bin/env node -var argv = require('yargs').argv; -console.log('(%d,%d)', argv.x, argv.y); -console.log(argv._); -```` - -*** - - $ ./nonopt.js -x 6.82 -y 3.35 rum - (6.82,3.35) - [ 'rum' ] - - $ ./nonopt.js "me hearties" -x 0.54 yo -y 1.12 ho - (0.54,1.12) - [ 'me hearties', 'yo', 'ho' ] - -Yargs even counts your booleans! ----------------------------------------------------------------------- - -count.js: - -````javascript -#!/usr/bin/env node -var argv = require('yargs') - .count('verbose') - .alias('v', 'verbose') - .argv; - -VERBOSE_LEVEL = argv.verbose; - -function WARN() { VERBOSE_LEVEL >= 0 && console.log.apply(console, arguments); } -function INFO() { VERBOSE_LEVEL >= 1 && console.log.apply(console, arguments); } -function DEBUG() { VERBOSE_LEVEL >= 2 && console.log.apply(console, arguments); } - -WARN("Showing only important stuff"); -INFO("Showing semi-important stuff too"); -DEBUG("Extra chatty mode"); -```` - -*** - $ node count.js - Showing only important stuff - - $ node count.js -v - Showing only important stuff - Showing semi-important stuff too - - $ node count.js -vv - Showing only important stuff - Showing semi-important stuff too - Extra chatty mode - - $ node count.js -v --verbose - Showing only important stuff - Showing semi-important stuff too - Extra chatty mode - -Tell users how to use yer options and make demands. -------------------------------------------------- - -area.js: - -````javascript -#!/usr/bin/env node -var argv = require('yargs') - .usage('Usage: $0 -w [num] -h [num]') - .demand(['w','h']) - .argv; - -console.log("The area is:", argv.w * argv.h); -```` - -*** - - $ ./area.js -w 55 -h 11 - The area is: 605 - - $ node ./area.js -w 4.91 -w 2.51 - Usage: area.js -w [num] -h [num] - - Options: - -w [required] - -h [required] - - Missing required arguments: h - -After yer demands have been met, demand more! Ask for non-hyphenated arguments! ------------------------------------------ - -demand_count.js: - -````javascript -#!/usr/bin/env node -var argv = require('yargs') - .demand(2) - .argv; -console.dir(argv); -```` - -*** - - $ ./demand_count.js a - - Not enough non-option arguments: got 1, need at least 2 - - $ ./demand_count.js a b - { _: [ 'a', 'b' ], '$0': 'demand_count.js' } - - $ ./demand_count.js a b c - { _: [ 'a', 'b', 'c' ], '$0': 'demand_count.js' } - -EVEN MORE SHIVER ME TIMBERS! ------------------- - -default_singles.js: - -````javascript -#!/usr/bin/env node -var argv = require('yargs') - .default('x', 10) - .default('y', 10) - .argv -; -console.log(argv.x + argv.y); -```` - -*** - - $ ./default_singles.js -x 5 - 15 - -default_hash.js: - -````javascript -#!/usr/bin/env node -var argv = require('yargs') - .default({ x : 10, y : 10 }) - .argv -; -console.log(argv.x + argv.y); -```` - -*** - - $ ./default_hash.js -y 7 - 17 - -And if you really want to get all descriptive about it... ---------------------------------------------------------- - -boolean_single.js: - -````javascript -#!/usr/bin/env node -var argv = require('yargs') - .boolean('v') - .argv -; -console.dir(argv.v); -console.dir(argv._); -```` - -*** - - $ ./boolean_single.js -v "me hearties" yo ho - true - [ 'me hearties', 'yo', 'ho' ] - - -boolean_double.js: - -````javascript -#!/usr/bin/env node -var argv = require('yargs') - .boolean(['x','y','z']) - .argv -; -console.dir([ argv.x, argv.y, argv.z ]); -console.dir(argv._); -```` - -*** - - $ ./boolean_double.js -x -z one two three - [ true, false, true ] - [ 'one', 'two', 'three' ] - -Yargs is here to help you... ---------------------------- - -Ye can describe parameters fer help messages and set aliases. Yargs figures -out how ter format a handy help string automatically. - -line_count.js: - -````javascript -#!/usr/bin/env node -var argv = require('yargs') - .usage('Usage: $0 [options]') - .command('count', 'Count the lines in a file') - .demand(1) - .example('$0 count -f foo.js', 'count the lines in the given file') - .demand('f') - .alias('f', 'file') - .nargs('f', 1) - .describe('f', 'Load a file') - .help('h') - .alias('h', 'help') - .epilog('copyright 2015') - .argv; - -var fs = require('fs'); -var s = fs.createReadStream(argv.file); - -var lines = 0; -s.on('data', function (buf) { - lines += buf.toString().match(/\n/g).length; -}); - -s.on('end', function () { - console.log(lines); -}); -```` - -*** - $ node line_count.js count - Usage: line_count.js [options] - - Commands: - count Count the lines in a file - - Options: - -f, --file Load a file [required] - -h, --help Show help [boolean] - - Examples: - line_count.js count -f foo.js count the lines in the given file - - copyright 2015 - - Missing required arguments: f - - $ node line_count.js count --file line_count.js - 26 - - $ node line_count.js count -f line_count.js - 26 - -methods -======= - -By itself, - -````javascript -require('yargs').argv -```` - -will use the `process.argv` array to construct the `argv` object. - -You can pass in the `process.argv` yourself: - -````javascript -require('yargs')([ '-x', '1', '-y', '2' ]).argv -```` - -or use `.parse()` to do the same thing: - -````javascript -require('yargs').parse([ '-x', '1', '-y', '2' ]) -```` - -The rest of these methods below come in just before the terminating `.argv`. - -.alias(key, alias) ------------------- - -Set key names as equivalent such that updates to a key will propagate to aliases -and vice-versa. - -Optionally `.alias()` can take an object that maps keys to aliases. -Each key of this object should be the canonical version of the option, and each -value should be a string or an array of strings. - -.argv ------ - -Get the arguments as a plain old object. - -Arguments without a corresponding flag show up in the `argv._` array. - -The script name or node command is available at `argv.$0` similarly to how `$0` -works in bash or perl. - -If `yargs` is executed in an environment that embeds node and there's no script name (e.g. -[Electron](http://electron.atom.io/) or [nw.js](http://nwjs.io/)), it will ignore the first parameter since it -expects it to be the script name. In order to override this behavior, use `.parse(process.argv.slice(1))` -instead of `.argv` and the first parameter won't be ignored. - -.array(key) ----------- - -Tell the parser to interpret `key` as an array. If `.array('foo')` is set, -`--foo foo bar` will be parsed as `['foo', 'bar']` rather than as `'foo'`. - -.boolean(key) -------------- - -Interpret `key` as a boolean. If a non-flag option follows `key` in -`process.argv`, that string won't get set as the value of `key`. - -`key` will default to `false`, unless a `default(key, undefined)` is -explicitly set. - -If `key` is an array, interpret all the elements as booleans. - -.check(fn) ----------- - -Check that certain conditions are met in the provided arguments. - -`fn` is called with two arguments, the parsed `argv` hash and an array of options and their aliases. - -If `fn` throws or returns a non-truthy value, show the thrown error, usage information, and -exit. - -.choices(key, choices) ----------------------- - -Limit valid values for `key` to a predefined set of `choices`, given as an array -or as an individual value. - -```js -var argv = require('yargs') - .alias('i', 'ingredient') - .describe('i', 'choose your sandwich ingredients') - .choices('i', ['peanut-butter', 'jelly', 'banana', 'pickles']) - .help('help') - .argv -``` - -If this method is called multiple times, all enumerated values will be merged -together. Choices are generally strings or numbers, and value matching is -case-sensitive. - -Optionally `.choices()` can take an object that maps multiple keys to their -choices. - -Choices can also be specified as `choices` in the object given to `option()`. - -```js -var argv = require('yargs') - .option('size', { - alias: 's', - describe: 'choose a size', - choices: ['xs', 's', 'm', 'l', 'xl'] - }) - .argv -``` - -.command(cmd, desc, [fn]) -------------------- - -Document the commands exposed by your application. - -Use `desc` to provide a description for each command your application accepts (the -values stored in `argv._`). Set `desc` to `false` to create a hidden command. -Hidden commands don't show up in the help output and aren't available for -completion. - -Optionally, you can provide a handler `fn` which will be executed when -a given command is provided. The handler will be called with `yargs` and -`argv` as arguments. - -`yargs` is a blank instance of yargs, which can be used to compose a nested -hierarchy of options handlers. - -`argv` represents the arguments parsed prior to the -command being executed (those described in the outer yargs instance). - -Here's an example of top-level and nested commands in action: - -```js -var argv = require('yargs') - .usage('npm ') - .command('install', 'tis a mighty fine package to install') - .command('publish', 'shiver me timbers, should you be sharing all that', function (yargs, argv) { - argv = yargs.option('f', { - alias: 'force', - description: 'yar, it usually be a bad idea' - }) - .help('help') - .argv - }) - .help('help') - .argv; -``` - -.completion(cmd, [description], [fn]); -------------- - -Enable bash-completion shortcuts for commands and options. - -`cmd`: When present in `argv._`, will result in the `.bashrc` completion script -being outputted. To enable bash completions, concat the generated script to your -`.bashrc` or `.bash_profile`. - -`description`: Provide a description in your usage instructions for the command -that generates bash completion scripts. - -`fn`: Rather than relying on yargs' default completion functionality, which -shiver me timbers is pretty awesome, you can provide your own completion -method. - -```js -var argv = require('yargs') - .completion('completion', function(current, argv) { - // 'current' is the current command being completed. - // 'argv' is the parsed arguments so far. - // simply return an array of completions. - return [ - 'foo', - 'bar' - ]; - }) - .argv; -``` - -You can also provide asynchronous completions. - -```js -var argv = require('yargs') - .completion('completion', function(current, argv, done) { - setTimeout(function() { - done([ - 'apple', - 'banana' - ]); - }, 500); - }) - .argv; -``` - -But wait, there's more! You can return an asynchronous promise. - -```js -var argv = require('yargs') - .completion('completion', function(current, argv, done) { - return new Promise(function (resolve, reject) { - setTimeout(function () { - resolve(['apple', 'banana']) - }, 10) - }) - }) - .argv; -``` - -.config(key, [description], [parseFn]) ------------- - -Tells the parser that if the option specified by `key` is passed in, it -should be interpreted as a path to a JSON config file. The file is loaded -and parsed, and its properties are set as arguments. - -An optional `description` can be provided to customize the config (`key`) option -in the usage string. - -An optional `parseFn` can be used to provide a custom parser. The parsing -function must be synchronous, and should return an object containing -key value pairs or an error. - -```js -var argv = require('yargs') - .config('settings', function (configPath) { - return JSON.parse(fs.readFileSync(configPath, 'utf-8')) - }) - .argv -``` - -.count(key) ------------- - -Interpret `key` as a boolean flag, but set its parsed value to the number of -flag occurrences rather than `true` or `false`. Default value is thus `0`. - -.default(key, value, [description]) --------------------- - -Set `argv[key]` to `value` if no option was specified in `process.argv`. - -Optionally `.default()` can take an object that maps keys to default values. - -But wait, there's more! The default value can be a `function` which returns -a value. The name of the function will be used in the usage string: - -```js -var argv = require('yargs') - .default('random', function randomValue() { - return Math.random() * 256; - }).argv; -``` - -Optionally, `description` can also be provided and will take precedence over -displaying the value in the usage instructions: - -```js -.default('timeout', 60000, '(one-minute)') -``` - -.demand(key, [msg | boolean]) ------------------------------- -.demand(count, [max], [msg]) ------------------------------- - -If `key` is a string, show the usage information and exit if `key` wasn't -specified in `process.argv`. - -If `key` is a number, demand at least as many non-option arguments, which show -up in `argv._`. A second number can also optionally be provided, which indicates -the maximum number of non-option arguments. - -If `key` is an array, demand each element. - -If a `msg` string is given, it will be printed when the argument is missing, -instead of the standard error message. This is especially helpful for the non-option arguments in `argv._`. - -If a `boolean` value is given, it controls whether the option is demanded; -this is useful when using `.options()` to specify command line parameters. - -.describe(key, desc) --------------------- - -Describe a `key` for the generated usage information. - -Optionally `.describe()` can take an object that maps keys to descriptions. - -.detectLocale(boolean) ------------ - -Should yargs attempt to detect the os' locale? Defaults to `true`. - -.env([prefix]) --------------- - -Tell yargs to parse environment variables matching the given prefix and apply -them to argv as though they were command line arguments. - -If this method is called with no argument or with an empty string or with `true`, -then all env vars will be applied to argv. - -Program arguments are defined in this order of precedence: - -1. Command line args -2. Config file -3. Env var -4. Configured defaults - -```js -var argv = require('yargs') - .env('MY_PROGRAM') - .option('f', { - alias: 'fruit-thing', - default: 'apple' - }) - .argv -console.log(argv) -``` - -``` -$ node fruity.js -{ _: [], - f: 'apple', - 'fruit-thing': 'apple', - fruitThing: 'apple', - '$0': 'fruity.js' } -``` - -``` -$ MY_PROGRAM_FRUIT_THING=banana node fruity.js -{ _: [], - fruitThing: 'banana', - f: 'banana', - 'fruit-thing': 'banana', - '$0': 'fruity.js' } -``` - -``` -$ MY_PROGRAM_FRUIT_THING=banana node fruity.js -f cat -{ _: [], - f: 'cat', - 'fruit-thing': 'cat', - fruitThing: 'cat', - '$0': 'fruity.js' } -``` - -Env var parsing is disabled by default, but you can also explicitly disable it -by calling `.env(false)`, e.g. if you need to undo previous configuration. - -.epilog(str) ------------- -.epilogue(str) --------------- - -A message to print at the end of the usage instructions, e.g. - -```js -var argv = require('yargs') - .epilogue('for more information, find our manual at http://example.com'); -``` - -.example(cmd, desc) -------------------- - -Give some example invocations of your program. Inside `cmd`, the string -`$0` will get interpolated to the current script name or node command for the -present script similar to how `$0` works in bash or perl. -Examples will be printed out as part of the help message. - -.exitProcess(enable) ----------------------------------- - -By default, yargs exits the process when the user passes a help flag, uses the -`.version` functionality, or when validation fails. Calling -`.exitProcess(false)` disables this behavior, enabling further actions after -yargs have been validated. - -.fail(fn) ---------- - -Method to execute when a failure occurs, rather than printing the failure message. - -`fn` is called with the failure message that would have been printed. - -.group(key(s), groupName) --------------------- - -Given a key, or an array of keys, places options under an alternative heading -when displaying usage instructions, e.g., - -```js -var yargs = require('yargs')(['--help']) - .help('help') - .group('batman', 'Heroes:') - .describe('batman', "world's greatest detective") - .wrap(null) - .argv -``` -*** - Heroes: - --batman world's greatest detective - - Options: - --help Show help [boolean] - -.help([option, [description]]) ------------------------------- - -Add an option (e.g. `--help`) that displays the usage string and exits the -process. If present, the `description` parameter customizes the description of -the help option in the usage string. - -If invoked without parameters, `.help()` returns the generated usage string. - -Example: - -```js -var yargs = require("yargs") - .usage("$0 -operand1 number -operand2 number -operation [add|subtract]"); -console.log(yargs.help()); -``` - -Later on, `argv` can be retrieved with `yargs.argv`. - -.implies(x, y) --------------- - -Given the key `x` is set, it is required that the key `y` is set. - -Optionally `.implies()` can accept an object specifying multiple implications. - -.locale() ---------- - -Return the locale that yargs is currently using. - -By default, yargs will auto-detect the operating system's locale so that -yargs-generated help content will display in the user's language. - -To override this behavior with a static locale, pass the desired locale as a -string to this method (see below). - -.locale(locale) ---------------- - -Override the auto-detected locale from the user's operating system with a static -locale. Note that the OS locale can be modified by setting/exporting the `LC_ALL` -environment variable. - -```js -var argv = require('yargs') - .usage('./$0 - follow ye instructions true') - .option('option', { - alias: 'o', - describe: "'tis a mighty fine option", - demand: true - }) - .command('run', "Arrr, ya best be knowin' what yer doin'") - .example('$0 run foo', "shiver me timbers, here's an example for ye") - .help('help') - .wrap(70) - .locale('pirate') - .argv -``` - -*** - -```shell -./test.js - follow ye instructions true - -Choose yer command: - run Arrr, ya best be knowin' what yer doin' - -Options for me hearties! - --option, -o 'tis a mighty fine option [requi-yar-ed] - --help Parlay this here code of conduct [boolean] - -Ex. marks the spot: - test.js run foo shiver me timbers, here's an example for ye - -Ye be havin' to set the followin' argument land lubber: option -``` - -Locales currently supported: - -* **de:** German. -* **en:** American English. -* **es:** Spanish. -* **fr:** French. -* **id:** Indonesian. -* **ja:** Japanese. -* **ko:** Korean. -* **nb:** Norwegian Bokmål. -* **pirate:** American Pirate. -* **pt:** Portuguese. -* **pt_BR:** Brazilian Portuguese. -* **tr:** Turkish. -* **zh:** Chinese. - -To submit a new translation for yargs: - -1. use `./locales/en.json` as a starting point. -2. submit a pull request with the new locale file. - -*The [Microsoft Terminology Search](http://www.microsoft.com/Language/en-US/Search.aspx) can be useful for finding the correct terminology in your locale.* - -.nargs(key, count) ------------ - -The number of arguments that should be consumed after a key. This can be a -useful hint to prevent parsing ambiguity. For example: - -```js -var argv = require('yargs') - .nargs('token', 1) - .parse(['--token', '-my-token']); -``` - -parses as: - -`{ _: [], token: '-my-token', '$0': 'node test' }` - -Optionally `.nargs()` can take an object of `key`/`narg` pairs. - -.option(key, opt) ------------------ -.options(key, opt) ------------------- - -Instead of chaining together `.alias().demand().default().describe().string()`, you can specify -keys in `opt` for each of the chainable methods. - -For example: - -````javascript -var argv = require('yargs') - .option('f', { - alias: 'file', - demand: true, - default: '/etc/passwd', - describe: 'x marks the spot', - type: 'string' - }) - .argv -; -```` - -is the same as - -````javascript -var argv = require('yargs') - .alias('f', 'file') - .demand('f') - .default('f', '/etc/passwd') - .describe('f', 'x marks the spot') - .string('f') - .argv -; -```` - -Optionally `.options()` can take an object that maps keys to `opt` parameters. - -````javascript -var argv = require('yargs') - .options({ - 'f': { - alias: 'file', - demand: true, - default: '/etc/passwd', - describe: 'x marks the spot', - type: 'string' - } - }) - .argv -; -```` - -Valid `opt` keys include: - -- `alias`: string or array of strings, alias(es) for the canonical option key, see [`alias()`](#alias) -- `array`: boolean, interpret option as an array, see [`array()`](#array) -- `boolean`: boolean, interpret option as a boolean flag, see [`boolean()`](#boolean) -- `choices`: value or array of values, limit valid option arguments to a predefined set, see [`choices()`](#choices) -- `config`: boolean, interpret option as a path to a JSON config file, see [`config()`](#config) -- `configParser`: function, provide a custom config parsing function, see [`config()`](#config) -- `count`: boolean, interpret option as a count of boolean flags, see [`count()`](#count) -- `default`: value, set a default value for the option, see [`default()`](#default) -- `defaultDescription`: string, use this description for the default value in help content, see [`default()`](#default) -- `demand`/`require`/`required`: boolean or string, demand the option be given, with optional error message, see [`demand()`](#demand) -- `desc`/`describe`/`description`: string, the option description for help content, see [`describe()`](#describe) -- `group`: string, when displaying usage instructions place the option under an alternative group heading, see [`group()`](#group) -- `nargs`: number, specify how many arguments should be consumed for the option, see [`nargs()`](#nargs) -- `requiresArg`: boolean, require the option be specified with a value, see [`requiresArg()`](#requiresArg) -- `string`: boolean, interpret option as a string, see [`string()`](#string) -- `type`: one of the following strings - - `'array'`: synonymous for `array: true`, see [`array()`](#array) - - `'boolean'`: synonymous for `boolean: true`, see [`boolean()`](#boolean) - - `'count'`: synonymous for `count: true`, see [`count()`](#count) - - `'string'`: synonymous for `string: true`, see [`string()`](#string) - -.parse(args) ------------- - -Parse `args` instead of `process.argv`. Returns the `argv` object. - -`args` may either be a pre-processed argv array, or a raw argument string. - -.require(key, [msg | boolean]) ------------------------------- -.required(key, [msg | boolean]) ------------------------------- - -An alias for [`demand()`](#demand). See docs there. - -.requiresArg(key) ------------------ - -Specifies either a single option key (string), or an array of options that -must be followed by option values. If any option value is missing, show the -usage information and exit. - -The default behavior is to set the value of any key not followed by an -option value to `true`. - -.reset() --------- - -Reset the argument object built up so far. This is useful for -creating nested command line interfaces. - -```js -var yargs = require('yargs') - .usage('$0 command') - .command('hello', 'hello command') - .command('world', 'world command') - .demand(1, 'must provide a valid command'), - argv = yargs.argv, - command = argv._[0]; - -if (command === 'hello') { - yargs.reset() - .usage('$0 hello') - .help('h') - .example('$0 hello', 'print the hello message!') - .argv - - console.log('hello!'); -} else if (command === 'world'){ - yargs.reset() - .usage('$0 world') - .help('h') - .example('$0 world', 'print the world message!') - .argv - - console.log('world!'); + console.log('Plunder more riffiwobbles!') } else { - yargs.showHelp(); + console.log('Retreat from the xupptumblers!') } -``` - -.showCompletionScript() ----------------------- - -Generate a bash completion script. Users of your application can install this -script in their `.bashrc`, and yargs will provide completion shortcuts for -commands and options. - -.showHelp(consoleLevel='error') ---------------------------- - -Print the usage data using the [`console`](https://nodejs.org/api/console.html) function `consoleLevel` for printing. - -Example: - -```js -var yargs = require("yargs") - .usage("$0 -operand1 number -operand2 number -operation [add|subtract]"); -yargs.showHelp(); //prints to stderr using console.error() -``` - -Or, to print the usage data to `stdout` instead, you can specify the use of `console.log`: - -```js -yargs.showHelp("log"); //prints to stdout using console.log() -``` - -Later on, `argv` can be retrieved with `yargs.argv`. - -.showHelpOnFail(enable, [message]) ----------------------------------- - -By default, yargs outputs a usage string if any error is detected. Use the -`.showHelpOnFail()` method to customize this behavior. If `enable` is `false`, -the usage string is not output. If the `message` parameter is present, this -message is output after the error message. - -line_count.js: - -````javascript -#!/usr/bin/env node -var argv = require('yargs') - .usage('Count the lines in a file.\nUsage: $0 -f ') - .demand('f') - .alias('f', 'file') - .describe('f', 'Load a file') - .string('f') - .showHelpOnFail(false, 'Specify --help for available options') - .help('help') - .argv; - -// etc. ```` -*** +```bash +$ ./plunder.js --ships=4 --distance=22 +Plunder more riffiwobbles! -``` -$ node line_count.js -Missing argument value: f - -Specify --help for available options +$ ./plunder.js --ships 12 --distance 98.7 +Retreat from the xupptumblers! ``` -.strict() ---------- +### Complex Example -Any command-line argument given that is not demanded, or does not have a -corresponding description, will be reported as an error. - -.string(key) ------------- - -Tell the parser logic not to interpret `key` as a number or boolean. -This can be useful if you need to preserve leading zeros in an input. - -If `key` is an array, interpret all the elements as strings. - -`.string('_')` will result in non-hyphenated arguments being interpreted as strings, -regardless of whether they resemble numbers. - -.updateLocale(obj) ------------------- -.updateStrings(obj) ------------------- - -Override the default strings used by yargs with the key/value -pairs provided in `obj`: - -```js -var argv = require('yargs') - .command('run', 'the run command') - .help('help') - .updateStrings({ - 'Commands:': 'My Commands -->\n' +```javascript +#!/usr/bin/env node +require('yargs') // eslint-disable-line + .command('serve [port]', 'start the server', (yargs) => { + yargs + .positional('port', { + describe: 'port to bind on', + default: 5000 + }) + }, (argv) => { + if (argv.verbose) console.info(`start server on :${argv.port}`) + serve(argv.port) + }) + .option('verbose', { + alias: 'v', + type: 'boolean', + description: 'Run with verbose logging' }) - .wrap(null) .argv ``` -*** +Run the example above with `--help` to see the help for the application. -```shell -My Commands --> +## TypeScript - run the run command +yargs has type definitions at [@types/yargs][type-definitions]. -Options: - --help Show help [boolean] +``` +npm i @types/yargs --save-dev ``` -If you explicitly specify a `locale()`, you should do so *before* calling -`updateStrings()`. +See usage examples in [docs](/docs/typescript.md). -.usage(message, [opts]) ---------------------- +## Community : -Set a usage message to show which commands to use. Inside `message`, the string -`$0` will get interpolated to the current script name or node command for the -present script similar to how `$0` works in bash or perl. +Having problems? want to contribute? join our [community slack](http://devtoolscommunity.herokuapp.com). -`opts` is optional and acts like calling `.options(opts)`. +## Documentation : -.version(version, [option], [description]) ----------------------------------------- +### Table of Contents -Add an option (e.g. `--version`) that displays the version number (given by the -`version` parameter) and exits the process. If present, the `description` -parameter customizes the description of the version option in the usage string. +* [Yargs' API](/docs/api.md) +* [Examples](/docs/examples.md) +* [Parsing Tricks](/docs/tricks.md) + * [Stop the Parser](/docs/tricks.md#stop) + * [Negating Boolean Arguments](/docs/tricks.md#negate) + * [Numbers](/docs/tricks.md#numbers) + * [Arrays](/docs/tricks.md#arrays) + * [Objects](/docs/tricks.md#objects) + * [Quotes](/docs/tricks.md#quotes) +* [Advanced Topics](/docs/advanced.md) + * [Composing Your App Using Commands](/docs/advanced.md#commands) + * [Building Configurable CLI Apps](/docs/advanced.md#configuration) + * [Customizing Yargs' Parser](/docs/advanced.md#customizing) +* [Contributing](/contributing.md) -You can provide a `function` for version, rather than a string. -This is useful if you want to use the version from your package.json: - -```js -var argv = require('yargs') - .version(function() { - return require('../package').version; - }) - .argv; -``` - -.wrap(columns) --------------- - -Format usage output to wrap at `columns` many columns. - -By default wrap will be set to `Math.min(80, windowWidth)`. Use `.wrap(null)` to -specify no column limit (no right-align). Use `.wrap(yargs.terminalWidth())` to -maximize the width of yargs' usage instructions. - -parsing tricks -============== - -stop parsing ------------- - -Use `--` to stop parsing flags and stuff the remainder into `argv._`. - - $ node examples/reflect.js -a 1 -b 2 -- -c 3 -d 4 - { _: [ '-c', '3', '-d', '4' ], - a: 1, - b: 2, - '$0': 'examples/reflect.js' } - -negate fields -------------- - -If you want to explicitly set a field to false instead of just leaving it -undefined or to override a default you can do `--no-key`. - - $ node examples/reflect.js -a --no-b - { _: [], a: true, b: false, '$0': 'examples/reflect.js' } - -numbers -------- - -Every argument that looks like a number (`!isNaN(Number(arg))`) is converted to -one. This way you can just `net.createConnection(argv.port)` and you can add -numbers out of `argv` with `+` without having that mean concatenation, -which is super frustrating. - -duplicates ----------- - -If you specify a flag multiple times it will get turned into an array containing -all the values in order. - - $ node examples/reflect.js -x 5 -x 8 -x 0 - { _: [], x: [ 5, 8, 0 ], '$0': 'examples/reflect.js' } - -dot notation ------------- - -When you use dots (`.`s) in argument names, an implicit object path is assumed. -This lets you organize arguments into nested objects. - - $ node examples/reflect.js --foo.bar.baz=33 --foo.quux=5 - { _: [], - foo: { bar: { baz: 33 }, quux: 5 }, - '$0': 'examples/reflect.js' } - -short numbers -------------- - -Short numeric `-n5` style arguments work too: - - $ node examples/reflect.js -n123 -m456 - { _: [], n: 123, m: 456, '$0': 'examples/reflect.js' } - -installation -============ - -With [npm](https://github.com/npm/npm), just do: - - npm install yargs - -or clone this project on github: - - git clone http://github.com/bcoe/yargs.git - -To run the tests with npm, just do: - - npm test - -inspired by -=========== - -This module is loosely inspired by Perl's -[Getopt::Casual](http://search.cpan.org/~photo/Getopt-Casual-0.13.1/Casual.pm). - - - -[travis-url]: https://travis-ci.org/bcoe/yargs -[travis-image]: https://img.shields.io/travis/bcoe/yargs.svg -[gemnasium-url]: https://gemnasium.com/bcoe/yargs -[gemnasium-image]: https://img.shields.io/gemnasium/bcoe/yargs.svg -[coveralls-url]: https://coveralls.io/github/bcoe/yargs -[coveralls-image]: https://img.shields.io/coveralls/bcoe/yargs.svg +[travis-url]: https://travis-ci.org/yargs/yargs +[travis-image]: https://img.shields.io/travis/yargs/yargs/master.svg +[coveralls-url]: https://coveralls.io/github/yargs/yargs +[coveralls-image]: https://img.shields.io/coveralls/yargs/yargs.svg [npm-url]: https://www.npmjs.com/package/yargs [npm-image]: https://img.shields.io/npm/v/yargs.svg -[windows-url]: https://ci.appveyor.com/project/bcoe/yargs -[windows-image]: https://img.shields.io/appveyor/ci/bcoe/yargs/master.svg?label=Windows%20Tests +[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg +[standard-url]: http://standardjs.com/ +[conventional-commits-image]: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg +[conventional-commits-url]: https://conventionalcommits.org/ +[slack-image]: http://devtoolscommunity.herokuapp.com/badge.svg +[slack-url]: http://devtoolscommunity.herokuapp.com +[type-definitions]: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs diff --git a/node_modules/yargs/completion.sh.hbs b/node_modules/yargs/completion.sh.hbs deleted file mode 100644 index 8392ad5..0000000 --- a/node_modules/yargs/completion.sh.hbs +++ /dev/null @@ -1,28 +0,0 @@ -###-begin-{{app_name}}-completions-### -# -# yargs command completion script -# -# Installation: {{app_path}} completion >> ~/.bashrc -# or {{app_path}} completion >> ~/.bash_profile on OSX. -# -_yargs_completions() -{ - local cur_word args type_list - - cur_word="${COMP_WORDS[COMP_CWORD]}" - args=$(printf "%s " "${COMP_WORDS[@]}") - - # ask yargs to generate completions. - type_list=`{{app_path}} --get-yargs-completions $args` - - COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) ) - - # if no match was found, fall back to filename completion - if [ ${#COMPREPLY[@]} -eq 0 ]; then - COMPREPLY=( $(compgen -f -- "${cur_word}" ) ) - fi - - return 0 -} -complete -F _yargs_completions {{app_name}} -###-end-{{app_name}}-completions-### diff --git a/node_modules/yargs/index.js b/node_modules/yargs/index.js index 7b6a343..2db543e 100644 --- a/node_modules/yargs/index.js +++ b/node_modules/yargs/index.js @@ -1,650 +1,17 @@ -var assert = require('assert') -var Completion = require('./lib/completion') -var Parser = require('./lib/parser') -var path = require('path') -var tokenizeArgString = require('./lib/tokenize-arg-string') -var Usage = require('./lib/usage') -var Validation = require('./lib/validation') -var Y18n = require('y18n') +'use strict' +// classic singleton yargs API, to use yargs +// without running as a singleton do: +// require('yargs/yargs')(process.argv.slice(2)) +const yargs = require('./yargs') Argv(process.argv.slice(2)) -var exports = module.exports = Argv +module.exports = Argv + function Argv (processArgs, cwd) { - processArgs = processArgs || [] // handle calling yargs(). - - var self = {} - var completion = null - var usage = null - var validation = null - var y18n = Y18n({ - directory: path.resolve(__dirname, './locales'), - updateFiles: false - }) - - if (!cwd) cwd = process.cwd() - - self.$0 = process.argv - .slice(0, 2) - .map(function (x, i) { - // ignore the node bin, specify this in your - // bin file with #!/usr/bin/env node - if (i === 0 && /\b(node|iojs)$/.test(x)) return - var b = rebase(cwd, x) - return x.match(/^\//) && b.length < x.length ? b : x - }) - .join(' ').trim() - - if (process.env._ !== undefined && process.argv[1] === process.env._) { - self.$0 = process.env._.replace( - path.dirname(process.execPath) + '/', '' - ) - } - - var options - self.resetOptions = self.reset = function () { - // put yargs back into its initial - // state, this is useful for creating a - // nested CLI. - options = { - array: [], - boolean: [], - string: [], - narg: {}, - key: {}, - alias: {}, - default: {}, - defaultDescription: {}, - choices: {}, - requiresArg: [], - count: [], - normalize: [], - config: {}, - envPrefix: undefined - } - - usage = Usage(self, y18n) // handle usage output. - validation = Validation(self, usage, y18n) // handle arg validation. - completion = Completion(self, usage) - - demanded = {} - groups = {} - - exitProcess = true - strict = false - helpOpt = null - versionOpt = null - commandHandlers = {} - self.parsed = false - - return self - } - self.resetOptions() - - self.boolean = function (bools) { - options.boolean.push.apply(options.boolean, [].concat(bools)) - return self - } - - self.array = function (arrays) { - options.array.push.apply(options.array, [].concat(arrays)) - return self - } - - self.nargs = function (key, n) { - if (typeof key === 'object') { - Object.keys(key).forEach(function (k) { - self.nargs(k, key[k]) - }) - } else { - options.narg[key] = n - } - return self - } - - self.choices = function (key, values) { - if (typeof key === 'object') { - Object.keys(key).forEach(function (k) { - self.choices(k, key[k]) - }) - } else { - options.choices[key] = (options.choices[key] || []).concat(values) - } - return self - } - - self.normalize = function (strings) { - options.normalize.push.apply(options.normalize, [].concat(strings)) - return self - } - - self.config = function (key, msg, parseFn) { - if (typeof msg === 'function') { - parseFn = msg - msg = null - } - self.describe(key, msg || usage.deferY18nLookup('Path to JSON config file')) - ;(Array.isArray(key) ? key : [key]).forEach(function (k) { - options.config[k] = parseFn || true - }) - return self - } - - self.example = function (cmd, description) { - usage.example(cmd, description) - return self - } - - self.command = function (cmd, description, fn) { - if (description !== false) { - usage.command(cmd, description) - } - if (fn) commandHandlers[cmd] = fn - return self - } - - var commandHandlers = {} - self.getCommandHandlers = function () { - return commandHandlers - } - - self.string = function (strings) { - options.string.push.apply(options.string, [].concat(strings)) - return self - } - - self.default = function (key, value, defaultDescription) { - if (typeof key === 'object') { - Object.keys(key).forEach(function (k) { - self.default(k, key[k]) - }) - } else { - if (defaultDescription) options.defaultDescription[key] = defaultDescription - if (typeof value === 'function') { - if (!options.defaultDescription[key]) options.defaultDescription[key] = usage.functionDescription(value) - value = value.call() - } - options.default[key] = value - } - return self - } - - self.alias = function (x, y) { - if (typeof x === 'object') { - Object.keys(x).forEach(function (key) { - self.alias(key, x[key]) - }) - } else { - // perhaps 'x' is already an alias in another list? - // if so we should append to x's list. - var aliases = null - Object.keys(options.alias).forEach(function (key) { - if (~options.alias[key].indexOf(x)) aliases = options.alias[key] - }) - - if (aliases) { // x was an alias itself. - aliases.push(y) - } else { // x is a new alias key. - options.alias[x] = (options.alias[x] || []).concat(y) - } - - // wait! perhaps we've created two lists of aliases - // that reference each other? - if (options.alias[y]) { - Array.prototype.push.apply((options.alias[x] || aliases), options.alias[y]) - delete options.alias[y] - } - } - return self - } - - self.count = function (counts) { - options.count.push.apply(options.count, [].concat(counts)) - return self - } - - var demanded = {} - self.demand = self.required = self.require = function (keys, max, msg) { - // you can optionally provide a 'max' key, - // which will raise an exception if too many '_' - // options are provided. - if (typeof max !== 'number') { - msg = max - max = Infinity - } - - if (typeof keys === 'number') { - if (!demanded._) demanded._ = { count: 0, msg: null, max: max } - demanded._.count = keys - demanded._.msg = msg - } else if (Array.isArray(keys)) { - keys.forEach(function (key) { - self.demand(key, msg) - }) - } else { - if (typeof msg === 'string') { - demanded[keys] = { msg: msg } - } else if (msg === true || typeof msg === 'undefined') { - demanded[keys] = { msg: undefined } - } - } - - return self - } - self.getDemanded = function () { - return demanded - } - - self.requiresArg = function (requiresArgs) { - options.requiresArg.push.apply(options.requiresArg, [].concat(requiresArgs)) - return self - } - - self.implies = function (key, value) { - validation.implies(key, value) - return self - } - - self.usage = function (msg, opts) { - if (!opts && typeof msg === 'object') { - opts = msg - msg = null - } - - usage.usage(msg) - - if (opts) self.options(opts) - - return self - } - - self.epilogue = self.epilog = function (msg) { - usage.epilog(msg) - return self - } - - self.fail = function (f) { - usage.failFn(f) - return self - } - - self.check = function (f) { - validation.check(f) - return self - } - - self.defaults = self.default - - self.describe = function (key, desc) { - options.key[key] = true - usage.describe(key, desc) - return self - } - - self.parse = function (args) { - return parseArgs(args) - } - - self.option = self.options = function (key, opt) { - if (typeof key === 'object') { - Object.keys(key).forEach(function (k) { - self.options(k, key[k]) - }) - } else { - assert(typeof opt === 'object', 'second argument to option must be an object') - - options.key[key] = true // track manually set keys. - - if (opt.alias) self.alias(key, opt.alias) - - var demand = opt.demand || opt.required || opt.require - - if (demand) { - self.demand(key, demand) - } if ('config' in opt) { - self.config(key, opt.configParser) - } if ('default' in opt) { - self.default(key, opt.default) - } if ('nargs' in opt) { - self.nargs(key, opt.nargs) - } if ('choices' in opt) { - self.choices(key, opt.choices) - } if ('group' in opt) { - self.group(key, opt.group) - } if (opt.boolean || opt.type === 'boolean') { - self.boolean(key) - if (opt.alias) self.boolean(opt.alias) - } if (opt.array || opt.type === 'array') { - self.array(key) - if (opt.alias) self.array(opt.alias) - } if (opt.string || opt.type === 'string') { - self.string(key) - if (opt.alias) self.string(opt.alias) - } if (opt.count || opt.type === 'count') { - self.count(key) - } if (opt.defaultDescription) { - options.defaultDescription[key] = opt.defaultDescription - } - - var desc = opt.describe || opt.description || opt.desc - if (desc) { - self.describe(key, desc) - } - - if (opt.requiresArg) { - self.requiresArg(key) - } - } - - return self - } - self.getOptions = function () { - return options - } - - var groups = {} - self.group = function (opts, groupName) { - var seen = {} - groups[groupName] = (groups[groupName] || []).concat(opts).filter(function (key) { - if (seen[key]) return false - return (seen[key] = true) - }) - return self - } - self.getGroups = function () { - return groups - } - - // as long as options.envPrefix is not undefined, - // parser will apply env vars matching prefix to argv - self.env = function (prefix) { - if (prefix === false) options.envPrefix = undefined - else options.envPrefix = prefix || '' - return self - } - - self.wrap = function (cols) { - usage.wrap(cols) - return self - } - - var strict = false - self.strict = function () { - strict = true - return self - } - self.getStrict = function () { - return strict - } - - self.showHelp = function (level) { - if (!self.parsed) parseArgs(processArgs) // run parser, if it has not already been executed. - usage.showHelp(level) - return self - } - - var versionOpt = null - self.version = function (ver, opt, msg) { - versionOpt = opt || 'version' - usage.version(ver) - self.boolean(versionOpt) - self.describe(versionOpt, msg || usage.deferY18nLookup('Show version number')) - return self - } - - var helpOpt = null - self.addHelpOpt = function (opt, msg) { - helpOpt = opt - self.boolean(opt) - self.describe(opt, msg || usage.deferY18nLookup('Show help')) - return self - } - - self.showHelpOnFail = function (enabled, message) { - usage.showHelpOnFail(enabled, message) - return self - } - - var exitProcess = true - self.exitProcess = function (enabled) { - if (typeof enabled !== 'boolean') { - enabled = true - } - exitProcess = enabled - return self - } - self.getExitProcess = function () { - return exitProcess - } - - self.help = function () { - if (arguments.length > 0) return self.addHelpOpt.apply(self, arguments) - - if (!self.parsed) parseArgs(processArgs) // run parser, if it has not already been executed. - - return usage.help() - } - - var completionCommand = null - self.completion = function (cmd, desc, fn) { - // a function to execute when generating - // completions can be provided as the second - // or third argument to completion. - if (typeof desc === 'function') { - fn = desc - desc = null - } - - // register the completion command. - completionCommand = cmd || 'completion' - if (!desc && desc !== false) { - desc = 'generate bash completion script' - } - self.command(completionCommand, desc) - - // a function can be provided - if (fn) completion.registerFunction(fn) - - return self - } - - self.showCompletionScript = function ($0) { - $0 = $0 || self.$0 - console.log(completion.generateCompletionScript($0)) - return self - } - - self.locale = function (locale) { - if (arguments.length === 0) { - guessLocale() - return y18n.getLocale() - } - detectLocale = false - y18n.setLocale(locale) - return self - } - - self.updateStrings = self.updateLocale = function (obj) { - detectLocale = false - y18n.updateLocale(obj) - return self - } - - var detectLocale = true - self.detectLocale = function (detect) { - detectLocale = detect - return self - } - self.getDetectLocale = function () { - return detectLocale - } - - self.getUsageInstance = function () { - return usage - } - - self.getValidationInstance = function () { - return validation - } - - self.terminalWidth = function () { - return require('window-size').width - } - - Object.defineProperty(self, 'argv', { - get: function () { - var args = null - - try { - args = parseArgs(processArgs) - } catch (err) { - usage.fail(err.message) - } - - return args - }, - enumerable: true - }) - - function parseArgs (args) { - args = normalizeArgs(args) - - var parsed = Parser(args, options, y18n) - var argv = parsed.argv - var aliases = parsed.aliases - - argv.$0 = self.$0 - - self.parsed = parsed - - guessLocale() // guess locale lazily, so that it can be turned off in chain. - - // while building up the argv object, there - // are two passes through the parser. If completion - // is being performed short-circuit on the first pass. - if (completionCommand && - (process.argv.join(' ')).indexOf(completion.completionKey) !== -1 && - !argv[completion.completionKey]) { - return argv - } - - // if there's a handler associated with a - // command defer processing to it. - var handlerKeys = Object.keys(self.getCommandHandlers()) - for (var i = 0, command; (command = handlerKeys[i]) !== undefined; i++) { - if (~argv._.indexOf(command)) { - runCommand(command, self, argv) - return self.argv - } - } - - // generate a completion script for adding to ~/.bashrc. - if (completionCommand && ~argv._.indexOf(completionCommand) && !argv[completion.completionKey]) { - self.showCompletionScript() - if (exitProcess) { - process.exit(0) - } - } - - // we must run completions first, a user might - // want to complete the --help or --version option. - if (completion.completionKey in argv) { - // we allow for asynchronous completions, - // e.g., loading in a list of commands from an API. - completion.getCompletion(function (completions) { - ;(completions || []).forEach(function (completion) { - console.log(completion) - }) - - if (exitProcess) { - process.exit(0) - } - }) - return - } - - var helpOrVersion = false - Object.keys(argv).forEach(function (key) { - if (key === helpOpt && argv[key]) { - helpOrVersion = true - self.showHelp('log') - if (exitProcess) { - process.exit(0) - } - } else if (key === versionOpt && argv[key]) { - helpOrVersion = true - usage.showVersion() - if (exitProcess) { - process.exit(0) - } - } - }) - - // If the help or version options where used and exitProcess is false, - // we won't run validations - if (!helpOrVersion) { - if (parsed.error) throw parsed.error - - // if we're executed via bash completion, don't - // bother with validation. - if (!argv[completion.completionKey]) { - validation.nonOptionCount(argv) - validation.missingArgumentValue(argv) - validation.requiredArguments(argv) - if (strict) validation.unknownArguments(argv, aliases) - validation.customChecks(argv, aliases) - validation.limitedChoices(argv) - validation.implications(argv) - } - } - - setPlaceholderKeys(argv) - - return argv - } - - function guessLocale () { - if (!detectLocale) return - - try { - var osLocale = require('os-locale') - self.locale(osLocale.sync({ spawn: false })) - } catch (err) { - // if we explode looking up locale just noop - // we'll keep using the default language 'en'. - } - } - - function runCommand (command, yargs, argv) { - setPlaceholderKeys(argv) - yargs.getCommandHandlers()[command](yargs.reset(), argv) - } - - function setPlaceholderKeys (argv) { - Object.keys(options.key).forEach(function (key) { - // don't set placeholder keys for dot - // notation options 'foo.bar'. - if (~key.indexOf('.')) return - if (typeof argv[key] === 'undefined') argv[key] = undefined - }) - } - - function normalizeArgs (args) { - if (typeof args === 'string') { - return tokenizeArgString(args) - } - return args - } - - singletonify(self) - return self -} - -// rebase an absolute path to a relative one with respect to a base directory -// exported for tests -exports.rebase = rebase -function rebase (base, dir) { - return path.relative(base, dir) + const argv = yargs(processArgs, cwd, require) + singletonify(argv) + return argv } /* Hack an instance of Argv with process.argv into Argv @@ -655,11 +22,18 @@ function rebase (base, dir) { to get a parsed version of process.argv. */ function singletonify (inst) { - Object.keys(inst).forEach(function (key) { + Object.keys(inst).forEach((key) => { if (key === 'argv') { Argv.__defineGetter__(key, inst.__lookupGetter__(key)) + } else if (typeof inst[key] === 'function') { + Argv[key] = inst[key].bind(inst) } else { - Argv[key] = typeof inst[key] === 'function' ? inst[key].bind(inst) : inst[key] + Argv.__defineGetter__('$0', () => { + return inst.$0 + }) + Argv.__defineGetter__('parsed', () => { + return inst.parsed + }) } }) } diff --git a/node_modules/yargs/lib/completion.js b/node_modules/yargs/lib/completion.js index 576012f..3f3bf16 100644 --- a/node_modules/yargs/lib/completion.js +++ b/node_modules/yargs/lib/completion.js @@ -1,32 +1,36 @@ -var fs = require('fs') -var path = require('path') +'use strict' +const path = require('path') // add bash completions to your // yargs-powered applications. -module.exports = function (yargs, usage) { - var self = { +module.exports = function completion (yargs, usage, command) { + const self = { completionKey: 'get-yargs-completions' } + const zshShell = (process.env.SHELL && process.env.SHELL.indexOf('zsh') !== -1) || + (process.env.ZSH_NAME && process.env.ZSH_NAME.indexOf('zsh') !== -1) // get a list of completion commands. - self.getCompletion = function (done) { - var completions = [] - var current = process.argv[process.argv.length - 1] - var previous = process.argv.slice(process.argv.indexOf('--' + self.completionKey) + 1) - var argv = yargs.parse(previous) + // 'args' is the array of strings from the line to be completed + self.getCompletion = function getCompletion (args, done) { + const completions = [] + const current = args.length ? args[args.length - 1] : '' + const argv = yargs.parse(args, true) + const aliases = yargs.parsed.aliases + const parentCommands = yargs.getContext().commands // a custom completion function can be provided // to completion(). if (completionFunction) { if (completionFunction.length < 3) { - var result = completionFunction(current, argv) + const result = completionFunction(current, argv) // promise based completion function. if (typeof result.then === 'function') { - return result.then(function (list) { - process.nextTick(function () { done(list) }) - }).catch(function (err) { - process.nextTick(function () { throw err }) + return result.then((list) => { + process.nextTick(() => { done(list) }) + }).catch((err) => { + process.nextTick(() => { throw err }) }) } @@ -34,30 +38,52 @@ module.exports = function (yargs, usage) { return done(result) } else { // asynchronous completion function - return completionFunction(current, argv, function (completions) { + return completionFunction(current, argv, (completions) => { done(completions) }) } } - var handlers = yargs.getCommandHandlers() - for (var i = 0, ii = previous.length; i < ii; ++i) { - if (handlers[previous[i]]) { - return handlers[previous[i]](yargs.reset()) + const handlers = command.getCommandHandlers() + for (let i = 0, ii = args.length; i < ii; ++i) { + if (handlers[args[i]] && handlers[args[i]].builder) { + const builder = handlers[args[i]].builder + if (typeof builder === 'function') { + const y = yargs.reset() + builder(y) + return y.argv + } } } - if (!current.match(/^-/)) { - usage.getCommands().forEach(function (command) { - if (previous.indexOf(command[0]) === -1) { - completions.push(command[0]) + if (!current.match(/^-/) && parentCommands[parentCommands.length - 1] !== current) { + usage.getCommands().forEach((usageCommand) => { + const commandName = command.parseCommand(usageCommand[0]).cmd + if (args.indexOf(commandName) === -1) { + if (!zshShell) { + completions.push(commandName) + } else { + const desc = usageCommand[1] || '' + completions.push(commandName.replace(/:/g, '\\:') + ':' + desc) + } } }) } - if (current.match(/^-/)) { - Object.keys(yargs.getOptions().key).forEach(function (key) { - completions.push('--' + key) + if (current.match(/^-/) || (current === '' && completions.length === 0)) { + const descs = usage.getDescriptions() + Object.keys(yargs.getOptions().key).forEach((key) => { + // If the key and its aliases aren't in 'args', add the key to 'completions' + const keyAndAliases = [key].concat(aliases[key] || []) + const notInArgs = keyAndAliases.every(val => args.indexOf(`--${val}`) === -1) + if (notInArgs) { + if (!zshShell) { + completions.push(`--${key}`) + } else { + const desc = descs[key] || '' + completions.push(`--${key.replace(/:/g, '\\:')}:${desc.replace('__yargsString__:', '')}`) + } + } }) } @@ -65,25 +91,24 @@ module.exports = function (yargs, usage) { } // generate the completion script to add to your .bashrc. - self.generateCompletionScript = function ($0) { - var script = fs.readFileSync( - path.resolve(__dirname, '../completion.sh.hbs'), - 'utf-8' - ) - var name = path.basename($0) + self.generateCompletionScript = function generateCompletionScript ($0, cmd) { + const templates = require('./completion-templates') + let script = zshShell ? templates.completionZshTemplate : templates.completionShTemplate + const name = path.basename($0) // add ./to applications not yet installed as bin. - if ($0.match(/\.js$/)) $0 = './' + $0 + if ($0.match(/\.js$/)) $0 = `./${$0}` script = script.replace(/{{app_name}}/g, name) + script = script.replace(/{{completion_command}}/g, cmd) return script.replace(/{{app_path}}/g, $0) } // register a function to perform your own custom // completions., this function can be either // synchrnous or asynchronous. - var completionFunction = null - self.registerFunction = function (fn) { + let completionFunction = null + self.registerFunction = (fn) => { completionFunction = fn } diff --git a/node_modules/yargs/lib/parser.js b/node_modules/yargs/lib/parser.js deleted file mode 100644 index f5f68e9..0000000 --- a/node_modules/yargs/lib/parser.js +++ /dev/null @@ -1,520 +0,0 @@ -// fancy-pants parsing of argv, originally forked -// from minimist: https://www.npmjs.com/package/minimist -var camelCase = require('camelcase') -var path = require('path') - -function increment (orig) { - return orig !== undefined ? orig + 1 : 0 -} - -module.exports = function (args, opts, y18n) { - if (!opts) opts = {} - - var __ = y18n.__ - var error = null - var flags = { arrays: {}, bools: {}, strings: {}, counts: {}, normalize: {}, configs: {}, defaulted: {} } - - ;[].concat(opts['array']).filter(Boolean).forEach(function (key) { - flags.arrays[key] = true - }) - - ;[].concat(opts['boolean']).filter(Boolean).forEach(function (key) { - flags.bools[key] = true - }) - - ;[].concat(opts.string).filter(Boolean).forEach(function (key) { - flags.strings[key] = true - }) - - ;[].concat(opts.count).filter(Boolean).forEach(function (key) { - flags.counts[key] = true - }) - - ;[].concat(opts.normalize).filter(Boolean).forEach(function (key) { - flags.normalize[key] = true - }) - - Object.keys(opts.config).forEach(function (k) { - flags.configs[k] = opts.config[k] - }) - - var aliases = {} - var newAliases = {} - - extendAliases(opts.key) - extendAliases(opts.alias) - extendAliases(opts.default) - - var defaults = opts['default'] || {} - Object.keys(defaults).forEach(function (key) { - if (/-/.test(key) && !opts.alias[key]) { - aliases[key] = aliases[key] || [] - } - (aliases[key] || []).forEach(function (alias) { - defaults[alias] = defaults[key] - }) - }) - - var argv = { _: [] } - - Object.keys(flags.bools).forEach(function (key) { - setArg(key, !(key in defaults) ? false : defaults[key]) - setDefaulted(key) - }) - - var notFlags = [] - if (args.indexOf('--') !== -1) { - notFlags = args.slice(args.indexOf('--') + 1) - args = args.slice(0, args.indexOf('--')) - } - - for (var i = 0; i < args.length; i++) { - var arg = args[i] - var broken - var key - var letters - var m - var next - var value - - // -- seperated by = - if (arg.match(/^--.+=/)) { - // Using [\s\S] instead of . because js doesn't support the - // 'dotall' regex modifier. See: - // http://stackoverflow.com/a/1068308/13216 - m = arg.match(/^--([^=]+)=([\s\S]*)$/) - - // nargs format = '--f=monkey washing cat' - if (checkAllAliases(m[1], opts.narg)) { - args.splice(i + 1, m[1], m[2]) - i = eatNargs(i, m[1], args) - // arrays format = '--f=a b c' - } else if (checkAllAliases(m[1], flags.arrays) && args.length > i + 1) { - args.splice(i + 1, m[1], m[2]) - i = eatArray(i, m[1], args) - } else { - setArg(m[1], m[2]) - } - } else if (arg.match(/^--no-.+/)) { - key = arg.match(/^--no-(.+)/)[1] - setArg(key, false) - - // -- seperated by space. - } else if (arg.match(/^--.+/)) { - key = arg.match(/^--(.+)/)[1] - - // nargs format = '--foo a b c' - if (checkAllAliases(key, opts.narg)) { - i = eatNargs(i, key, args) - // array format = '--foo a b c' - } else if (checkAllAliases(key, flags.arrays) && args.length > i + 1) { - i = eatArray(i, key, args) - } else { - next = args[i + 1] - - if (next !== undefined && !next.match(/^-/) && - !checkAllAliases(key, flags.bools) && - !checkAllAliases(key, flags.counts)) { - setArg(key, next) - i++ - } else if (/^(true|false)$/.test(next)) { - setArg(key, next) - i++ - } else { - setArg(key, defaultForType(guessType(key, flags))) - } - } - - // dot-notation flag seperated by '='. - } else if (arg.match(/^-.\..+=/)) { - m = arg.match(/^-([^=]+)=([\s\S]*)$/) - setArg(m[1], m[2]) - - // dot-notation flag seperated by space. - } else if (arg.match(/^-.\..+/)) { - next = args[i + 1] - key = arg.match(/^-(.\..+)/)[1] - - if (next !== undefined && !next.match(/^-/) && - !checkAllAliases(key, flags.bools) && - !checkAllAliases(key, flags.counts)) { - setArg(key, next) - i++ - } else { - setArg(key, defaultForType(guessType(key, flags))) - } - } else if (arg.match(/^-[^-]+/)) { - letters = arg.slice(1, -1).split('') - broken = false - - for (var j = 0; j < letters.length; j++) { - next = arg.slice(j + 2) - - if (letters[j + 1] && letters[j + 1] === '=') { - value = arg.slice(j + 3) - key = letters[j] - - // nargs format = '-f=monkey washing cat' - if (checkAllAliases(letters[j], opts.narg)) { - args.splice(i + 1, 0, value) - i = eatNargs(i, key, args) - // array format = '-f=a b c' - } else if (checkAllAliases(key, flags.arrays) && args.length > i + 1) { - args.splice(i + 1, 0, value) - i = eatArray(i, key, args) - } else { - setArg(key, value) - } - - broken = true - break - } - - if (next === '-') { - setArg(letters[j], next) - continue - } - - if (/[A-Za-z]/.test(letters[j]) && - /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { - setArg(letters[j], next) - broken = true - break - } - - if (letters[j + 1] && letters[j + 1].match(/\W/)) { - setArg(letters[j], arg.slice(j + 2)) - broken = true - break - } else { - setArg(letters[j], defaultForType(guessType(letters[j], flags))) - } - } - - key = arg.slice(-1)[0] - - if (!broken && key !== '-') { - // nargs format = '-f a b c' - if (checkAllAliases(key, opts.narg)) { - i = eatNargs(i, key, args) - // array format = '-f a b c' - } else if (checkAllAliases(key, flags.arrays) && args.length > i + 1) { - i = eatArray(i, key, args) - } else { - if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && - !checkAllAliases(key, flags.bools) && - !checkAllAliases(key, flags.counts)) { - setArg(key, args[i + 1]) - i++ - } else if (args[i + 1] && /true|false/.test(args[i + 1])) { - setArg(key, args[i + 1]) - i++ - } else { - setArg(key, defaultForType(guessType(key, flags))) - } - } - } - } else { - argv._.push( - flags.strings['_'] || !isNumber(arg) ? arg : Number(arg) - ) - } - } - - // order of precedence: - // 1. command line arg - // 2. value from config file - // 3. value from env var - // 4. configured default value - applyEnvVars(opts, argv, true) // special case: check env vars that point to config file - setConfig(argv) - applyEnvVars(opts, argv, false) - applyDefaultsAndAliases(argv, aliases, defaults) - - Object.keys(flags.counts).forEach(function (key) { - setArg(key, defaults[key]) - }) - - notFlags.forEach(function (key) { - argv._.push(key) - }) - - // how many arguments should we consume, based - // on the nargs option? - function eatNargs (i, key, args) { - var toEat = checkAllAliases(key, opts.narg) - - if (args.length - (i + 1) < toEat) error = Error(__('Not enough arguments following: %s', key)) - - for (var ii = i + 1; ii < (toEat + i + 1); ii++) { - setArg(key, args[ii]) - } - - return (i + toEat) - } - - // if an option is an array, eat all non-hyphenated arguments - // following it... YUM! - // e.g., --foo apple banana cat becomes ["apple", "banana", "cat"] - function eatArray (i, key, args) { - for (var ii = i + 1; ii < args.length; ii++) { - if (/^-/.test(args[ii])) break - i = ii - setArg(key, args[ii]) - } - - return i - } - - function setArg (key, val) { - unsetDefaulted(key) - - // handle parsing boolean arguments --foo=true --bar false. - if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) { - if (typeof val === 'string') val = val === 'true' - } - - if (/-/.test(key) && !(aliases[key] && aliases[key].length)) { - var c = camelCase(key) - aliases[key] = [c] - newAliases[c] = true - } - - var value = !checkAllAliases(key, flags.strings) && isNumber(val) ? Number(val) : val - - if (checkAllAliases(key, flags.counts)) { - value = increment - } - - var splitKey = key.split('.') - setKey(argv, splitKey, value) - - // alias references an inner-value within - // a dot-notation object. see #279. - if (~key.indexOf('.') && aliases[key]) { - aliases[key].forEach(function (x) { - x = x.split('.') - setKey(argv, x, value) - }) - } - - ;(aliases[splitKey[0]] || []).forEach(function (x) { - x = x.split('.') - - // handle populating dot notation for both - // the key and its aliases. - if (splitKey.length > 1) { - var a = [].concat(splitKey) - a.shift() // nuke the old key. - x = x.concat(a) - } - - setKey(argv, x, value) - }) - - var keys = [key].concat(aliases[key] || []) - for (var i = 0, l = keys.length; i < l; i++) { - if (flags.normalize[keys[i]]) { - keys.forEach(function (key) { - argv.__defineSetter__(key, function (v) { - val = path.normalize(v) - }) - - argv.__defineGetter__(key, function () { - return typeof val === 'string' ? path.normalize(val) : val - }) - }) - break - } - } - } - - // set args from config.json file, this should be - // applied last so that defaults can be applied. - function setConfig (argv) { - var configLookup = {} - - // expand defaults/aliases, in-case any happen to reference - // the config.json file. - applyDefaultsAndAliases(configLookup, aliases, defaults) - - Object.keys(flags.configs).forEach(function (configKey) { - var configPath = argv[configKey] || configLookup[configKey] - if (configPath) { - try { - var config = null - var resolvedConfigPath = path.resolve(process.cwd(), configPath) - - if (typeof flags.configs[configKey] === 'function') { - try { - config = flags.configs[configKey](resolvedConfigPath) - } catch (e) { - config = e - } - if (config instanceof Error) { - error = config - return - } - } else { - config = require(resolvedConfigPath) - } - - Object.keys(config).forEach(function (key) { - // setting arguments via CLI takes precedence over - // values within the config file. - if (argv[key] === undefined || (flags.defaulted[key])) { - delete argv[key] - setArg(key, config[key]) - } - }) - } catch (ex) { - if (argv[configKey]) error = Error(__('Invalid JSON config file: %s', configPath)) - } - } - }) - } - - function applyEnvVars (opts, argv, configOnly) { - if (typeof opts.envPrefix === 'undefined') return - - var prefix = typeof opts.envPrefix === 'string' ? opts.envPrefix : '' - Object.keys(process.env).forEach(function (envVar) { - if (prefix === '' || envVar.lastIndexOf(prefix, 0) === 0) { - var key = camelCase(envVar.substring(prefix.length)) - if (((configOnly && flags.configs[key]) || !configOnly) && (!(key in argv) || flags.defaulted[key])) { - setArg(key, process.env[envVar]) - } - } - }) - } - - function applyDefaultsAndAliases (obj, aliases, defaults) { - Object.keys(defaults).forEach(function (key) { - if (!hasKey(obj, key.split('.'))) { - setKey(obj, key.split('.'), defaults[key]) - - ;(aliases[key] || []).forEach(function (x) { - if (hasKey(obj, x.split('.'))) return - setKey(obj, x.split('.'), defaults[key]) - }) - } - }) - } - - function hasKey (obj, keys) { - var o = obj - keys.slice(0, -1).forEach(function (key) { - o = (o[key] || {}) - }) - - var key = keys[keys.length - 1] - - if (typeof o !== 'object') return false - else return key in o - } - - function setKey (obj, keys, value) { - var o = obj - keys.slice(0, -1).forEach(function (key) { - if (o[key] === undefined) o[key] = {} - o = o[key] - }) - - var key = keys[keys.length - 1] - if (value === increment) { - o[key] = increment(o[key]) - } else if (o[key] === undefined && checkAllAliases(key, flags.arrays)) { - o[key] = Array.isArray(value) ? value : [value] - } else if (o[key] === undefined || typeof o[key] === 'boolean') { - o[key] = value - } else if (Array.isArray(o[key])) { - o[key].push(value) - } else { - o[key] = [ o[key], value ] - } - } - - // extend the aliases list with inferred aliases. - function extendAliases (obj) { - Object.keys(obj || {}).forEach(function (key) { - // short-circuit if we've already added a key - // to the aliases array, for example it might - // exist in both 'opts.default' and 'opts.key'. - if (aliases[key]) return - - aliases[key] = [].concat(opts.alias[key] || []) - // For "--option-name", also set argv.optionName - aliases[key].concat(key).forEach(function (x) { - if (/-/.test(x)) { - var c = camelCase(x) - aliases[key].push(c) - newAliases[c] = true - } - }) - aliases[key].forEach(function (x) { - aliases[x] = [key].concat(aliases[key].filter(function (y) { - return x !== y - })) - }) - }) - } - - // check if a flag is set for any of a key's aliases. - function checkAllAliases (key, flag) { - var isSet = false - var toCheck = [].concat(aliases[key] || [], key) - - toCheck.forEach(function (key) { - if (flag[key]) isSet = flag[key] - }) - - return isSet - } - - function setDefaulted (key) { - [].concat(aliases[key] || [], key).forEach(function (k) { - flags.defaulted[k] = true - }) - } - - function unsetDefaulted (key) { - [].concat(aliases[key] || [], key).forEach(function (k) { - delete flags.defaulted[k] - }) - } - - // return a default value, given the type of a flag., - // e.g., key of type 'string' will default to '', rather than 'true'. - function defaultForType (type) { - var def = { - boolean: true, - string: '', - array: [] - } - - return def[type] - } - - // given a flag, enforce a default type. - function guessType (key, flags) { - var type = 'boolean' - - if (flags.strings && flags.strings[key]) type = 'string' - else if (flags.arrays && flags.arrays[key]) type = 'array' - - return type - } - - function isNumber (x) { - if (typeof x === 'number') return true - if (/^0x[0-9a-f]+$/i.test(x)) return true - return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x) - } - - return { - argv: argv, - aliases: aliases, - error: error, - newAliases: newAliases - } -} diff --git a/node_modules/yargs/lib/tokenize-arg-string.js b/node_modules/yargs/lib/tokenize-arg-string.js deleted file mode 100644 index df43fa5..0000000 --- a/node_modules/yargs/lib/tokenize-arg-string.js +++ /dev/null @@ -1,32 +0,0 @@ -// take an un-split argv string and tokenize it. -module.exports = function (argString) { - var i = 0 - var c = null - var opening = null - var args = [] - - for (var ii = 0; ii < argString.length; ii++) { - c = argString.charAt(ii) - - // split on spaces unless we're in quotes. - if (c === ' ' && !opening) { - i++ - continue - } - - // don't split the string if we're in matching - // opening or closing single and double quotes. - if (c === opening) { - opening = null - continue - } else if ((c === "'" || c === '"') && !opening) { - opening = c - continue - } - - if (!args[i]) args[i] = '' - args[i] += c - } - - return args -} diff --git a/node_modules/yargs/lib/usage.js b/node_modules/yargs/lib/usage.js index b1b59bc..92bf378 100644 --- a/node_modules/yargs/lib/usage.js +++ b/node_modules/yargs/lib/usage.js @@ -1,23 +1,26 @@ +'use strict' // this file handles outputting usage instructions, // failures, etc. keeps logging in one place. -var cliui = require('cliui') -var decamelize = require('decamelize') -var stringWidth = require('string-width') -var wsize = require('window-size') +const decamelize = require('decamelize') +const stringWidth = require('string-width') +const objFilter = require('./obj-filter') +const path = require('path') +const setBlocking = require('set-blocking') +const YError = require('./yerror') -module.exports = function (yargs, y18n) { - var __ = y18n.__ - var self = {} +module.exports = function usage (yargs, y18n) { + const __ = y18n.__ + const self = {} // methods for ouputting/building failure message. - var fails = [] - self.failFn = function (f) { + const fails = [] + self.failFn = function failFn (f) { fails.push(f) } - var failMessage = null - var showHelpOnFail = true - self.showHelpOnFail = function (enabled, message) { + let failMessage = null + let showHelpOnFail = true + self.showHelpOnFail = function showHelpOnFailFn (enabled, message) { if (typeof enabled === 'string') { message = enabled enabled = true @@ -29,104 +32,170 @@ module.exports = function (yargs, y18n) { return self } - var failureOutput = false - self.fail = function (msg) { + let failureOutput = false + self.fail = function fail (msg, err) { + const logger = yargs._getLoggerInstance() + if (fails.length) { - fails.forEach(function (f) { - f(msg) - }) + for (let i = fails.length - 1; i >= 0; --i) { + fails[i](msg, err, self) + } } else { + if (yargs.getExitProcess()) setBlocking(true) + // don't output failure message more than once if (!failureOutput) { failureOutput = true - if (showHelpOnFail) yargs.showHelp('error') - if (msg) console.error(msg) + if (showHelpOnFail) { + yargs.showHelp('error') + logger.error() + } + if (msg || err) logger.error(msg || err) if (failMessage) { - if (msg) console.error('') - console.error(failMessage) + if (msg || err) logger.error('') + logger.error(failMessage) } } + + err = err || new YError(msg) if (yargs.getExitProcess()) { - process.exit(1) + return yargs.exit(1) + } else if (yargs._hasParseCallback()) { + return yargs.exit(1, err) } else { - throw new Error(msg) + throw err } } } // methods for ouputting/building help (usage) message. - var usage - self.usage = function (msg) { - usage = msg + let usages = [] + let usageDisabled = false + self.usage = (msg, description) => { + if (msg === null) { + usageDisabled = true + usages = [] + return + } + usageDisabled = false + usages.push([msg, description || '']) + return self + } + self.getUsage = () => { + return usages + } + self.getUsageDisabled = () => { + return usageDisabled } - var examples = [] - self.example = function (cmd, description) { + self.getPositionalGroupName = () => { + return __('Positionals:') + } + + let examples = [] + self.example = (cmd, description) => { examples.push([cmd, description || '']) } - var commands = [] - self.command = function (cmd, description) { - commands.push([cmd, description || '']) - } - self.getCommands = function () { - return commands + let commands = [] + self.command = function command (cmd, description, isDefault, aliases) { + // the last default wins, so cancel out any previously set default + if (isDefault) { + commands = commands.map((cmdArray) => { + cmdArray[2] = false + return cmdArray + }) + } + commands.push([cmd, description || '', isDefault, aliases]) } + self.getCommands = () => commands - var descriptions = {} - self.describe = function (key, desc) { + let descriptions = {} + self.describe = function describe (key, desc) { if (typeof key === 'object') { - Object.keys(key).forEach(function (k) { + Object.keys(key).forEach((k) => { self.describe(k, key[k]) }) } else { descriptions[key] = desc } } - self.getDescriptions = function () { - return descriptions + self.getDescriptions = () => descriptions + + let epilogs = [] + self.epilog = (msg) => { + epilogs.push(msg) } - var epilog - self.epilog = function (msg) { - epilog = msg - } - - var wrap = windowWidth() - self.wrap = function (cols) { + let wrapSet = false + let wrap + self.wrap = (cols) => { + wrapSet = true wrap = cols } - var deferY18nLookupPrefix = '__yargsString__:' - self.deferY18nLookup = function (str) { - return deferY18nLookupPrefix + str + function getWrap () { + if (!wrapSet) { + wrap = windowWidth() + wrapSet = true + } + + return wrap } - var defaultGroup = 'Options:' - self.help = function () { + const deferY18nLookupPrefix = '__yargsString__:' + self.deferY18nLookup = str => deferY18nLookupPrefix + str + + const defaultGroup = 'Options:' + self.help = function help () { + if (cachedHelpMessage) return cachedHelpMessage normalizeAliases() - var demanded = yargs.getDemanded() - var groups = yargs.getGroups() - var options = yargs.getOptions() - var keys = Object.keys( - Object.keys(descriptions) - .concat(Object.keys(demanded)) - .concat(Object.keys(options.default)) - .reduce(function (acc, key) { - if (key !== '_') acc[key] = true - return acc - }, {}) - ) - var ui = cliui({ - width: wrap, - wrap: !!wrap + // handle old demanded API + const base$0 = yargs.customScriptName ? yargs.$0 : path.basename(yargs.$0) + const demandedOptions = yargs.getDemandedOptions() + const demandedCommands = yargs.getDemandedCommands() + const groups = yargs.getGroups() + const options = yargs.getOptions() + + let keys = [] + keys = keys.concat(Object.keys(descriptions)) + keys = keys.concat(Object.keys(demandedOptions)) + keys = keys.concat(Object.keys(demandedCommands)) + keys = keys.concat(Object.keys(options.default)) + keys = keys.filter(filterHiddenOptions) + keys = Object.keys(keys.reduce((acc, key) => { + if (key !== '_') acc[key] = true + return acc + }, {})) + + const theWrap = getWrap() + const ui = require('cliui')({ + width: theWrap, + wrap: !!theWrap }) // the usage string. - if (usage) { - var u = usage.replace(/\$0/g, yargs.$0) - ui.div(u + '\n') + if (!usageDisabled) { + if (usages.length) { + // user-defined usage. + usages.forEach((usage) => { + ui.div(`${usage[0].replace(/\$0/g, base$0)}`) + if (usage[1]) { + ui.div({ text: `${usage[1]}`, padding: [1, 0, 0, 0] }) + } + }) + ui.div() + } else if (commands.length) { + let u = null + // demonstrate how commands are used. + if (demandedCommands._) { + u = `${base$0} <${__('command')}>\n` + } else { + u = `${base$0} [${__('command')}]\n` + } + ui.div(`${u}`) + } } // your application's commands, i.e., non-option @@ -134,11 +203,33 @@ module.exports = function (yargs, y18n) { if (commands.length) { ui.div(__('Commands:')) - commands.forEach(function (command) { - ui.div( - {text: command[0], padding: [0, 2, 0, 2], width: maxWidth(commands) + 4}, - {text: command[1]} + const context = yargs.getContext() + const parentCommands = context.commands.length ? `${context.commands.join(' ')} ` : '' + + if (yargs.getParserConfiguration()['sort-commands'] === true) { + commands = commands.sort((a, b) => a[0].localeCompare(b[0])) + } + + commands.forEach((command) => { + const commandString = `${base$0} ${parentCommands}${command[0].replace(/^\$0 ?/, '')}` // drop $0 from default commands. + ui.span( + { + text: commandString, + padding: [0, 2, 0, 2], + width: maxWidth(commands, theWrap, `${base$0}${parentCommands}`) + 4 + }, + { text: command[1] } ) + const hints = [] + if (command[2]) hints.push(`[${__('default:').slice(0, -1)}]`) // TODO hacking around i18n here + if (command[3] && command[3].length) { + hints.push(`[${__('aliases:')} ${command[3].join(', ')}]`) + } + if (hints.length) { + ui.div({ text: hints.join(' '), padding: [0, 0, 0, 2], align: 'right' }) + } else { + ui.div() + } }) ui.div() @@ -146,14 +237,10 @@ module.exports = function (yargs, y18n) { // perform some cleanup on the keys array, making it // only include top-level keys not their aliases. - var aliasKeys = (Object.keys(options.alias) || []) + const aliasKeys = (Object.keys(options.alias) || []) .concat(Object.keys(yargs.parsed.newAliases) || []) - keys = keys.filter(function (key) { - return !yargs.parsed.newAliases[key] && aliasKeys.every(function (alias) { - return (options.alias[alias] || []).indexOf(key) === -1 - }) - }) + keys = keys.filter(key => !yargs.parsed.newAliases[key] && aliasKeys.every(alias => (options.alias[alias] || []).indexOf(key) === -1)) // populate 'Options:' group with any keys that have not // explicitly had a group set. @@ -161,59 +248,65 @@ module.exports = function (yargs, y18n) { addUngroupedKeys(keys, options.alias, groups) // display 'Options:' table along with any custom tables: - Object.keys(groups).forEach(function (groupName) { + Object.keys(groups).forEach((groupName) => { if (!groups[groupName].length) return - ui.div(__(groupName)) - // if we've grouped the key 'f', but 'f' aliases 'foobar', // normalizedKeys should contain only 'foobar'. - var normalizedKeys = groups[groupName].map(function (key) { + const normalizedKeys = groups[groupName].filter(filterHiddenOptions).map((key) => { if (~aliasKeys.indexOf(key)) return key - for (var i = 0, aliasKey; (aliasKey = aliasKeys[i]) !== undefined; i++) { + for (let i = 0, aliasKey; (aliasKey = aliasKeys[i]) !== undefined; i++) { if (~(options.alias[aliasKey] || []).indexOf(key)) return aliasKey } return key }) + if (normalizedKeys.length < 1) return + + ui.div(__(groupName)) + // actually generate the switches string --foo, -f, --bar. - var switches = normalizedKeys.reduce(function (acc, key) { + const switches = normalizedKeys.reduce((acc, key) => { acc[key] = [ key ].concat(options.alias[key] || []) - .map(function (sw) { - return (sw.length > 1 ? '--' : '-') + sw + .map(sw => { + // for the special positional group don't + // add '--' or '-' prefix. + if (groupName === self.getPositionalGroupName()) return sw + else return (sw.length > 1 ? '--' : '-') + sw }) .join(', ') return acc }, {}) - normalizedKeys.forEach(function (key) { - var kswitch = switches[key] - var desc = descriptions[key] || '' - var type = null + normalizedKeys.forEach((key) => { + const kswitch = switches[key] + let desc = descriptions[key] || '' + let type = null if (~desc.lastIndexOf(deferY18nLookupPrefix)) desc = __(desc.substring(deferY18nLookupPrefix.length)) - if (~options.boolean.indexOf(key)) type = '[' + __('boolean') + ']' - if (~options.count.indexOf(key)) type = '[' + __('count') + ']' - if (~options.string.indexOf(key)) type = '[' + __('string') + ']' - if (~options.normalize.indexOf(key)) type = '[' + __('string') + ']' - if (~options.array.indexOf(key)) type = '[' + __('array') + ']' + if (~options.boolean.indexOf(key)) type = `[${__('boolean')}]` + if (~options.count.indexOf(key)) type = `[${__('count')}]` + if (~options.string.indexOf(key)) type = `[${__('string')}]` + if (~options.normalize.indexOf(key)) type = `[${__('string')}]` + if (~options.array.indexOf(key)) type = `[${__('array')}]` + if (~options.number.indexOf(key)) type = `[${__('number')}]` - var extra = [ + const extra = [ type, - demanded[key] ? '[' + __('required') + ']' : null, - options.choices && options.choices[key] ? '[' + __('choices:') + ' ' + - self.stringifiedValues(options.choices[key]) + ']' : null, + (key in demandedOptions) ? `[${__('required')}]` : null, + options.choices && options.choices[key] ? `[${__('choices:')} ${ + self.stringifiedValues(options.choices[key])}]` : null, defaultString(options.default[key], options.defaultDescription[key]) ].filter(Boolean).join(' ') ui.span( - {text: kswitch, padding: [0, 2, 0, 2], width: maxWidth(switches) + 4}, + { text: kswitch, padding: [0, 2, 0, 2], width: maxWidth(switches, theWrap) + 4 }, desc ) - if (extra) ui.div({text: extra, padding: [0, 0, 0, 2], align: 'right'}) + if (extra) ui.div({ text: extra, padding: [0, 0, 0, 2], align: 'right' }) else ui.div() }) @@ -224,49 +317,65 @@ module.exports = function (yargs, y18n) { if (examples.length) { ui.div(__('Examples:')) - examples.forEach(function (example) { - example[0] = example[0].replace(/\$0/g, yargs.$0) + examples.forEach((example) => { + example[0] = example[0].replace(/\$0/g, base$0) }) - examples.forEach(function (example) { - ui.div( - {text: example[0], padding: [0, 2, 0, 2], width: maxWidth(examples) + 4}, - example[1] - ) + examples.forEach((example) => { + if (example[1] === '') { + ui.div( + { + text: example[0], + padding: [0, 2, 0, 2] + } + ) + } else { + ui.div( + { + text: example[0], + padding: [0, 2, 0, 2], + width: maxWidth(examples, theWrap) + 4 + }, { + text: example[1] + } + ) + } }) ui.div() } // the usage string. - if (epilog) { - var e = epilog.replace(/\$0/g, yargs.$0) - ui.div(e + '\n') + if (epilogs.length > 0) { + const e = epilogs.map(epilog => epilog.replace(/\$0/g, base$0)).join('\n') + ui.div(`${e}\n`) } - return ui.toString() + // Remove the trailing white spaces + return ui.toString().replace(/\s*$/, '') } // return the maximum width of a string // in the left-hand column of a table. - function maxWidth (table) { - var width = 0 + function maxWidth (table, theWrap, modifier) { + let width = 0 // table might be of the form [leftColumn], - // or {key: leftColumn}} + // or {key: leftColumn} if (!Array.isArray(table)) { - table = Object.keys(table).map(function (key) { - return [table[key]] - }) + table = Object.keys(table).map(key => [table[key]]) } - table.forEach(function (v) { - width = Math.max(stringWidth(v[0]), width) + table.forEach((v) => { + width = Math.max( + stringWidth(modifier ? `${modifier} ${v[0]}` : v[0]), + width + ) }) // if we've enabled 'wrap' we should limit // the max-width of the left-column. - if (wrap) width = Math.min(width, parseInt(wrap * 0.5, 10)) + if (theWrap) width = Math.min(width, parseInt(theWrap * 0.5, 10)) return width } @@ -274,63 +383,76 @@ module.exports = function (yargs, y18n) { // make sure any options set for aliases, // are copied to the keys being aliased. function normalizeAliases () { - var demanded = yargs.getDemanded() - var options = yargs.getOptions() + // handle old demanded API + const demandedOptions = yargs.getDemandedOptions() + const options = yargs.getOptions() - ;(Object.keys(options.alias) || []).forEach(function (key) { - options.alias[key].forEach(function (alias) { + ;(Object.keys(options.alias) || []).forEach((key) => { + options.alias[key].forEach((alias) => { // copy descriptions. if (descriptions[alias]) self.describe(key, descriptions[alias]) // copy demanded. - if (demanded[alias]) yargs.demand(key, demanded[alias].msg) + if (alias in demandedOptions) yargs.demandOption(key, demandedOptions[alias]) // type messages. if (~options.boolean.indexOf(alias)) yargs.boolean(key) if (~options.count.indexOf(alias)) yargs.count(key) if (~options.string.indexOf(alias)) yargs.string(key) if (~options.normalize.indexOf(alias)) yargs.normalize(key) if (~options.array.indexOf(alias)) yargs.array(key) + if (~options.number.indexOf(alias)) yargs.number(key) }) }) } + // if yargs is executing an async handler, we take a snapshot of the + // help message to display on failure: + let cachedHelpMessage + self.cacheHelpMessage = function () { + cachedHelpMessage = this.help() + } + // given a set of keys, place any keys that are // ungrouped under the 'Options:' grouping. function addUngroupedKeys (keys, aliases, groups) { - var groupedKeys = [] - var toCheck = null - Object.keys(groups).forEach(function (group) { + let groupedKeys = [] + let toCheck = null + Object.keys(groups).forEach((group) => { groupedKeys = groupedKeys.concat(groups[group]) }) - keys.forEach(function (key) { + keys.forEach((key) => { toCheck = [key].concat(aliases[key]) - if (!toCheck.some(function (k) { - return groupedKeys.indexOf(k) !== -1 - })) { + if (!toCheck.some(k => groupedKeys.indexOf(k) !== -1)) { groups[defaultGroup].push(key) } }) return groupedKeys } - self.showHelp = function (level) { - level = level || 'error' - console[level](self.help()) + function filterHiddenOptions (key) { + return yargs.getOptions().hiddenOptions.indexOf(key) < 0 || yargs.parsed.argv[yargs.getOptions().showHiddenOpt] } - self.functionDescription = function (fn) { - var description = fn.name ? decamelize(fn.name, '-') : __('generated-value') + self.showHelp = (level) => { + const logger = yargs._getLoggerInstance() + if (!level) level = 'error' + const emit = typeof level === 'function' ? level : logger[level] + emit(self.help()) + } + + self.functionDescription = (fn) => { + const description = fn.name ? decamelize(fn.name, '-') : __('generated-value') return ['(', description, ')'].join('') } - self.stringifiedValues = function (values, separator) { - var string = '' - var sep = separator || ', ' - var array = [].concat(values) + self.stringifiedValues = function stringifiedValues (values, separator) { + let string = '' + const sep = separator || ', ' + const array = [].concat(values) if (!values || !array.length) return string - array.forEach(function (value) { + array.forEach((value) => { if (string.length) string += sep string += JSON.stringify(value) }) @@ -341,7 +463,7 @@ module.exports = function (yargs, y18n) { // format the default-value-string displayed in // the right-hand column. function defaultString (value, defaultDescription) { - var string = '[' + __('default:') + ' ' + let string = `[${__('default:')} ` if (value === undefined && !defaultDescription) return null @@ -350,7 +472,7 @@ module.exports = function (yargs, y18n) { } else { switch (typeof value) { case 'string': - string += JSON.stringify(value) + string += `"${value}"` break case 'object': string += JSON.stringify(value) @@ -360,23 +482,67 @@ module.exports = function (yargs, y18n) { } } - return string + ']' + return `${string}]` } // guess the width of the console window, max-width 80. function windowWidth () { - return wsize.width ? Math.min(80, wsize.width) : null + const maxWidth = 80 + if (typeof process === 'object' && process.stdout && process.stdout.columns) { + return Math.min(maxWidth, process.stdout.columns) + } else { + return maxWidth + } } // logic for displaying application version. - var version = null - self.version = function (ver, opt, msg) { + let version = null + self.version = (ver) => { version = ver } - self.showVersion = function () { - if (typeof version === 'function') console.log(version()) - else console.log(version) + self.showVersion = () => { + const logger = yargs._getLoggerInstance() + logger.log(version) + } + + self.reset = function reset (localLookup) { + // do not reset wrap here + // do not reset fails here + failMessage = null + failureOutput = false + usages = [] + usageDisabled = false + epilogs = [] + examples = [] + commands = [] + descriptions = objFilter(descriptions, (k, v) => !localLookup[k]) + return self + } + + let frozens = [] + self.freeze = function freeze () { + let frozen = {} + frozens.push(frozen) + frozen.failMessage = failMessage + frozen.failureOutput = failureOutput + frozen.usages = usages + frozen.usageDisabled = usageDisabled + frozen.epilogs = epilogs + frozen.examples = examples + frozen.commands = commands + frozen.descriptions = descriptions + } + self.unfreeze = function unfreeze () { + let frozen = frozens.pop() + failMessage = frozen.failMessage + failureOutput = frozen.failureOutput + usages = frozen.usages + usageDisabled = frozen.usageDisabled + epilogs = frozen.epilogs + examples = frozen.examples + commands = frozen.commands + descriptions = frozen.descriptions } return self diff --git a/node_modules/yargs/lib/validation.js b/node_modules/yargs/lib/validation.js index 514bbff..35659a3 100644 --- a/node_modules/yargs/lib/validation.js +++ b/node_modules/yargs/lib/validation.js @@ -1,85 +1,81 @@ +'use strict' +const argsert = require('./argsert') +const objFilter = require('./obj-filter') +const specialKeys = ['$0', '--', '_'] + // validation-type-stuff, missing params, // bad implications, custom checks. -module.exports = function (yargs, usage, y18n) { - var __ = y18n.__ - var __n = y18n.__n - var self = {} +module.exports = function validation (yargs, usage, y18n) { + const __ = y18n.__ + const __n = y18n.__n + const self = {} // validate appropriate # of non-option // arguments were provided, i.e., '_'. - self.nonOptionCount = function (argv) { - var demanded = yargs.getDemanded() - var _s = argv._.length + self.nonOptionCount = function nonOptionCount (argv) { + const demandedCommands = yargs.getDemandedCommands() + // don't count currently executing commands + const _s = argv._.length - yargs.getContext().commands.length - if (demanded._ && (_s < demanded._.count || _s > demanded._.max)) { - if (demanded._.msg !== undefined) { - usage.fail(demanded._.msg) - } else if (_s < demanded._.count) { - usage.fail( - __('Not enough non-option arguments: got %s, need at least %s', argv._.length, demanded._.count) - ) - } else { - usage.fail( - __('Too many non-option arguments: got %s, maximum of %s', argv._.length, demanded._.max) - ) + if (demandedCommands._ && (_s < demandedCommands._.min || _s > demandedCommands._.max)) { + if (_s < demandedCommands._.min) { + if (demandedCommands._.minMsg !== undefined) { + usage.fail( + // replace $0 with observed, $1 with expected. + demandedCommands._.minMsg ? demandedCommands._.minMsg.replace(/\$0/g, _s).replace(/\$1/, demandedCommands._.min) : null + ) + } else { + usage.fail( + __('Not enough non-option arguments: got %s, need at least %s', _s, demandedCommands._.min) + ) + } + } else if (_s > demandedCommands._.max) { + if (demandedCommands._.maxMsg !== undefined) { + usage.fail( + // replace $0 with observed, $1 with expected. + demandedCommands._.maxMsg ? demandedCommands._.maxMsg.replace(/\$0/g, _s).replace(/\$1/, demandedCommands._.max) : null + ) + } else { + usage.fail( + __('Too many non-option arguments: got %s, maximum of %s', _s, demandedCommands._.max) + ) + } } } } - // make sure that any args that require an - // value (--foo=bar), have a value. - self.missingArgumentValue = function (argv) { - var defaultValues = [true, false, ''] - var options = yargs.getOptions() - - if (options.requiresArg.length > 0) { - var missingRequiredArgs = [] - - options.requiresArg.forEach(function (key) { - var value = argv[key] - - // if a value is explicitly requested, - // flag argument as missing if it does not - // look like foo=bar was entered. - if (~defaultValues.indexOf(value) || - (Array.isArray(value) && !value.length)) { - missingRequiredArgs.push(key) - } - }) - - if (missingRequiredArgs.length > 0) { - usage.fail(__n( - 'Missing argument value: %s', - 'Missing argument values: %s', - missingRequiredArgs.length, - missingRequiredArgs.join(', ') - )) - } + // validate the appropriate # of + // positional arguments were provided: + self.positionalCount = function positionalCount (required, observed) { + if (observed < required) { + usage.fail( + __('Not enough non-option arguments: got %s, need at least %s', observed, required) + ) } } // make sure all the required arguments are present. - self.requiredArguments = function (argv) { - var demanded = yargs.getDemanded() - var missing = null + self.requiredArguments = function requiredArguments (argv) { + const demandedOptions = yargs.getDemandedOptions() + let missing = null - Object.keys(demanded).forEach(function (key) { - if (!argv.hasOwnProperty(key)) { + Object.keys(demandedOptions).forEach((key) => { + if (!argv.hasOwnProperty(key) || typeof argv[key] === 'undefined') { missing = missing || {} - missing[key] = demanded[key] + missing[key] = demandedOptions[key] } }) if (missing) { - var customMsgs = [] - Object.keys(missing).forEach(function (key) { - var msg = missing[key].msg + const customMsgs = [] + Object.keys(missing).forEach((key) => { + const msg = missing[key] if (msg && customMsgs.indexOf(msg) < 0) { customMsgs.push(msg) } }) - var customMsg = customMsgs.length ? '\n' + customMsgs.join('\n') : '' + const customMsg = customMsgs.length ? `\n${customMsgs.join('\n')}` : '' usage.fail(__n( 'Missing required argument: %s', @@ -91,27 +87,29 @@ module.exports = function (yargs, usage, y18n) { } // check for unknown arguments (strict-mode). - self.unknownArguments = function (argv, aliases) { - var aliasLookup = {} - var descriptions = usage.getDescriptions() - var demanded = yargs.getDemanded() - var unknown = [] + self.unknownArguments = function unknownArguments (argv, aliases, positionalMap) { + const commandKeys = yargs.getCommandInstance().getCommands() + const unknown = [] + const currentContext = yargs.getContext() - Object.keys(aliases).forEach(function (key) { - aliases[key].forEach(function (alias) { - aliasLookup[alias] = key - }) - }) - - Object.keys(argv).forEach(function (key) { - if (key !== '$0' && key !== '_' && - !descriptions.hasOwnProperty(key) && - !demanded.hasOwnProperty(key) && - !aliasLookup.hasOwnProperty(key)) { + Object.keys(argv).forEach((key) => { + if (specialKeys.indexOf(key) === -1 && + !positionalMap.hasOwnProperty(key) && + !yargs._getParseContext().hasOwnProperty(key) && + !self.isValidAndSomeAliasIsNotNew(key, aliases) + ) { unknown.push(key) } }) + if ((currentContext.commands.length > 0) || (commandKeys.length > 0)) { + argv._.slice(currentContext.commands.length).forEach((key) => { + if (commandKeys.indexOf(key) === -1) { + unknown.push(key) + } + }) + } + if (unknown.length > 0) { usage.fail(__n( 'Unknown argument: %s', @@ -122,128 +120,231 @@ module.exports = function (yargs, usage, y18n) { } } + // check for a key that is not an alias, or for which every alias is new, + // implying that it was invented by the parser, e.g., during camelization + self.isValidAndSomeAliasIsNotNew = function isValidAndSomeAliasIsNotNew (key, aliases) { + if (!aliases.hasOwnProperty(key)) { + return false + } + const newAliases = yargs.parsed.newAliases + for (let a of [key, ...aliases[key]]) { + if (!newAliases.hasOwnProperty(a) || !newAliases[key]) { + return true + } + } + return false + } + // validate arguments limited to enumerated choices - self.limitedChoices = function (argv) { - var options = yargs.getOptions() - var invalid = {} + self.limitedChoices = function limitedChoices (argv) { + const options = yargs.getOptions() + const invalid = {} if (!Object.keys(options.choices).length) return - Object.keys(argv).forEach(function (key) { - if (key !== '$0' && key !== '_' && + Object.keys(argv).forEach((key) => { + if (specialKeys.indexOf(key) === -1 && options.choices.hasOwnProperty(key)) { - [].concat(argv[key]).forEach(function (value) { + [].concat(argv[key]).forEach((value) => { // TODO case-insensitive configurability - if (options.choices[key].indexOf(value) === -1) { + if (options.choices[key].indexOf(value) === -1 && + value !== undefined) { invalid[key] = (invalid[key] || []).concat(value) } }) } }) - var invalidKeys = Object.keys(invalid) + const invalidKeys = Object.keys(invalid) if (!invalidKeys.length) return - var msg = __('Invalid values:') - invalidKeys.forEach(function (key) { - msg += '\n ' + __( + let msg = __('Invalid values:') + invalidKeys.forEach((key) => { + msg += `\n ${__( 'Argument: %s, Given: %s, Choices: %s', key, usage.stringifiedValues(invalid[key]), usage.stringifiedValues(options.choices[key]) - ) + )}` }) usage.fail(msg) } // custom checks, added using the `check` option on yargs. - var checks = [] - self.check = function (f) { - checks.push(f) + let checks = [] + self.check = function check (f, global) { + checks.push({ + func: f, + global + }) } - self.customChecks = function (argv, aliases) { - checks.forEach(function (f) { + self.customChecks = function customChecks (argv, aliases) { + for (let i = 0, f; (f = checks[i]) !== undefined; i++) { + const func = f.func + let result = null try { - var result = f(argv, aliases) - if (!result) { - usage.fail(__('Argument check failed: %s', f.toString())) - } else if (typeof result === 'string') { - usage.fail(result) - } + result = func(argv, aliases) } catch (err) { - usage.fail(err.message ? err.message : err) + usage.fail(err.message ? err.message : err, err) + continue } - }) + + if (!result) { + usage.fail(__('Argument check failed: %s', func.toString())) + } else if (typeof result === 'string' || result instanceof Error) { + usage.fail(result.toString(), result) + } + } } // check implications, argument foo implies => argument bar. - var implied = {} - self.implies = function (key, value) { + let implied = {} + self.implies = function implies (key, value) { + argsert(' [array|number|string]', [key, value], arguments.length) + if (typeof key === 'object') { - Object.keys(key).forEach(function (k) { + Object.keys(key).forEach((k) => { self.implies(k, key[k]) }) } else { - implied[key] = value + yargs.global(key) + if (!implied[key]) { + implied[key] = [] + } + if (Array.isArray(value)) { + value.forEach((i) => self.implies(key, i)) + } else { + implied[key].push(value) + } } } - self.getImplied = function () { + self.getImplied = function getImplied () { return implied } - self.implications = function (argv) { - var implyFail = [] + function keyExists (argv, val) { + // convert string '1' to number 1 + let num = Number(val) + val = isNaN(num) ? val : num - Object.keys(implied).forEach(function (key) { - var num - var origKey = key - var value = implied[key] + if (typeof val === 'number') { + // check length of argv._ + val = argv._.length >= val + } else if (val.match(/^--no-.+/)) { + // check if key/value doesn't exist + val = val.match(/^--no-(.+)/)[1] + val = !argv[val] + } else { + // check if key/value exists + val = argv[val] + } + return val + } - // convert string '1' to number 1 - num = Number(key) - key = isNaN(num) ? key : num + self.implications = function implications (argv) { + const implyFail = [] - if (typeof key === 'number') { - // check length of argv._ - key = argv._.length >= key - } else if (key.match(/^--no-.+/)) { - // check if key doesn't exist - key = key.match(/^--no-(.+)/)[1] - key = !argv[key] - } else { - // check if key exists - key = argv[key] - } + Object.keys(implied).forEach((key) => { + const origKey = key + ;(implied[key] || []).forEach((value) => { + let key = origKey + const origValue = value + key = keyExists(argv, key) + value = keyExists(argv, value) - num = Number(value) - value = isNaN(num) ? value : num - - if (typeof value === 'number') { - value = argv._.length >= value - } else if (value.match(/^--no-.+/)) { - value = value.match(/^--no-(.+)/)[1] - value = !argv[value] - } else { - value = argv[value] - } - - if (key && !value) { - implyFail.push(origKey) - } + if (key && !value) { + implyFail.push(` ${origKey} -> ${origValue}`) + } + }) }) if (implyFail.length) { - var msg = __('Implications failed:') + '\n' + let msg = `${__('Implications failed:')}\n` - implyFail.forEach(function (key) { - msg += (' ' + key + ' -> ' + implied[key]) + implyFail.forEach((value) => { + msg += (value) }) usage.fail(msg) } } + let conflicting = {} + self.conflicts = function conflicts (key, value) { + argsert(' [array|string]', [key, value], arguments.length) + + if (typeof key === 'object') { + Object.keys(key).forEach((k) => { + self.conflicts(k, key[k]) + }) + } else { + yargs.global(key) + if (!conflicting[key]) { + conflicting[key] = [] + } + if (Array.isArray(value)) { + value.forEach((i) => self.conflicts(key, i)) + } else { + conflicting[key].push(value) + } + } + } + self.getConflicting = () => conflicting + + self.conflicting = function conflictingFn (argv) { + Object.keys(argv).forEach((key) => { + if (conflicting[key]) { + conflicting[key].forEach((value) => { + // we default keys to 'undefined' that have been configured, we should not + // apply conflicting check unless they are a value other than 'undefined'. + if (value && argv[key] !== undefined && argv[value] !== undefined) { + usage.fail(__('Arguments %s and %s are mutually exclusive', key, value)) + } + }) + } + }) + } + + self.recommendCommands = function recommendCommands (cmd, potentialCommands) { + const distance = require('./levenshtein') + const threshold = 3 // if it takes more than three edits, let's move on. + potentialCommands = potentialCommands.sort((a, b) => b.length - a.length) + + let recommended = null + let bestDistance = Infinity + for (let i = 0, candidate; (candidate = potentialCommands[i]) !== undefined; i++) { + const d = distance(cmd, candidate) + if (d <= threshold && d < bestDistance) { + bestDistance = d + recommended = candidate + } + } + if (recommended) usage.fail(__('Did you mean %s?', recommended)) + } + + self.reset = function reset (localLookup) { + implied = objFilter(implied, (k, v) => !localLookup[k]) + conflicting = objFilter(conflicting, (k, v) => !localLookup[k]) + checks = checks.filter(c => c.global) + return self + } + + let frozens = [] + self.freeze = function freeze () { + let frozen = {} + frozens.push(frozen) + frozen.implied = implied + frozen.checks = checks + frozen.conflicting = conflicting + } + self.unfreeze = function unfreeze () { + let frozen = frozens.pop() + implied = frozen.implied + checks = frozen.checks + conflicting = frozen.conflicting + } + return self } diff --git a/node_modules/yargs/locales/de.json b/node_modules/yargs/locales/de.json index 00b3907..05d9837 100644 --- a/node_modules/yargs/locales/de.json +++ b/node_modules/yargs/locales/de.json @@ -5,10 +5,12 @@ "boolean": "boolean", "count": "Zähler", "string": "string", + "number": "Zahl", "array": "array", "required": "erforderlich", "default:": "Standard:", "choices:": "Möglichkeiten:", + "aliases:": "Aliase:", "generated-value": "Generierter-Wert", "Not enough non-option arguments: got %s, need at least %s": "Nicht genügend Argumente ohne Optionen: %s vorhanden, mindestens %s benötigt", "Too many non-option arguments: got %s, maximum of %s": "Zu viele Argumente ohne Optionen: %s vorhanden, maximal %s erlaubt", @@ -27,10 +29,11 @@ "Invalid values:": "Unzulässige Werte:", "Argument: %s, Given: %s, Choices: %s": "Argument: %s, Gegeben: %s, Möglichkeiten: %s", "Argument check failed: %s": "Argumente-Check fehlgeschlagen: %s", - "Implications failed:": "Implikationen fehlgeschlagen:", + "Implications failed:": "Fehlende abhängige Argumente:", "Not enough arguments following: %s": "Nicht genügend Argumente nach: %s", "Invalid JSON config file: %s": "Fehlerhafte JSON-Config Datei: %s", "Path to JSON config file": "Pfad zur JSON-Config Datei", "Show help": "Hilfe anzeigen", - "Show version number": "Version anzeigen" + "Show version number": "Version anzeigen", + "Did you mean %s?": "Meintest du %s?" } diff --git a/node_modules/yargs/locales/en.json b/node_modules/yargs/locales/en.json index ce19199..b32a63f 100644 --- a/node_modules/yargs/locales/en.json +++ b/node_modules/yargs/locales/en.json @@ -5,10 +5,12 @@ "boolean": "boolean", "count": "count", "string": "string", + "number": "number", "array": "array", "required": "required", "default:": "default:", "choices:": "choices:", + "aliases:": "aliases:", "generated-value": "generated-value", "Not enough non-option arguments: got %s, need at least %s": "Not enough non-option arguments: got %s, need at least %s", "Too many non-option arguments: got %s, maximum of %s": "Too many non-option arguments: got %s, maximum of %s", @@ -27,10 +29,14 @@ "Invalid values:": "Invalid values:", "Argument: %s, Given: %s, Choices: %s": "Argument: %s, Given: %s, Choices: %s", "Argument check failed: %s": "Argument check failed: %s", - "Implications failed:": "Implications failed:", + "Implications failed:": "Missing dependent arguments:", "Not enough arguments following: %s": "Not enough arguments following: %s", "Invalid JSON config file: %s": "Invalid JSON config file: %s", "Path to JSON config file": "Path to JSON config file", "Show help": "Show help", - "Show version number": "Show version number" + "Show version number": "Show version number", + "Did you mean %s?": "Did you mean %s?", + "Arguments %s and %s are mutually exclusive" : "Arguments %s and %s are mutually exclusive", + "Positionals:": "Positionals:", + "command": "command" } diff --git a/node_modules/yargs/locales/es.json b/node_modules/yargs/locales/es.json index c4f1917..d7c8af9 100644 --- a/node_modules/yargs/locales/es.json +++ b/node_modules/yargs/locales/es.json @@ -2,13 +2,15 @@ "Commands:": "Comandos:", "Options:": "Opciones:", "Examples:": "Ejemplos:", - "boolean": "boolean", + "boolean": "booleano", "count": "cuenta", "string": "cadena de caracteres", + "number": "número", "array": "tabla", - "required": "requisito", + "required": "requerido", "default:": "defecto:", "choices:": "selección:", + "aliases:": "alias:", "generated-value": "valor-generado", "Not enough non-option arguments: got %s, need at least %s": "Hacen falta argumentos no-opcionales: Número recibido %s, necesita por lo menos %s", "Too many non-option arguments: got %s, maximum of %s": "Demasiados argumentos no-opcionales: Número recibido %s, máximo es %s", @@ -25,12 +27,13 @@ "other": "Argumentos desconocidos: %s" }, "Invalid values:": "Valores inválidos:", - "Argument: %s, Given: %s, Choices: %s": "Argumento: %s, Recibido: %s, Selección: %s", - "Argument check failed: %s": "Verificación de argumento ha fracasado: %s", - "Implications failed:": "Implicaciones fracasadas:", + "Argument: %s, Given: %s, Choices: %s": "Argumento: %s, Recibido: %s, Seleccionados: %s", + "Argument check failed: %s": "Verificación de argumento ha fallado: %s", + "Implications failed:": "Implicaciones fallidas:", "Not enough arguments following: %s": "No hay suficientes argumentos después de: %s", "Invalid JSON config file: %s": "Archivo de configuración JSON inválido: %s", "Path to JSON config file": "Ruta al archivo de configuración JSON", "Show help": "Muestra ayuda", - "Show version number": "Muestra número de versión" + "Show version number": "Muestra número de versión", + "Did you mean %s?": "Quisiste decir %s?" } diff --git a/node_modules/yargs/locales/fr.json b/node_modules/yargs/locales/fr.json index 49d068b..cf9c74b 100644 --- a/node_modules/yargs/locales/fr.json +++ b/node_modules/yargs/locales/fr.json @@ -5,6 +5,7 @@ "boolean": "booléen", "count": "comptage", "string": "chaine de caractère", + "number": "nombre", "array": "tableau", "required": "requis", "default:": "défaut:", @@ -27,7 +28,7 @@ "Invalid values:": "Valeurs invalides:", "Argument: %s, Given: %s, Choices: %s": "Argument: %s, Donné: %s, Choix: %s", "Argument check failed: %s": "Echec de la vérification de l'argument: %s", - "Implications failed:": "Implications échouées:", + "Implications failed:": "Arguments dépendants manquants:", "Not enough arguments following: %s": "Pas assez d'arguments suivant: %s", "Invalid JSON config file: %s": "Fichier de configuration JSON invalide: %s", "Path to JSON config file": "Chemin du fichier de configuration JSON", diff --git a/node_modules/yargs/locales/id.json b/node_modules/yargs/locales/id.json index 7cb7e56..87e441c 100644 --- a/node_modules/yargs/locales/id.json +++ b/node_modules/yargs/locales/id.json @@ -5,10 +5,12 @@ "Examples:": "Contoh:", "boolean": "boolean", "count": "jumlah", + "number": "nomor", "string": "string", "array": "larik", "required": "diperlukan", "default:": "bawaan:", + "aliases:": "istilah lain:", "choices:": "pilihan:", "generated-value": "nilai-yang-dihasilkan", "Not enough non-option arguments: got %s, need at least %s": "Argumen wajib kurang: hanya %s, minimal %s", @@ -33,5 +35,9 @@ "Invalid JSON config file: %s": "Berkas konfigurasi JSON tidak valid: %s", "Path to JSON config file": "Alamat berkas konfigurasi JSON", "Show help": "Lihat bantuan", - "Show version number": "Lihat nomor versi" + "Show version number": "Lihat nomor versi", + "Did you mean %s?": "Maksud Anda: %s?", + "Arguments %s and %s are mutually exclusive" : "Argumen %s dan %s saling eksklusif", + "Positionals:": "Posisional-posisional:", + "command": "perintah" } diff --git a/node_modules/yargs/locales/ja.json b/node_modules/yargs/locales/ja.json index 21b8e52..64ee6d3 100644 --- a/node_modules/yargs/locales/ja.json +++ b/node_modules/yargs/locales/ja.json @@ -5,10 +5,12 @@ "boolean": "真偽", "count": "カウント", "string": "文字列", + "number": "数値", "array": "配列", "required": "必須", "default:": "デフォルト:", "choices:": "選択してください:", + "aliases:": "エイリアス:", "generated-value": "生成された値", "Not enough non-option arguments: got %s, need at least %s": "オプションではない引数が %s 個では不足しています。少なくとも %s 個の引数が必要です:", "Too many non-option arguments: got %s, maximum of %s": "オプションではない引数が %s 個では多すぎます。最大で %s 個までです:", @@ -32,5 +34,9 @@ "Invalid JSON config file: %s": "JSONの設定ファイルが不正です: %s", "Path to JSON config file": "JSONの設定ファイルまでのpath", "Show help": "ヘルプを表示", - "Show version number": "バージョンを表示" + "Show version number": "バージョンを表示", + "Did you mean %s?": "もしかして %s?", + "Arguments %s and %s are mutually exclusive" : "引数 %s と %s は同時に指定できません", + "Positionals:": "位置:", + "command": "コマンド" } diff --git a/node_modules/yargs/locales/ko.json b/node_modules/yargs/locales/ko.json index a16971a..0eaeab2 100644 --- a/node_modules/yargs/locales/ko.json +++ b/node_modules/yargs/locales/ko.json @@ -5,10 +5,12 @@ "boolean": "여부", "count": "개수", "string": "문자열", + "number": "숫자", "array": "배열", "required": "필수", "default:": "기본:", "choices:": "선택:", + "aliases:": "별칭:", "generated-value": "생성된 값", "Not enough non-option arguments: got %s, need at least %s": "옵션이 아닌 인자가 충분치 않습니다: %s개를 받았지만, 적어도 %s개는 필요합니다", "Too many non-option arguments: got %s, maximum of %s": "옵션이 아닌 인자가 너무 많습니다: %s개를 받았지만, %s개 이하여야 합니다", @@ -32,5 +34,9 @@ "Invalid JSON config file: %s": "유효하지 않은 JSON 설정파일입니다: %s", "Path to JSON config file": "JSON 설정파일 경로", "Show help": "도움말을 보여줍니다", - "Show version number": "버전 넘버를 보여줍니다" + "Show version number": "버전 넘버를 보여줍니다", + "Did you mean %s?": "찾고계신게 %s입니까?", + "Arguments %s and %s are mutually exclusive" : "%s와 %s 인자는 같이 사용될 수 없습니다", + "Positionals:": "위치:", + "command": "명령" } diff --git a/node_modules/yargs/locales/nb.json b/node_modules/yargs/locales/nb.json index 65fa6ae..55be1fb 100644 --- a/node_modules/yargs/locales/nb.json +++ b/node_modules/yargs/locales/nb.json @@ -5,6 +5,7 @@ "boolean": "boolsk", "count": "antall", "string": "streng", + "number": "nummer", "array": "matrise", "required": "obligatorisk", "default:": "standard:", @@ -26,7 +27,7 @@ }, "Invalid values:": "Ugyldige verdier:", "Argument: %s, Given: %s, Choices: %s": "Argument: %s, Gitt: %s, Valg: %s", - "Argument check failed: %s": "Argument sjekk mislyktes: %s", + "Argument check failed: %s": "Argumentsjekk mislyktes: %s", "Implications failed:": "Konsekvensene mislyktes:", "Not enough arguments following: %s": "Ikke nok følgende argumenter: %s", "Invalid JSON config file: %s": "Ugyldig JSON konfigurasjonsfil: %s", diff --git a/node_modules/yargs/locales/pirate.json b/node_modules/yargs/locales/pirate.json index 1f4e19e..dcb5cb7 100644 --- a/node_modules/yargs/locales/pirate.json +++ b/node_modules/yargs/locales/pirate.json @@ -8,5 +8,6 @@ "other": "Ye be havin' to set the followin' arguments land lubber: %s" }, "Show help": "Parlay this here code of conduct", - "Show version number": "'Tis the version ye be askin' fer" + "Show version number": "'Tis the version ye be askin' fer", + "Arguments %s and %s are mutually exclusive" : "Yon scurvy dogs %s and %s be as bad as rum and a prudish wench" } diff --git a/node_modules/yargs/locales/pl.json b/node_modules/yargs/locales/pl.json index 7d4c5be..6926a45 100644 --- a/node_modules/yargs/locales/pl.json +++ b/node_modules/yargs/locales/pl.json @@ -5,10 +5,12 @@ "boolean": "boolean", "count": "ilość", "string": "ciąg znaków", + "number": "liczba", "array": "tablica", "required": "wymagany", "default:": "domyślny:", "choices:": "dostępne:", + "aliases:": "aliasy:", "generated-value": "wygenerowana-wartość", "Not enough non-option arguments: got %s, need at least %s": "Niewystarczająca ilość argumentów: otrzymano %s, wymagane co najmniej %s", "Too many non-option arguments: got %s, maximum of %s": "Zbyt duża ilość argumentów: otrzymano %s, wymagane co najwyżej %s", @@ -32,5 +34,9 @@ "Invalid JSON config file: %s": "Nieprawidłowy plik konfiguracyjny JSON: %s", "Path to JSON config file": "Ścieżka do pliku konfiguracyjnego JSON", "Show help": "Pokaż pomoc", - "Show version number": "Pokaż numer wersji" + "Show version number": "Pokaż numer wersji", + "Did you mean %s?": "Czy chodziło Ci o %s?", + "Arguments %s and %s are mutually exclusive": "Argumenty %s i %s wzajemnie się wykluczają", + "Positionals:": "Pozycyjne:", + "command": "polecenie" } diff --git a/node_modules/yargs/locales/pt.json b/node_modules/yargs/locales/pt.json index 6abbcd4..75c3921 100644 --- a/node_modules/yargs/locales/pt.json +++ b/node_modules/yargs/locales/pt.json @@ -5,6 +5,7 @@ "boolean": "boolean", "count": "contagem", "string": "cadeia de caracteres", + "number": "número", "array": "arranjo", "required": "requerido", "default:": "padrão:", @@ -32,5 +33,6 @@ "Invalid JSON config file: %s": "Arquivo de configuração em JSON esta inválido: %s", "Path to JSON config file": "Caminho para o arquivo de configuração em JSON", "Show help": "Mostra ajuda", - "Show version number": "Mostra número de versão" + "Show version number": "Mostra número de versão", + "Arguments %s and %s are mutually exclusive" : "Argumentos %s e %s são mutualmente exclusivos" } diff --git a/node_modules/yargs/locales/pt_BR.json b/node_modules/yargs/locales/pt_BR.json index eb7544e..904cb66 100644 --- a/node_modules/yargs/locales/pt_BR.json +++ b/node_modules/yargs/locales/pt_BR.json @@ -2,13 +2,15 @@ "Commands:": "Comandos:", "Options:": "Opções:", "Examples:": "Exemplos:", - "boolean": "boolean", + "boolean": "booleano", "count": "contagem", "string": "string", + "number": "número", "array": "array", "required": "obrigatório", "default:": "padrão:", "choices:": "opções:", + "aliases:": "sinônimos:", "generated-value": "valor-gerado", "Not enough non-option arguments: got %s, need at least %s": "Argumentos insuficientes: Argumento %s, necessário pelo menos %s", "Too many non-option arguments: got %s, maximum of %s": "Excesso de argumentos: recebido %s, máximo de %s", @@ -32,5 +34,9 @@ "Invalid JSON config file: %s": "Arquivo JSON de configuração inválido: %s", "Path to JSON config file": "Caminho para o arquivo JSON de configuração", "Show help": "Exibe ajuda", - "Show version number": "Exibe a versão" + "Show version number": "Exibe a versão", + "Did you mean %s?": "Você quis dizer %s?", + "Arguments %s and %s are mutually exclusive" : "Argumentos %s e %s são mutualmente exclusivos", + "Positionals:": "Posicionais:", + "command": "comando" } diff --git a/node_modules/yargs/locales/tr.json b/node_modules/yargs/locales/tr.json index cef09d2..9b06c52 100644 --- a/node_modules/yargs/locales/tr.json +++ b/node_modules/yargs/locales/tr.json @@ -5,10 +5,12 @@ "boolean": "boolean", "count": "sayı", "string": "string", + "number": "numara", "array": "array", "required": "zorunlu", "default:": "varsayılan:", "choices:": "seçimler:", + "aliases:": "takma adlar:", "generated-value": "oluşturulan-değer", "Not enough non-option arguments: got %s, need at least %s": "Seçenek dışı argümanlar yetersiz: %s bulundu, %s gerekli", "Too many non-option arguments: got %s, maximum of %s": "Seçenek dışı argümanlar gereğinden fazla: %s bulundu, azami %s", @@ -32,5 +34,8 @@ "Invalid JSON config file: %s": "Geçersiz JSON yapılandırma dosyası: %s", "Path to JSON config file": "JSON yapılandırma dosya konumu", "Show help": "Yardım detaylarını göster", - "Show version number": "Versiyon detaylarını göster" + "Show version number": "Versiyon detaylarını göster", + "Did you mean %s?": "Bunu mu demek istediniz: %s?", + "Positionals:": "Sıralılar:", + "command": "komut" } diff --git a/node_modules/yargs/locales/zh.json b/node_modules/yargs/locales/zh.json deleted file mode 100644 index 7b01d71..0000000 --- a/node_modules/yargs/locales/zh.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "Commands:": "命令:", - "Options:": "选项:", - "Examples:": "示例:", - "boolean": "boolean", - "count": "count", - "string": "string", - "array": "array", - "required": "required", - "default:": "默认值:", - "choices:": "可选值:", - "generated-value": "生成的值", - "Not enough non-option arguments: got %s, need at least %s": "缺少 non-option 参数:传入了 %s 个, 至少需要 %s 个", - "Too many non-option arguments: got %s, maximum of %s": "non-option 参数过多:传入了 %s 个, 最大允许 %s 个", - "Missing argument value: %s": { - "one": "没有给此选项指定值:%s", - "other": "没有给这些选项指定值:%s" - }, - "Missing required argument: %s": { - "one": "缺少必须的选项:%s", - "other": "缺少这些必须的选项:%s" - }, - "Unknown argument: %s": { - "one": "无法识别的选项:%s", - "other": "无法识别这些选项:%s" - }, - "Invalid values:": "无效的选项值:", - "Argument: %s, Given: %s, Choices: %s": "选项名称: %s, 传入的值: %s, 可选的值:%s", - "Argument check failed: %s": "选项值验证失败:%s", - "Implications failed:": "缺少依赖的选项:", - "Not enough arguments following: %s": "没有提供足够的值给此选项:%s", - "Invalid JSON config file: %s": "无效的 JSON 配置文件:%s", - "Path to JSON config file": "JSON 配置文件的路径", - "Show help": "显示帮助信息", - "Show version number": "显示版本号" -} diff --git a/node_modules/yargs/package.json b/node_modules/yargs/package.json index 807e071..ecfeca9 100644 --- a/node_modules/yargs/package.json +++ b/node_modules/yargs/package.json @@ -1,103 +1,82 @@ { - "_from": "yargs@^3.10.0", - "_id": "yargs@3.32.0", + "_from": "yargs", + "_id": "yargs@14.2.0", "_inBundle": false, - "_integrity": "sha1-AwiOnr+edWtpdRYR0qXvWRSCyZU=", + "_integrity": "sha512-/is78VKbKs70bVZH7w4YaZea6xcJWOAwkhbR0CFuZBmYtfTYF0xjGJF43AYd8g2Uii1yJwmS5GR2vBmrc32sbg==", "_location": "/yargs", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "tag", "registry": true, - "raw": "yargs@^3.10.0", + "raw": "yargs", "name": "yargs", "escapedName": "yargs", - "rawSpec": "^3.10.0", + "rawSpec": "", "saveSpec": null, - "fetchSpec": "^3.10.0" + "fetchSpec": "latest" }, "_requiredBy": [ - "/protobufjs" + "#USER", + "/" ], - "_resolved": "https://registry.npmjs.org/yargs/-/yargs-3.32.0.tgz", - "_shasum": "03088e9ebf9e756b69751611d2a5ef591482c995", - "_spec": "yargs@^3.10.0", - "_where": "/home/sergiu/linx-audio-simulator/node_modules/protobufjs", - "author": { - "name": "Alex Ford", - "email": "Alex.Ford@CodeTunnel.com", - "url": "http://CodeTunnel.com" - }, + "_resolved": "https://registry.npmjs.org/yargs/-/yargs-14.2.0.tgz", + "_shasum": "f116a9242c4ed8668790b40759b4906c276e76c3", + "_spec": "yargs", + "_where": "/home/sergiu/linx-simulator2", "bugs": { - "url": "https://github.com/bcoe/yargs/issues" + "url": "https://github.com/yargs/yargs/issues" }, "bundleDependencies": false, "contributors": [ { - "name": "Benjamin Coe", - "email": "ben@npmjs.com", - "url": "https://github.com/bcoe" - }, - { - "name": "Andrew Goode", - "url": "https://github.com/nexdrew" - }, - { - "name": "Chris Needham", - "email": "chris@chrisneedham.com", - "url": "http://chrisneedham.com" - }, - { - "name": "James Nylen", - "email": "jnylen@gmail.com", - "url": "https://github.com/nylen" - }, - { - "name": "Benjamin Horsleben", - "url": "https://github.com/fizker" - }, - { - "name": "Lin Clark", - "url": "https://github.com/linclark" - }, - { - "name": "Tim Schaub", - "url": "https://github.com/tschaub" + "name": "Yargs Contributors", + "url": "https://github.com/yargs/yargs/graphs/contributors" } ], "dependencies": { - "camelcase": "^2.0.1", - "cliui": "^3.0.3", - "decamelize": "^1.1.1", - "os-locale": "^1.4.0", - "string-width": "^1.0.1", - "window-size": "^0.1.4", - "y18n": "^3.2.0" + "cliui": "^5.0.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^15.0.0" }, "deprecated": false, - "description": "Light-weight option parsing with an argv hash. No optstrings attached.", + "description": "yargs the modern, pirate-themed, successor to optimist.", "devDependencies": { - "chai": "^3.4.1", - "chalk": "^1.1.1", - "coveralls": "^2.11.4", - "es6-promise": "^3.0.2", + "chai": "^4.2.0", + "chalk": "^2.4.2", + "coveralls": "^3.0.3", + "cpr": "^3.0.1", + "cross-spawn": "^6.0.4", + "es6-promise": "^4.2.5", "hashish": "0.0.4", - "mocha": "^2.3.4", - "nyc": "^5.2.0", - "standard": "^5.4.1", - "which": "^1.1.2", - "win-spawn": "^2.0.0" + "mocha": "^5.2.0", + "nyc": "^14.1.0", + "rimraf": "^2.6.3", + "standard": "^12.0.1", + "standard-version": "^7.0.0", + "which": "^1.3.1", + "yargs-test-extends": "^1.0.1" }, "engine": { - "node": ">=0.10" + "node": ">=6" }, "files": [ "index.js", + "yargs.js", "lib", "locales", "completion.sh.hbs", + "completion.zsh.hbs", "LICENSE" ], - "homepage": "https://github.com/bcoe/yargs#readme", + "homepage": "https://yargs.js.org/", "keywords": [ "argument", "args", @@ -112,20 +91,18 @@ "name": "yargs", "repository": { "type": "git", - "url": "git+ssh://git@github.com/bcoe/yargs.git" + "url": "git+https://github.com/yargs/yargs.git" }, "scripts": { "coverage": "nyc report --reporter=text-lcov | coveralls", "pretest": "standard", - "test": "nyc --cache mocha --timeout=4000 --check-leaks" + "release": "standard-version", + "test": "nyc --cache mocha --require ./test/before.js --timeout=12000 --check-leaks" }, "standard": { "ignore": [ "**/example/**" - ], - "globals": [ - "it" ] }, - "version": "3.32.0" + "version": "14.2.0" } diff --git a/package-lock.json b/package-lock.json index e74d91b..c1e4139 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,9 +21,9 @@ } }, "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" }, "ansi-styles": { "version": "3.2.1", @@ -187,9 +187,9 @@ "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=" }, "camelcase": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", - "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=" + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" }, "caseless": { "version": "0.12.0", @@ -207,13 +207,13 @@ } }, "cliui": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", - "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wrap-ansi": "^2.0.0" + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" } }, "code-point-at": { @@ -328,6 +328,11 @@ "safer-buffer": "^2.1.0" } }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==" + }, "engine.io-client": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.3.2.tgz", @@ -398,6 +403,14 @@ "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "requires": { + "locate-path": "^3.0.0" + } + }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -418,6 +431,11 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" + }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -513,12 +531,9 @@ "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" }, "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "requires": { - "number-is-nan": "^1.0.0" - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" }, "is-typedarray": { "version": "1.0.0", @@ -611,6 +626,15 @@ "resolved": "https://registry.npmjs.org/limiter/-/limiter-1.1.4.tgz", "integrity": "sha512-XCpr5bElgDI65vVgstP8TWjv6/QKWm9GU5UG0Pr5sLQ3QLo8NVKsioe+Jed5/3vFOe3IQuqE7DKwTvKQkjTHvg==" }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", @@ -757,6 +781,27 @@ "lcid": "^1.0.0" } }, + "p-limit": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", + "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" + }, "parseqs": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", @@ -773,6 +818,11 @@ "better-assert": "~1.0.0" } }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -810,6 +860,82 @@ "bytebuffer": "~5", "glob": "^7.0.5", "yargs": "^3.10.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "camelcase": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", + "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=" + }, + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wrap-ansi": "^2.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + } + }, + "y18n": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" + }, + "yargs": { + "version": "3.32.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.32.0.tgz", + "integrity": "sha1-AwiOnr+edWtpdRYR0qXvWRSCyZU=", + "requires": { + "camelcase": "^2.0.1", + "cliui": "^3.0.3", + "decamelize": "^1.1.1", + "os-locale": "^1.4.0", + "string-width": "^1.0.1", + "window-size": "^0.1.4", + "y18n": "^3.2.0" + } + } } }, "psl": { @@ -921,6 +1047,16 @@ "uuid": "^3.3.2" } }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==" + }, "rtimer": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/rtimer/-/rtimer-0.1.0.tgz", @@ -936,6 +1072,11 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, "socket.io-client": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.2.0.tgz", @@ -1096,13 +1237,13 @@ } }, "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" } }, "string_decoder": { @@ -1111,11 +1252,11 @@ "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" }, "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "^4.1.0" } }, "supports-color": { @@ -1236,18 +1377,24 @@ "extsprintf": "^1.2.0" } }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" + }, "window-size": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.4.tgz", "integrity": "sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY=" }, "wrap-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", - "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" } }, "wrappy": { @@ -1274,22 +1421,35 @@ "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" }, "y18n": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", - "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==" }, "yargs": { - "version": "3.32.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.32.0.tgz", - "integrity": "sha1-AwiOnr+edWtpdRYR0qXvWRSCyZU=", + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-14.2.0.tgz", + "integrity": "sha512-/is78VKbKs70bVZH7w4YaZea6xcJWOAwkhbR0CFuZBmYtfTYF0xjGJF43AYd8g2Uii1yJwmS5GR2vBmrc32sbg==", "requires": { - "camelcase": "^2.0.1", - "cliui": "^3.0.3", - "decamelize": "^1.1.1", - "os-locale": "^1.4.0", - "string-width": "^1.0.1", - "window-size": "^0.1.4", - "y18n": "^3.2.0" + "cliui": "^5.0.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^15.0.0" + } + }, + "yargs-parser": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-15.0.0.tgz", + "integrity": "sha512-xLTUnCMc4JhxrPEPUYD5IBR1mWCK/aT6+RJ/K29JY2y1vD+FhtgKK0AXRWvI262q3QSffAQuTouFIKUuHX89wQ==", + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" } }, "yeast": { diff --git a/package.json b/package.json index 15d7a50..90b0edd 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "speaker": "^0.4.1", "stream-chunker": "^1.2.8", "stream-throttle": "^0.1.3", - "toml": "^2.3.3" + "toml": "^2.3.3", + "yargs": "^14.2.0" } } diff --git a/src/mumble.js b/src/mumble.js index 9906f4c..83a94fd 100644 --- a/src/mumble.js +++ b/src/mumble.js @@ -106,6 +106,7 @@ class Mumble { // delay = delay used before reconnect console.log('------ Server reconnect...'); utils.writeErrorLog(`ERROR_MUMBLE_RECONNECT`); + // utils.exitWriteErrorLog(`ERROR_MUMBLE_RECONNECT`); }) .on('disconnect', function (err) { // err = possible error diff --git a/src/simulator.js b/src/simulator.js index 270080c..600ccfd 100644 --- a/src/simulator.js +++ b/src/simulator.js @@ -46,6 +46,7 @@ class Simulator { } fs.openSync('./logs/simulator.log', 'w'); utils.writeLog('START'); + utils.writeLog(`process.env["NODE_CONFIG_DIR"]: ${process.env["NODE_CONFIG_DIR"]}`); fs.openSync('./logs/error.log', 'w'); }); diff --git a/src/utils.js b/src/utils.js index 53dfbff..9b0caca 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,8 +1,9 @@ +const config = require('config'); const fs = require('fs'); const moment = require('moment'); -const config = require('config'); let current_error_count = 0; +let count_mumble_reconnect = 0; let max_fails = config.settings.max_fails; module.exports.writeLog = async (value) => { @@ -21,7 +22,7 @@ module.exports.writeErrorLog = async (value) => { await fs.writeFile('./logs/error.log', `[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${value} [${current_error_count}]\n`, {'flag':'a'}, (err) => { if (err) { reject(err); } - else { + else { if(current_error_count >= max_fails) { process.exit(0); } @@ -29,4 +30,19 @@ module.exports.writeErrorLog = async (value) => { } }); }); +} + +module.exports.exitWriteErrorLog = async (value) => { + return new Promise(async (resolve, reject) => { + console.log(`ERROR: ${value}`); + await fs.writeFile('./logs/error.log', `[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${value}\n`, {'flag':'a'}, (err) => { + if (err) { reject(err); } + else { + if(count_mumble_reconnect >= max_fails) { + process.exit(0); + } + resolve(); + } + }); + }); } \ No newline at end of file