@bring-it/cli
Version:
Common command line interface of 'bring-it'
2 lines • 4.69 kB
JavaScript
import{readFileSync as e}from"fs";import{default as t}from"yargs";import{join as r}from"path";import{fileURLToPath as o}from"url";var i,n,a,s,c,m,p,d={},h={};function l(e){var t=h[e];if(void 0!==t)return t.exports;var r=h[e]={exports:{}};return d[e](r,r.exports,l),r.exports}l.m=d,i="function"==typeof Symbol,n=i?Symbol("webpack queues"):"__webpack_queues__",a=i?Symbol("webpack exports"):"__webpack_exports__",s=i?Symbol("webpack error"):"__webpack_error__",c=e=>{e&&e.d<1&&(e.d=1,e.forEach(e=>e.r--),e.forEach(e=>e.r--?e.r++:e()))},l.a=(e,t,r)=>{var o;r&&((o=[]).d=-1);var i,m,p,d=new Set,h=e.exports,l=new Promise((e,t)=>{p=t,m=e});l[a]=h,l[n]=e=>(o&&e(o),d.forEach(e),l.catch(e=>{})),e.exports=l,t(e=>{var t;i=(e=>e.map(e=>{if(null!==e&&"object"==typeof e){if(e[n])return e;if(e.then){var t=[];t.d=0,e.then(e=>{r[a]=e,c(t)},e=>{r[s]=e,c(t)});var r={};return r[n]=e=>e(t),r}}var o={};return o[n]=e=>{},o[a]=e,o}))(e);var r=()=>i.map(e=>{if(e[s])throw e[s];return e[a]}),m=new Promise(e=>{(t=()=>e(r)).r=0;var a=e=>e!==o&&!d.has(e)&&(d.add(e),e&&!e.d&&(t.r++,e.push(t)));i.map(e=>e[n](a))});return t.r?m:r()},e=>(e?p(l[s]=e):m(h),c(o))),o&&o.d<0&&(o.d=0)},l.d=(e,t)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce((t,r)=>(l.f[r](e,t),t),[])),l.u=e=>e+".mjs",l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},m={27:0},p=e=>{var t,r,{__webpack_esm_ids__:o,__webpack_esm_modules__:i,__webpack_esm_runtime__:n}=e,a=0;for(t in i)l.o(i,t)&&(l.m[t]=i[t]);for(n&&n(l);a<o.length;a++)r=o[a],l.o(m,r)&&m[r]&&m[r][0](),m[o[a]]=0},l.f.j=(e,t)=>{var r=l.o(m,e)?m[e]:void 0;if(0!==r)if(r)t.push(r[1]);else{var o=import("./"+l.u(e)).then(p,t=>{throw 0!==m[e]&&(m[e]=void 0),t});o=Promise.race([o,new Promise(t=>r=m[e]=[t])]),t.push(r[1]=o)}};var u={};function f(e,t){const o=e.startsWith(".")?r(t,e):e;return import(o)}l.r(u),l.d(u,{builder:()=>_,command:()=>g,describe:()=>b,handler:()=>y});const g="pack [pattern...]",b="Pack files when support";function _(e){e.positional("pattern",{description:"glob pattern of files or directories"}).options({name:{alias:"n",description:"archive output file name",default:"pack"},dir:{alias:"d",description:"archive output path name",default:".bring-it"},cwd:{alias:"c",description:"current working directory",default:process.cwd()},ignore:{alias:"i",description:"default ignore pattern",type:"boolean",default:!0}})}function y(e){l.e(473).then(l.bind(l,473)).then(({action:t})=>t(e)).catch(console.error)}new class{constructor(r,o){this.root=o;const{bin:i,homepage:n,name:a="cheetor",repository:{url:s=""}={},version:c}="string"==typeof r?JSON.parse(e(new URL(r,o))):r;this.homepage=n,this.repository=s.includes("github.com")?s.replace(/\.git$/,""):"";const m=t(process.argv.slice(2)).strict().alias("help","h").alias("version","v").hide("help").version(c).hide("version").detectLocale(!1),p=function(e,t){if("string"==typeof e||!e)return t;const r=Object.keys(e);return 1===r.length&&r[0]}(i,a);p&&m.scriptName(p),this.cli=Promise.resolve(m)}config(e){return this.cli=this.cli.then(e),this}command(...e){return this.cli=this.cli.then(t=>t.command(...e)),this}commandFrom(e){return this.cli=this.cli.then(async t=>{const r=await f(e,this.root);return t.command(r)}),this}commandSafe(e){return this.cli=this.cli.then(t=>function(e,t){return f(e,t).catch(e=>{if("ERR_MODULE_NOT_FOUND"===e.code&&e.message.endsWith(` imported from ${o(import.meta.url)}`))return!1;throw e})}(e,this.root).then(e=>e&&e.command?t.command(e):t)),this}commandSmart(e){return this.cli=this.cli.then(async t=>{const r=e();return r&&r.command?t.command(r):t}),this}website(e){return this.site=e,this}middleware(...e){return this.cli=this.cli.then(t=>t.middleware(...e)),this}setup(e){return this.cli.then(e=>function(e,t){const{homepage:r,site:o=r,repository:i}=t,n=o&&o!==i,a=e.getInternalMethods(),s=(c=a.getCommandInstance().handlers,Object.keys(c).some(e=>e&&"$0"!==e));var c;return 0===a.getUsageInstance().getUsage().length&&(s?e.usage("Usage: $0 <command>"):e.usage("Usage: $0")),s&&e.demandCommand(1,"Won't work without a command"),n&&e.epilogue(`Website: ${o}`),i&&e.epilogue(`Repository: ${i}`),e}(e,this)).then(t=>"function"==typeof e?e(t.parse()):t.parse())}}("../package.json",import.meta.url).command(u).commandSafe("@bring-it/notify").commandSafe("@bring-it/npm").commandSafe("@bring-it/sample").commandSafe("@bring-it/sentry").commandSafe("@bring-it/sftp").config(e=>e.wrap(null)).setup();