@bring-it/sftp
Version:
SFTP deployment tool for frontend
1 lines • 3.5 kB
JavaScript
export const __webpack_id__=93;export const __webpack_ids__=[93];export const __webpack_modules__={5605:(e,n,o)=>{o.d(n,{v:()=>s});const s=new(o(9790).Vy)("sftp")},7093:(e,n,o)=>{o.r(n),o.d(n,{action:()=>l});var s=o(6760),t=o(9969),i=o(5605),r=o(3024),c=o(2691),a=o(4816),d=o(1086);function _(e){throw new Error(`Error: ${e}`)}function u(e){e||_("<server> is missing");const{user:n,hostname:o,port:s=22,path:t="/mnt/.bring-it",cwd:i=process.cwd(),exclude:u,include:l}=c(/\S+@\S+/.test(e)&&URL.canParse(`sftp://${e}`)?function(e){try{const{username:n,hostname:o,port:s,pathname:t}=new URL(`sftp://${e}`);return!n||n.includes("%")?{}:c({user:n,hostname:o,port:s,path:t},e=>e)}catch{return{}}}(e):function(e){const n=function(){try{return(0,r.readFileSync)(d.I.conf,"utf8").trim()}catch{return""}}();let o;n||_(".ssh/config is not found");try{o=a.parse(n)}catch{_(".ssh/config is not valid")}o.find({Host:e})||_(`${e} is not found in .ssh/config`);const{user:s,User:t=s,hostname:i,Hostname:c=i,port:u,Port:l=u,path:p,Path:h=p,cwd:f,CWD:m=f,Cwd:C=m,include:v,Include:g=v,exclude:I,Exclude:E=I}=o.compute(e);return{hostname:c,port:l?Number.parseInt(l,10):void 0,user:t,path:h,cwd:C,include:g,exclude:E}}(e));return n||_("'User' is missing in config"),o||_("'Hostname' is missing in config"),{user:n,hostname:o,port:s,path:t,cwd:i,exclude:u,include:l}}async function l({key:e,server:n}){const{user:c,hostname:a,port:d,path:_,cwd:l,include:p="**",exclude:h="*.map"}=u(n),f=(0,t.A)((0,s.normalize)(_)),m=(0,t.A)((0,s.resolve)((0,s.normalize)(l)));if(C=m,(0,r.existsSync)(C)?0!==(0,r.readdirSync)(C).length||(i.v.fail((0,t.A)(C),"is empty"),process.exitCode=1,0):(i.v.fail((0,t.A)(C),"is not exists"),process.exitCode=1,0)){i.v.info("From:",m),i.v.info("To:",new URL(f,`sftp://${c}@${a}:${d}`).href),i.v.info("Include:",p),i.v.info("Exclude:",h);const n={hostname:a,port:d,user:c,key:e},{SSH:s}=await Promise.all([o.e(562),o.e(497)]).then(o.bind(o,7497)),{upload:t}=await o.e(154).then(o.bind(o,154));return s(n,e=>t(e,{CWD:m,path:f,include:p,exclude:h}))}var C}process.on("SIGINT",()=>{process.exit(1)})},9790:(e,n,o)=>{o.d(n,{Vy:()=>k,Xe:()=>H}),o(1455);var s=o(8127);const{CNB:t,CNB_BUILD_ID:i,CNB_BRANCH:r,CNB_COMMIT:c,CNB_COMMIT_SHORT:a,CNB_BEFORE_SHA:d,CNB_REPO_URL_HTTPS:_,CNB_DOCKER_REGISTRY:u,CNB_PIPELINE_NAME:l,CNB_REPO_SLUG_LOWERCASE:p,CNB_BUILD_WEB_URL:h}=process.env,{npm_package_version:f="\u672a\u77e5",CUSTOM_ARTIFACT_URL:m,BRANCH_NAME:C=(t?r:void 0),CCI_JOB_NAME:v=(t?l:void 0),CI_BUILD_NUMBER:g,DEPOT_NAME:I=(t?p:void 0),GIT_COMMIT_SHORT:E=(t?a:void 0),GIT_COMMIT:R=(t?c:void 0),GIT_PREVIOUS_COMMIT:T=(t?d:void 0),GIT_HTTP_URL:B=(t?_:void 0),JOB_ID:N=(t?i:void 0),PROJECT_WEB_URL:w=(t?`https://cnb.cool/${p}`:void 0),DOCKER_REG_HOST:O=(t?u:void 0)}=process.env;!function(e=""){e.slice(0,7)}(T);const{red:y,cyan:S,green:U,yellow:x,magenta:M}=s.Ay,A=U("[okay]"),L=y("[fail]"),P=x("[warn]");class k{constructor(e){this.name=`[${S("bring-it")}:${M(e)}]`}okay(...e){this.log(A,...e)}fail(...e){this.log(L,...e)}warn(...e){this.log(P,...e)}task(...e){this.log("[task]",...e)}file(...e){this.log("[file]",...e)}info(...e){this.log("[info]",...e)}json(e){this.log("[json]",JSON.stringify(e,"",2))}log(...e){console.log(this.name,...e)}}const H=["**/.{cache,git,svn,ssh,yarn}/**","**/.{npm,yarn}rc","**/.env.*","**/.env","**/.git{keep,ignore}","**/{node,web}_modules/**","**/*.{pem,ppk}","**/id_{d,r}sa","**/.obsidian/**","**/.docusaurus/**","**/miniprogram_npm/**","**/ssh*config","**/sshd*config"]}};