builder.io 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -55,7 +55,7 @@ ${C.default.cyan(B2)}
|
|
|
55
55
|
`)}
|
|
56
56
|
`)},info:t=>{Ze.message(t,{symbol:C.default.blue(kl)})},success:t=>{Ze.message(t,{symbol:C.default.green(Ml)})},step:t=>{Ze.message(t,{symbol:C.default.green(on)})},warn:t=>{Ze.message(t,{symbol:C.default.yellow(Ul)})},warning:t=>{Ze.warn(t)},error:t=>{Ze.message(t,{symbol:C.default.red(Vl)})}},P2=()=>{let t=sn?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],e=sn?80:120,a,i,p=!1,r="",n=(u="")=>{p=!0,a=R2(),r=u.replace(/\.+$/,""),process.stdout.write(`${C.default.gray(Ve)}
|
|
57
57
|
`);let l=0,m=0;i=setInterval(()=>{let c=C.default.magenta(t[l]),h=".".repeat(Math.floor(m)).slice(0,3);process.stdout.write(r1.cursor.move(-999,0)),process.stdout.write(r1.erase.down(1)),process.stdout.write(`${c} ${r}${h}`),l=l+1<t.length?l+1:0,m=m<t.length?m+.125:0},e)},s=(u="",l=0)=>{r=u??r,p=!1,clearInterval(i);let m=l===0?C.default.green(on):l===1?C.default.red(O2):C.default.red(x2);process.stdout.write(r1.cursor.move(-999,0)),process.stdout.write(r1.erase.down(1)),process.stdout.write(`${m} ${r}
|
|
58
|
-
`),a()},d=(u="")=>{r=u??r},o=u=>{let l=u>1?"Something went wrong":"Canceled";p&&s(l,u)};return process.on("uncaughtExceptionMonitor",()=>o(2)),process.on("unhandledRejection",()=>o(2)),process.on("SIGINT",()=>o(1)),process.on("SIGTERM",()=>o(1)),process.on("exit",o),{start:n,stop:s,message:d}};var Qu=require("path"),zp=require("fs"),el=Ae(e2()),tl=Ae(require("prettier")),al=Ae(Zu());async function il(t){try{if(t.args[0]==="add"){let a=t.args[1],i=P2();i.start(`Fetching snippet ${a}`);let p=await nv(a);if(i.stop(`Fetched snippet ${a}`),!p)throw new Error(`No snippet found for id ${a}`);let{code:r}=p,
|
|
58
|
+
`),a()},d=(u="")=>{r=u??r},o=u=>{let l=u>1?"Something went wrong":"Canceled";p&&s(l,u)};return process.on("uncaughtExceptionMonitor",()=>o(2)),process.on("unhandledRejection",()=>o(2)),process.on("SIGINT",()=>o(1)),process.on("SIGTERM",()=>o(1)),process.on("exit",o),{start:n,stop:s,message:d}};var Qu=require("path"),zp=require("fs"),el=Ae(e2()),tl=Ae(require("prettier")),al=Ae(Zu());async function il(t){try{if(t.args[0]==="add"){let a=t.args[1],i=P2();i.start(`Fetching snippet ${a}`);let p=await nv(a);if(i.stop(`Fetched snippet ${a}`),!p)throw new Error(`No snippet found for id ${a}`);let{code:r,suggestedName:n}=p,s=tl.default.format(r,{parser:"typescript"}),d=t.args[2];d||(d=await I2({message:"Where should we copy the code?",initialValue:`./${n||"MyComponent"}.js`,validate(u){if(u.length===0)return"Value is required!";if(u[0]!==".")return"Please enter a relative path."}}),ii(d)&&process.exit(0));let o=(0,Qu.resolve)(process.cwd(),d);if((0,zp.existsSync)(o))throw new Error(`File already exists at ${o}`);Ze.info(`Writing to ${o}`),(0,zp.writeFileSync)(o,s)}}catch(e){el.captureException(e),Ze.error(String(e.message||e))}console.log("")}function nv(t){return(0,al.default)(`https://cdn.builder.io/api/v1/snippet/${t}`).then(e=>e.status===404?null:e.json())}function pl(t,e){let a={cwd:t,args:e},i=e.indexOf("-r");return i>-1&&(a.registryToImport=e[i+1]),a}var xt=Ae(e2());xt.init({dsn:"https://3252dddc08dbb5bf406dc33bf3c13633@o117565.ingest.sentry.io/4505630794448896",tracesSampleRate:1,integrations:[new xt.Integrations.Http({tracing:!0}),...xt.autoDiscoverNodePerformanceMonitoringIntegrations()]});var nl=()=>process.exit(0);process.on("SIGINT",nl);process.on("SIGTERM",nl);var rv=pl(process.cwd(),process.argv.slice(2));il(rv).catch(t=>{xt.captureException(t),console.error("\u274C",String(t.message||t),`
|
|
59
59
|
`),process.exit(1)});
|
|
60
60
|
/*! Bundled license information:
|
|
61
61
|
|