UNPKG

@bring-it/cli

Version:
2 lines 4.35 kB
#!/usr/bin/env node import*as e from"globby";import{createRequire as t}from"node:module";import*as r from"yargs";var o,i,n={373:(t,r,o)=>{var i,n;t.exports=(i={globbySync:()=>e.globbySync},n={},o.d(n,i),n)},421:e=>{e.exports=t(import.meta.url)("node:child_process")},24:e=>{e.exports=t(import.meta.url)("node:fs")},455:e=>{e.exports=t(import.meta.url)("node:fs/promises")},161:e=>{e.exports=t(import.meta.url)("node:os")},760:e=>{e.exports=t(import.meta.url)("node:path")},708:e=>{e.exports=t(import.meta.url)("node:process")},66:e=>{e.exports=t(import.meta.url)("node:tty")}},s={};function a(e){var t=s[e];if(void 0!==t)return t.exports;var r=s[e]={exports:{}};return n[e](r,r.exports,a),r.exports}a.m=n,a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((t,r)=>(a.f[r](e,t),t)),[])),a.u=e=>e+".mjs",a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o={27:0},i=e=>{var t,r,{__webpack_ids__:i,__webpack_modules__:n,__webpack_runtime__:s}=e,c=0;for(t in n)a.o(n,t)&&(a.m[t]=n[t]);for(s&&s(a);c<i.length;c++)r=i[c],a.o(o,r)&&o[r]&&o[r][0](),o[i[c]]=0},a.f.j=(e,t)=>{var r=a.o(o,e)?o[e]:void 0;if(0!==r)if(r)t.push(r[1]);else{var n=import("./"+a.u(e)).then(i,(t=>{throw 0!==o[e]&&(o[e]=void 0),t}));n=Promise.race([n,new Promise((t=>r=o[e]=[t]))]),t.push(r[1]=n)}};var c={};a.r(c),a.d(c,{builder:()=>y,command:()=>g,describe:()=>b,handler:()=>v});const m=t(import.meta.url)("fs"),p=(u={default:()=>r.default},h={},a.d(h,u),h),l=t(import.meta.url)("path"),d=t(import.meta.url)("url");var u,h;function f(e,t){const r=e.startsWith(".")?(0,l.join)(t,e):e;return import(r)}const g="pack [pattern...]",b="Pack files when support";function y(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()}})}function v(e){a.e(425).then(a.bind(a,425)).then((({action:t})=>t(e))).catch(console.error)}new class{constructor(e,t){this.root=t;const{bin:r,homepage:o,name:i="cheetor",repository:{url:n=""}={},version:s}="string"==typeof e?JSON.parse((0,m.readFileSync)(new URL(e,t))):e;this.homepage=o,this.repository=n.includes("github.com")?n.replace(/\.git$/,""):"";const a=(0,p.default)(process.argv.slice(2)).strict().alias("help","h").alias("version","v").hide("help").version(s).hide("version").detectLocale(!1),c=function(e,t){if("string"==typeof e||!e)return t;const r=Object.keys(e);return 1===r.length&&r[0]}(r,i);c&&a.scriptName(c),this.cli=Promise.resolve(a)}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 ${(0,d.fileURLToPath)(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,s=e.getInternalMethods(),a=(c=s.getCommandInstance().handlers,Object.keys(c).some((e=>e&&"$0"!==e)));var c;return 0===s.getUsageInstance().getUsage().length&&(a?e.usage("Usage: $0 <command>"):e.usage("Usage: $0")),a&&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(c).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();