-
-
Save maxam2017/e6e1cdfcea220741a15daa6cc8a98cdb to your computer and use it in GitHub Desktop.
pre-built script for maxam2017/dev-setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dev-setup | |
Setup dev env by some scripts | |
> This product is for personal use, I'm not responsible for any problems. | |
## Usage | |
Ensure you have [Node.js](https://nodejs.org) version 14.8.0+ installed. Then run the following: | |
```bash | |
$ npx https://gist.github.com/maxam2017/e6e1cdfcea220741a15daa6cc8a98cdb | |
``` | |
## FAQ | |
1. why just use `npx github:[user]/[repository]`? | |
It doesn't work on my device. Still find the root cause... | |
## License | |
Distributed under the [MIT License](https://choosealicense.com/licenses/mit/). See `license` for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
import{$ as e,chalk as t}from"zx"; | |
/*! ***************************************************************************** | |
Copyright (c) Microsoft Corporation. | |
Permission to use, copy, modify, and/or distribute this software for any | |
purpose with or without fee is hereby granted. | |
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | |
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | |
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | |
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | |
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | |
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | |
PERFORMANCE OF THIS SOFTWARE. | |
***************************************************************************** */function n(e,t,n,s){return new(n||(n=Promise))((function(r,c){function i(e){try{o(s.next(e))}catch(e){c(e)}}function a(e){try{o(s.throw(e))}catch(e){c(e)}}function o(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}o((s=s.apply(e,t||[])).next())}))}function s(e,t){var n,s,r,c,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return c={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function a(c){return function(a){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,s&&(r=2&c[0]?s.return:c[0]?s.throw||((r=s.return)&&r.call(s),0):s.next)&&!(r=r.call(s,c[1])).done)return r;switch(s=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,s=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){i.label=c[1];break}if(6===c[0]&&i.label<r[1]){i.label=r[1],r=c;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(c);break}r[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],s=0}finally{n=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}function r(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function c(){return n(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,e(i||(i=r(["brew -v"],["brew -v"]))).exitCode];case 1:return 0===t.sent()?[3,3]:[4,e(a||(a=r(["curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | bash /dev/stdin -c"],["curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | bash /dev/stdin -c"])))];case 2:t.sent(),t.label=3;case 3:return[4,e(o||(o=r(["brew install fish"],["brew install fish"])))];case 4:return t.sent(),[4,e(u||(u=r(["curl -L https://get.oh-my.fish | fish"],["curl -L https://get.oh-my.fish | fish"])))];case 5:return t.sent(),e(l||(l=r(["omf install spacefish"],["omf install spacefish"]))),[4,e(h||(h=r(["curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher"],["curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher"])))];case 6:return t.sent(),e(f||(f=r(["fisher install jorgebucaran/nvm.fish"],["fisher install jorgebucaran/nvm.fish"]))),[4,e(b||(b=r(["fish"],["fish"])))];case 7:return t.sent(),[2]}}))}))}var i,a,o,u,l,h,f,b,g,d,p,v,w,m,y,_,x,k,E,S,C,L,j,H,A=function(){return n(void 0,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,e(g||(g=r(["which fish"],["which fish"])))];case 1:return 0!==(t=n.sent()).exitCode&&(e.shell=t.toString(),e.quote=function(e){return/^[a-z0-9_.-/]+$/i.test(e)?e:e.replace(/\\/g,"\\\\").replace(/\f/g,"\\f").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/\0/g,"\\0")}),[2,e]}}))}))},G=function(t,n){void 0===t&&(t=""),void 0===n&&(n="");var s="osascript -e 'display notification \""+n+'" with title "'+t+"\"'";return e(d||(d=r(["",""],["",""])),s)},D="]",O="",N=";";function T(){return n(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,A()];case 1:return[4,(e=t.sent())(p||(p=r(["curl https://sdk.cloud.google.com | bash"],["curl https://sdk.cloud.google.com | bash"])))];case 2:t.sent(),t.label=3;case 3:return[4,e(v||(v=r(["gcloud auth login"],["gcloud auth login"])))];case 4:return 0===t.sent().exitCode?[3,5]:[3,3];case 5:return G("🔥 Google Cloud Login Successfully!","You are now authenticated with the Google Cloud SDK!"),e(w||(w=r(["gcloud config set project ",""],["gcloud config set project ",""])),process.env.GCLOUD_PORJECT_NAME),[4,e(m||(m=r(["gcloud components install kubectl"],["gcloud components install kubectl"])))];case 6:return t.sent(),[4,e(y||(y=r(["gcloud container clusters get-credentials "," --zone asia-east1-a --project ",""],["gcloud container clusters get-credentials "," --zone asia-east1-a --project ",""])),process.env.GCLOUD_CLUSTER_NAME,process.env.GCLOUD_PORJECT_NAME)];case 7:return t.sent(),[4,e(_||(_=r(["brew -v"],["brew -v"]))).exitCode];case 8:return 0===t.sent()?[3,10]:[4,e(x||(x=r(["curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | bash /dev/stdin -c"],["curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | bash /dev/stdin -c"])))];case 9:t.sent(),t.label=10;case 10:return[4,e(k||(k=r(["brew install kubectx"],["brew install kubectx"])))];case 11:return t.sent(),[2]}}))}))}function U(){return n(this,void 0,void 0,(function(){var e,n,c,i,a;return s(this,(function(s){switch(s.label){case 0:return[4,A()];case 1:return[4,(e=s.sent())(E||(E=r(["cat ~/.ssh/id_rsa.pub"],["cat ~/.ssh/id_rsa.pub"]))).exitCode];case 2:return 0===s.sent()?[3,4]:[4,e(S||(S=r(["ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa <<<y >/dev/null 2>&1"],["ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa <<<y >/dev/null 2>&1"])))];case 3:s.sent(),s.label=4;case 4:return n="Copy below public key and paste into "+t.hex("#006aa6")([D,"8",N,N,"https://github.com/settings/ssh/new",O,"GitHub SSH keys Setting",D,"8",N,N,O].join("")),a=(i=t).cyan,[4,e(C||(C=r(["cat ~/.ssh/id_rsa.pub"],["cat ~/.ssh/id_rsa.pub"])))];case 5:return c=a.apply(i,[s.sent()]),console.log(n+"\n"+c),[2]}}))}))}function M(){return n(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(s){switch(s.label){case 0:return[4,A()];case 1:return e=s.sent(),[4,fetch("https://gist.githubusercontent.com/maxam2017/e519284bd4bf5f941ad4679b8cf34499/raw/afd89bc8885ca6fe147b0b2587c46cd6628274e9/.gitconfig")];case 2:return(t=s.sent()).ok?[4,t.text()]:[3,5];case 3:return n=s.sent(),[4,e(L||(L=r(["echo "," > ~/.gitconfig"],["echo "," > ~/.gitconfig"])),n)];case 4:s.sent(),s.label=5;case 5:return e(j||(j=r(['git config --global user.name "','"'],['git config --global user.name "','"'])),process.env.GIT_USER_NAME),e(H||(H=r(['git config --global user.email "','"'],['git config --global user.email "','"'])),process.env.GIT_USER_EMAIL),[2]}}))}))}!function(){n(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,c()];case 1:return e.sent(),[4,T()];case 2:return e.sent(),[4,U()];case 3:return e.sent(),[4,M()];case 4:return e.sent(),[2]}}))}))}(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "@maxam2017/dev-setup", | |
"version": "1.1.1", | |
"description": "a simple env setup script", | |
"type": "module", | |
"bin": "./index.js", | |
"dependencies": { | |
"zx": "^2.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment