builder.io 1.1.13-8 → 1.1.13-9

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/cli/index.cjs CHANGED
@@ -1184,11 +1184,11 @@ Migration is going to create new files, posibly duplicates.`);let c=await Zn({me
1184
1184
  })`}return Wt(`import { figmaMapping } from '@builder.io/dev-tools/figma';
1185
1185
  ${_7(e)}
1186
1186
 
1187
- ${i}`)}function _7(e){let{exportType:t,importName:n,importPath:r}=e;if(n&&r){let i=JSON.stringify(r);return t==="named"?`import { ${n} } from ${i};`:`import ${n} from ${i};`}return""}var Wn=G(Xn(),1);var nA=G(Ni(),1),rA=async(e,t,n)=>{if(n.help||n._[2]==="help"){rc(n._[1]);return}if(t==="migrate")await tA(e,n);else if(t==="publish"||t==="p")await eA(e,n);else if(t==="add"||t==="generate"||t==="gen"||t==="g")await VI(e,n);else if(t==="auth"){console.log(""),Ft((0,Wn.bgCyan)((0,Wn.bold)((0,Wn.white)(" figma auth "))));let{builderPublicKey:r}=await qr(e,n,{figmaAuth:!0,builderPrivateKey:!0,builderPublicKey:!0,force:!0});await qi(e,r,void 0),nA.track("figma auth",{spaceId:r}),Jt((0,Wn.bgGreen)((0,Wn.bold)((0,Wn.white)(" Done! \u{1F389} "))))}else t==="help"&&rc(n._[2])};var gn=G(To(),1),yd=G(Ni(),1);var ri=require("path"),At=require("fs");var Yt=require("fs/promises"),iA=require("crypto"),ni=require("fs"),Dd=require("os"),mn=G(require("path"),1),vb=G(require("prettier"),1),oA=G(require("typescript"),1),sA=G(require("launch-editor"),1);async function aA(e){let t=new Set,n=(...o)=>{if(process.env.DEBUG){let a=new Date,c=`${String(a.getMinutes()).padStart(2,"0")}:${String(a.getSeconds()).padStart(2,"0")}.${String(a.getMilliseconds()).padStart(3,"0")}`;console.debug(c,"[builder-dev-tools]",...o)}},r=async o=>{let a=(0,iA.createHash)("md5");return a.update(o),a.digest("hex")},i={...mn.default,getRootDir:()=>mn.default.normalize(e.getRootDir()),cwd:()=>process.cwd(),exists:async o=>{xr(e,o);try{return await(0,Yt.access)(o),!0}catch{return!1}},existsSync:o=>(xr(e,o),(0,ni.existsSync)(o)),readdir:async(o,a)=>{xr(e,o);let c=await(0,Yt.readdir)(o);return a?c.map(u=>mn.default.join(o,u)):c},readdirSync:o=>(xr(e,o),(0,ni.readdirSync)(o)),readFile:async o=>{xr(e,o);try{return await(0,Yt.readFile)(o,"utf-8")}catch(a){if(a.code==="ENOENT")return null;throw n(a,o),a}},readFileSync(o){xr(e,o);try{return(0,ni.readFileSync)(o,"utf-8")}catch(a){if(a.code==="ENOENT")return null;throw n(a,o),a}},stat:async o=>(xr(e,o),await(0,Yt.stat)(o)),statSync:o=>(xr(e,o),(0,ni.statSync)(o)),writeFile:async(o,a)=>{xr(e,o),o=mn.default.normalize(o);let c={path:o,basename:mn.default.basename(o),dirname:mn.default.dirname(o),extname:mn.default.extname(o)};await(0,Yt.mkdir)(mn.default.dirname(o),{recursive:!0}),await(0,Yt.writeFile)(o,a);for(let u of t)await u(c)},hash:r,getDeviceId:()=>r(`${(0,Dd.hostname)()}:${(0,Dd.homedir)()}`),formatCode:async(o,a)=>{let c=null;try{c=await vb.default.resolveConfig(o)}catch{}try{return vb.default.format(a,{...c,filepath:o})}catch{}return a},on:(o,a)=>{o==="change"&&t.add(a)},off:(o,a)=>{o==="change"&&t.delete(a)},debug:n,launchEditor:async o=>{try{let a=o.filePath;typeof o.line=="number"&&(a+=`:${o.line}`,typeof o.column=="number"&&(a+=`:${o.column}`)),(0,sA.default)(a,"code",(c,u)=>{console.error(`Failed to launch editor for ${c}`),u&&console.error(u)})}catch(a){console.error(`Failed to launch editor for ${String(a.message||a)}`)}},platform:()=>({runtime:"node",os:process.platform}),getFrameworks:()=>[],ts:oA.default,version:"1.1.12",sdkVersion:null,ignoreMissingConfig:e.ignoreMissingConfig},s=await Ii(i);return i.getFrameworks=()=>s,i}function xr(e,t){if(e.skipValidate)return;if(!t)throw new Error(`Invalid path: ${t} (7340)`);t=mn.default.normalize(mn.default.resolve(t));let n=e.getRootDir();if(!t.startsWith(n)&&!t.includes("node_modules"))throw new Error(`Invalid path: ${t} (7341)`)}var ts=G(Xn(),1);async function cA(e){console.log(""),Ft((0,ts.bgCyan)((0,ts.bold)((0,ts.white)(" add "))));let t=e.snippetId;t||(me("SnippetId expected. npx builder.io add <snippetId>"),process.exit(1));let n=ft();n.start(`Fetching snippet ${t}`);let r=await b7(t);if(n.stop(`Fetched snippet ${t}`),!r)throw new Error(`No snippet found for id ${t}`);if(r.files?.length>0){let i=T7(r.framework||"react"),s=e.path||await _n({message:"Where should we copy the files?",initialValue:i,validate(a){if(a.length===0)return"File path is required!";if(a[0]!==".")return"Please enter a relative path."}});$e(s)&&(me("Cancelled sync"),process.exit(0));let o=await lA(r.files,s);return z.success("All files have been written successfully."),{snippet:r,pathInput:s,writtenFiles:o,timeStamp:Date.now()}}else{let{code:i,suggestedName:s,framework:o}=r;if(o){if(o!=="html"&&!(0,At.existsSync)("./package.json"))throw new Error("No package.json found. Are you in the right directory?");s=await D7(o,i)}s??(s="./src/components/MyComponent.jsx");let a=uA(E7(r.code),r.framework);try{r.framework==="html"?a=await Wt(a,"html"):r.framework==="angular"?a=await Wt(a,"angular"):r.framework==="vue"?a=await Wt(a,"vue"):r.framework==="svelte"?a=await Wt(a,"html"):a=await Wt(a,"typescript")}catch{}let c=e.path;if(!c){try{let p=(await aA({getRootDir:()=>process.cwd()})).getFrameworks();if(p.length>0){let f;if(p.some(m=>m.name.includes("qwik"))?f="qwik":p.some(m=>m.name.includes("react"))?f="react":f=p[0].name,r.framework&&r.framework!==f){let m=await Zn({message:`This snippet is for ${r.framework}, but you are using ${f}. Continue?`,initialValue:!1});($e(m)||!m)&&(console.log("Please go back to builder and change the output framework to match your project."),console.log(),process.exit(0))}}}catch{}c=await _n({message:"Where should we copy the code?",initialValue:s?.startsWith("./")?s:`./${s}`,validate(d){if(d.length===0)return"File path is required!";if(d[0]!==".")return"Please enter a relative path."}}),$e(c)&&(console.log(""),process.exit(0))}let u=process.cwd(),l=(0,ri.resolve)(u,c);z.info(`Writing code to ${l}`),(0,At.mkdirSync)((0,ri.dirname)(l),{recursive:!0}),(0,At.writeFileSync)(l,a)}}function b7(e){return fetch(`https://cdn.builder.io/api/v1/snippet/${e}`).then(t=>t.status===404?null:t.json())}function E7(e){return e.replace(/^```jsx\s?|\s?```$/g,"").trim()}function uA(e,t){return t?["vue","html","svelte"].includes(t.toLowerCase())?`<!-- This code was generated by Builder.io -->
1187
+ ${i}`)}function _7(e){let{exportType:t,importName:n,importPath:r}=e;if(n&&r){let i=JSON.stringify(r);return t==="named"?`import { ${n} } from ${i};`:`import ${n} from ${i};`}return""}var Wn=G(Xn(),1);var nA=G(Ni(),1),rA=async(e,t,n)=>{if(n.help||n._[2]==="help"){rc(n._[1]);return}if(t==="migrate")await tA(e,n);else if(t==="publish"||t==="p")await eA(e,n);else if(t==="add"||t==="generate"||t==="gen"||t==="g")await VI(e,n);else if(t==="auth"){console.log(""),Ft((0,Wn.bgCyan)((0,Wn.bold)((0,Wn.white)(" figma auth "))));let{builderPublicKey:r}=await qr(e,n,{figmaAuth:!0,builderPrivateKey:!0,builderPublicKey:!0,force:!0});await qi(e,r,void 0),nA.track("figma auth",{spaceId:r}),Jt((0,Wn.bgGreen)((0,Wn.bold)((0,Wn.white)(" Done! \u{1F389} "))))}else t==="help"&&rc(n._[2])};var gn=G(To(),1),yd=G(Ni(),1);var ri=require("path"),At=require("fs");var Yt=require("fs/promises"),iA=require("crypto"),ni=require("fs"),Dd=require("os"),mn=G(require("path"),1),vb=G(require("prettier"),1),oA=G(require("typescript"),1),sA=G(require("launch-editor"),1);async function aA(e){let t=new Set,n=(...o)=>{if(process.env.DEBUG){let a=new Date,c=`${String(a.getMinutes()).padStart(2,"0")}:${String(a.getSeconds()).padStart(2,"0")}.${String(a.getMilliseconds()).padStart(3,"0")}`;console.debug(c,"[builder-dev-tools]",...o)}},r=async o=>{let a=(0,iA.createHash)("md5");return a.update(o),a.digest("hex")},i={...mn.default,getRootDir:()=>mn.default.normalize(e.getRootDir()),cwd:()=>process.cwd(),exists:async o=>{xr(e,o);try{return await(0,Yt.access)(o),!0}catch{return!1}},existsSync:o=>(xr(e,o),(0,ni.existsSync)(o)),readdir:async(o,a)=>{xr(e,o);let c=await(0,Yt.readdir)(o);return a?c.map(u=>mn.default.join(o,u)):c},readdirSync:o=>(xr(e,o),(0,ni.readdirSync)(o)),readFile:async o=>{xr(e,o);try{return await(0,Yt.readFile)(o,"utf-8")}catch(a){if(a.code==="ENOENT")return null;throw n(a,o),a}},readFileSync(o){xr(e,o);try{return(0,ni.readFileSync)(o,"utf-8")}catch(a){if(a.code==="ENOENT")return null;throw n(a,o),a}},stat:async o=>(xr(e,o),await(0,Yt.stat)(o)),statSync:o=>(xr(e,o),(0,ni.statSync)(o)),writeFile:async(o,a)=>{xr(e,o),o=mn.default.normalize(o);let c={path:o,basename:mn.default.basename(o),dirname:mn.default.dirname(o),extname:mn.default.extname(o)};await(0,Yt.mkdir)(mn.default.dirname(o),{recursive:!0}),await(0,Yt.writeFile)(o,a);for(let u of t)await u(c)},hash:r,getDeviceId:()=>r(`${(0,Dd.hostname)()}:${(0,Dd.homedir)()}`),formatCode:async(o,a)=>{let c=null;try{c=await vb.default.resolveConfig(o)}catch{}try{return vb.default.format(a,{...c,filepath:o})}catch{}return a},on:(o,a)=>{o==="change"&&t.add(a)},off:(o,a)=>{o==="change"&&t.delete(a)},debug:n,launchEditor:async o=>{try{let a=o.filePath;typeof o.line=="number"&&(a+=`:${o.line}`,typeof o.column=="number"&&(a+=`:${o.column}`)),(0,sA.default)(a,"code",(c,u)=>{console.error(`Failed to launch editor for ${c}`),u&&console.error(u)})}catch(a){console.error(`Failed to launch editor for ${String(a.message||a)}`)}},platform:()=>({runtime:"node",os:process.platform}),getFrameworks:()=>[],ts:oA.default,version:"1.1.12",sdkVersion:null,ignoreMissingConfig:e.ignoreMissingConfig},s=await Ii(i);return i.getFrameworks=()=>s,i}function xr(e,t){if(e.skipValidate)return;if(!t)throw new Error(`Invalid path: ${t} (7340)`);t=mn.default.normalize(mn.default.resolve(t));let n=e.getRootDir();if(!t.startsWith(n)&&!t.includes("node_modules"))throw new Error(`Invalid path: ${t} (7341)`)}var ts=G(Xn(),1);async function cA(e){console.log(""),Ft((0,ts.bgCyan)((0,ts.bold)((0,ts.white)(" add "))));let t=e.snippetId;t||(me("SnippetId expected. npx builder.io add <snippetId>"),process.exit(1));let n=ft();n.start(`Fetching snippet ${t}`);let r=e.snippet||await b7(t);if(n.stop(`Fetched snippet ${t}`),!r)throw new Error(`No snippet found for id ${t}`);if(r.files?.length>0){let i=T7(r.framework||"react"),s=e.path||await _n({message:"Where should we copy the files?",initialValue:i,validate(a){if(a.length===0)return"File path is required!";if(a[0]!==".")return"Please enter a relative path."}});$e(s)&&(me("Cancelled sync"),process.exit(0));let o=await lA(r.files,s);return z.success("All files have been written successfully."),{snippet:r,pathInput:s,writtenFiles:o,timeStamp:Date.now()}}else{let{code:i,suggestedName:s,framework:o}=r;if(o){if(o!=="html"&&!(0,At.existsSync)("./package.json"))throw new Error("No package.json found. Are you in the right directory?");s=await D7(o,i)}s??(s="./src/components/MyComponent.jsx");let a=uA(E7(r.code),r.framework);try{r.framework==="html"?a=await Wt(a,"html"):r.framework==="angular"?a=await Wt(a,"angular"):r.framework==="vue"?a=await Wt(a,"vue"):r.framework==="svelte"?a=await Wt(a,"html"):a=await Wt(a,"typescript")}catch{}let c=e.path;if(!c){try{let p=(await aA({getRootDir:()=>process.cwd()})).getFrameworks();if(p.length>0){let f;if(p.some(m=>m.name.includes("qwik"))?f="qwik":p.some(m=>m.name.includes("react"))?f="react":f=p[0].name,r.framework&&r.framework!==f){let m=await Zn({message:`This snippet is for ${r.framework}, but you are using ${f}. Continue?`,initialValue:!1});($e(m)||!m)&&(console.log("Please go back to builder and change the output framework to match your project."),console.log(),process.exit(0))}}}catch{}c=await _n({message:"Where should we copy the code?",initialValue:s?.startsWith("./")?s:`./${s}`,validate(d){if(d.length===0)return"File path is required!";if(d[0]!==".")return"Please enter a relative path."}}),$e(c)&&(console.log(""),process.exit(0))}let u=process.cwd(),l=(0,ri.resolve)(u,c);z.info(`Writing code to ${l}`),(0,At.mkdirSync)((0,ri.dirname)(l),{recursive:!0}),(0,At.writeFileSync)(l,a)}}function b7(e){return fetch(`https://cdn.builder.io/api/v1/snippet/${e}`).then(t=>t.status===404?null:t.json())}function E7(e){return e.replace(/^```jsx\s?|\s?```$/g,"").trim()}function uA(e,t){return t?["vue","html","svelte"].includes(t.toLowerCase())?`<!-- This code was generated by Builder.io -->
1188
1188
  ${e}`:`/**
1189
1189
  * This code was generated by Builder.io.
1190
1190
  */
1191
- ${e}`:e}async function D7(e,t){let n,r=S7(t,e.toLowerCase());switch(e.toLowerCase()){case"react":let i=await y7();n=`components/${r||"MyComponent"}.${i?"tsx":"jsx"}`;break;case"angular":n=`app/components/${r||"my-component"}.component.ts`;break;case"vue":n=`components/${r||"MyComponent"}.vue`;break;case"svelte":n=`components/${r||"MyComponent"}.svelte`;break;case"html":n=`${r||"my-design"}.html`;break;case"qwik":n=`components/${r||"MyComponent"}.tsx`;break;default:n="components/MyComponent.tsx"}return n=(0,At.existsSync)("./src")?`./src/${n}`:`./${n}`,n}async function y7(){let e=(0,At.readFileSync)("./package.json","utf-8");if(!e)throw new Error("No package.json found");return e.includes("typescript")}function S7(e,t){let n={vue:/name:\s*'([^']+)'/,react:/function (\w+)\([\w\W]+\)/,qwik:/export const (\w+) = component\$/,angular:/selector:\s*'([^']+)'/};if(!n[t])return null;let r=e.match(n[t]);return t==="react"&&!r?.[1]?e.match(/const (\w+)[\w\W]+=\s*\(/)?.[1]||null:r?.[1]||null}async function lA(e,t){let n=[];for(let r of e){let i=v7(t,r.path),s=(0,ri.resolve)(process.cwd(),i);if("code"in r){let o=await x7(r.code,C7(r.path));(0,At.mkdirSync)((0,ri.dirname)(s),{recursive:!0}),(0,At.writeFileSync)(s,o),n.push({...r,path:s,code:o}),z.info(`Writing file to ${s}`)}else(0,At.mkdirSync)(s,{recursive:!0}),n=n.concat(await lA(r.files,i))}return n}function v7(e,t){let n=e.replace(/^\.?\/+|\/+$/g,""),r=t.replace(/^\.?\/+|\/+$/g,""),i=n.split("/").filter(Boolean),s=r.split("/").filter(Boolean),o=-1;for(let c=0;c<i.length;c++){let u=s.indexOf(i[c]);u!==-1&&(o=u)}return"./"+[...i,...s.slice(o+1)].join("/")}function C7(e){switch(e.split(".").pop()?.toLowerCase()){case"html":case"svelte":return"html";case"vue":return"vue";case"ts":case"tsx":case"js":case"jsx":return"typescript";case"css":return"css";case"json":return"json";default:return"typescript"}}async function x7(e,t){let n=e;try{n=await Wt(e,t)}catch{}return uA(n,t)}function T7(e){let n=(0,At.existsSync)((0,ri.join)(process.cwd(),"src"))?"src/":"";switch(e.toLowerCase()){case"angular":return`./${n}app/components/`;case"html":return"./";default:return`./${n}components/`}}function dA(e,t){return{cwd:e,command:t[0],snippetId:t[1],path:t[2]}}var Sd=require("fs"),_A=require("path");function w7(){yd.init("ac35e3108919035e7d150a2450a07405",{logLevel:yd.Types.LogLevel.None,flushIntervalMillis:500}),gn.init({dsn:"https://3252dddc08dbb5bf406dc33bf3c13633@o117565.ingest.sentry.io/4505630794448896",tracesSampleRate:1,integrations:[new gn.Integrations.Http({tracing:!0}),...gn.autoDiscoverNodePerformanceMonitoringIntegrations()]})}async function pA(e,t){e.debug("builder dev tools cli init");let n=await(0,fA.createDevTools)(e),r=t;await(0,gA.createDevToolsServer)({...n,getPastSyncInfo:({sessionKey:i,since:s})=>{if(i&&r?.snippet.sessionKey===i){let o=!1;for(let a of r.writtenFiles){let c=(0,_A.resolve)(process.cwd(),a.path);try{let u=(0,Sd.statSync)(c);if(u.mtime.getTime()>Math.max(r.timeStamp,s)){console.log("file changed syncing up to app",c,u.mtime.getTime(),r.timeStamp);let l=(0,Sd.readFileSync)(c,"utf-8");a.code=l,o=!0,r.timeStamp=Date.now()}}catch(u){e.debug(`Error checking file ${c}: ${u}`)}}return{...r,hasChanged:o}}return r},getClientId:()=>t?"builder-add-cli":"builder-dev-tools-cli",closeAppServer:async()=>{},restartAppServer:async()=>{e.debug("restart server")},enableAppWatch:async i=>i,...e})}var bA=()=>process.exit(0);process.on("SIGINT",bA);process.on("SIGTERM",bA);async function R7(){w7();try{let e=await(0,mA.createDevToolsNodeSys)({getRootDir:()=>process.cwd(),ignoreMissingConfig:!0}),t=(0,hA.default)(process.argv.slice(2),{string:["figmaToken","privateKey"],boolean:["help","ci","force","printJson"]}),n=t._[0];if(n==="figma"){let r=t._[1];try{await rA(e,r,t)}catch(i){gn.captureException(i),console.error("Cannot run figma command",i),process.exit(1)}}else if(n==="add"){let r=dA(process.cwd(),process.argv.slice(2)),i=await cA(r);i&&pA(e,i).then(()=>{console.info("Builder dev tools is running")}).catch(s=>{gn.captureException(s),console.error("Cannot start builder dev tools",s)})}else n==="publish"||n==="migrate"||n==="generate"?(me("Command not found, do you mean `npx builder.io figma "+n+"`?"),process.exit(1)):pA(e).then(()=>{console.info("Builder dev tools is running")}).catch(r=>{gn.captureException(r),console.error("Cannot start builder dev tools",r)})}catch(e){gn.captureException(e),console.error("error"),process.exit(1)}}R7();
1191
+ ${e}`:e}async function D7(e,t){let n,r=S7(t,e.toLowerCase());switch(e.toLowerCase()){case"react":let i=await y7();n=`components/${r||"MyComponent"}.${i?"tsx":"jsx"}`;break;case"angular":n=`app/components/${r||"my-component"}.component.ts`;break;case"vue":n=`components/${r||"MyComponent"}.vue`;break;case"svelte":n=`components/${r||"MyComponent"}.svelte`;break;case"html":n=`${r||"my-design"}.html`;break;case"qwik":n=`components/${r||"MyComponent"}.tsx`;break;default:n="components/MyComponent.tsx"}return n=(0,At.existsSync)("./src")?`./src/${n}`:`./${n}`,n}async function y7(){let e=(0,At.readFileSync)("./package.json","utf-8");if(!e)throw new Error("No package.json found");return e.includes("typescript")}function S7(e,t){let n={vue:/name:\s*'([^']+)'/,react:/function (\w+)\([\w\W]+\)/,qwik:/export const (\w+) = component\$/,angular:/selector:\s*'([^']+)'/};if(!n[t])return null;let r=e.match(n[t]);return t==="react"&&!r?.[1]?e.match(/const (\w+)[\w\W]+=\s*\(/)?.[1]||null:r?.[1]||null}async function lA(e,t){let n=[];for(let r of e){let i=v7(t,r.path),s=(0,ri.resolve)(process.cwd(),i);if("code"in r){let o=await x7(r.code,C7(r.path));(0,At.mkdirSync)((0,ri.dirname)(s),{recursive:!0}),(0,At.writeFileSync)(s,o),n.push({...r,path:s,code:o}),z.info(`Writing file to ${s}`)}else(0,At.mkdirSync)(s,{recursive:!0}),n=n.concat(await lA(r.files,i))}return n}function v7(e,t){let n=e.replace(/^\.?\/+|\/+$/g,""),r=t.replace(/^\.?\/+|\/+$/g,""),i=n.split("/").filter(Boolean),s=r.split("/").filter(Boolean),o=-1;for(let c=0;c<i.length;c++){let u=s.indexOf(i[c]);u!==-1&&(o=u)}return"./"+[...i,...s.slice(o+1)].join("/")}function C7(e){switch(e.split(".").pop()?.toLowerCase()){case"html":case"svelte":return"html";case"vue":return"vue";case"ts":case"tsx":case"js":case"jsx":return"typescript";case"css":return"css";case"json":return"json";default:return"typescript"}}async function x7(e,t){let n=e;try{n=await Wt(e,t)}catch{}return uA(n,t)}function T7(e){let n=(0,At.existsSync)((0,ri.join)(process.cwd(),"src"))?"src/":"";switch(e.toLowerCase()){case"angular":return`./${n}app/components/`;case"html":return"./";default:return`./${n}components/`}}function dA(e,t){return{cwd:e,command:t[0],snippetId:t[1],path:t[2]}}var Sd=require("fs"),_A=require("path");function w7(){yd.init("ac35e3108919035e7d150a2450a07405",{logLevel:yd.Types.LogLevel.None,flushIntervalMillis:500}),gn.init({dsn:"https://3252dddc08dbb5bf406dc33bf3c13633@o117565.ingest.sentry.io/4505630794448896",tracesSampleRate:1,integrations:[new gn.Integrations.Http({tracing:!0}),...gn.autoDiscoverNodePerformanceMonitoringIntegrations()]})}async function pA(e,t){e.debug("builder dev tools cli init");let n=await(0,fA.createDevTools)(e),r=t;await(0,gA.createDevToolsServer)({...n,getPastSyncInfo:({sessionKey:i,since:s})=>{if(i&&r?.snippet.sessionKey===i){let o=!1;for(let a of r.writtenFiles){let c=(0,_A.resolve)(process.cwd(),a.path);try{let u=(0,Sd.statSync)(c);if(u.mtime.getTime()>Math.max(r.timeStamp,s)){console.log("file changed syncing up to app",c,u.mtime.getTime(),r.timeStamp);let l=(0,Sd.readFileSync)(c,"utf-8");a.code=l,o=!0,r.timeStamp=Date.now()}}catch(u){e.debug(`Error checking file ${c}: ${u}`)}}return{...r,hasChanged:o}}return r},getClientId:()=>t?"builder-add-cli":"builder-dev-tools-cli",closeAppServer:async()=>{},restartAppServer:async()=>{e.debug("restart server")},enableAppWatch:async i=>i,...e})}var bA=()=>process.exit(0);process.on("SIGINT",bA);process.on("SIGTERM",bA);async function R7(){w7();try{let e=await(0,mA.createDevToolsNodeSys)({getRootDir:()=>process.cwd(),ignoreMissingConfig:!0}),t=(0,hA.default)(process.argv.slice(2),{string:["figmaToken","privateKey"],boolean:["help","ci","force","printJson"]}),n=t._[0];if(n==="figma"){let r=t._[1];try{await rA(e,r,t)}catch(i){gn.captureException(i),console.error("Cannot run figma command",i),process.exit(1)}}else if(["add","sync"].includes(n)){let r=dA(process.cwd(),process.argv.slice(2)),i=await cA(r);i&&n==="sync"&&pA(e,i).then(()=>{console.info("Builder dev tools is running")}).catch(s=>{gn.captureException(s),console.error("Cannot start builder dev tools",s)})}else n==="publish"||n==="migrate"||n==="generate"?(me("Command not found, do you mean `npx builder.io figma "+n+"`?"),process.exit(1)):pA(e).then(()=>{console.info("Builder dev tools is running")}).catch(r=>{gn.captureException(r),console.error("Cannot start builder dev tools",r)})}catch(e){gn.captureException(e),console.error("error"),process.exit(1)}}R7();
1192
1192
  /*! Bundled license information:
1193
1193
 
1194
1194
  cookie/index.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "builder.io",
3
- "version": "1.1.13-8",
3
+ "version": "1.1.13-9",
4
4
  "description": "Add Builder.io code snippets to an application",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,36 +1,2 @@
1
- import type { CliOptions } from "./options";
2
- interface Snippet {
3
- createdDate: number;
4
- code: string;
5
- framework: string;
6
- suggestedName: string;
7
- id: string;
8
- sessionKey?: string;
9
- }
10
- export interface SyncInfo {
11
- snippet: Snippet;
12
- pathInput: string;
13
- writtenFiles: Array<FileNode>;
14
- timeStamp: number;
15
- }
16
- export declare function addCommand(opts: CliOptions): Promise<SyncInfo | undefined>;
17
- interface FileNode {
18
- name: string;
19
- code: string;
20
- path: string;
21
- isLoading?: boolean;
22
- }
23
- interface FolderNode {
24
- name: string;
25
- path: string;
26
- files: (FileNode | FolderNode)[];
27
- }
28
- interface Snippet {
29
- createdDate: number;
30
- code: string;
31
- framework: string;
32
- suggestedName: string;
33
- id: string;
34
- files: Array<FileNode | FolderNode>;
35
- }
36
- export {};
1
+ import type { AddCliOptions, SyncInfo } from "../../types";
2
+ export declare function addCommand(opts: AddCliOptions): Promise<SyncInfo | undefined>;
@@ -1,7 +1,2 @@
1
- export declare function getOptions(cwd: string, args: string[]): CliOptions;
2
- export interface CliOptions {
3
- cwd: string;
4
- command?: string;
5
- snippetId?: string;
6
- path?: string;
7
- }
1
+ import type { AddCliOptions } from "packages/dev-tools/types";
2
+ export declare function getOptions(cwd: string, args: string[]): AddCliOptions;
package/types/types.d.ts CHANGED
@@ -414,4 +414,37 @@ export interface UpdateRegistry {
414
414
  nodeIndex: number;
415
415
  components: ComponentInfo[];
416
416
  }
417
+ export interface AddCliOptions {
418
+ cwd: string;
419
+ command?: string;
420
+ snippetId?: string;
421
+ snippet?: Snippet;
422
+ path?: string;
423
+ }
424
+ export interface FileNode {
425
+ name: string;
426
+ code: string;
427
+ path: string;
428
+ isLoading?: boolean;
429
+ }
430
+ export interface FolderNode {
431
+ name: string;
432
+ path: string;
433
+ files: (FileNode | FolderNode)[];
434
+ }
435
+ export interface Snippet {
436
+ createdDate: number;
437
+ code: string;
438
+ framework: string;
439
+ suggestedName: string;
440
+ id: string;
441
+ files: Array<FileNode | FolderNode>;
442
+ sessionKey?: string;
443
+ }
444
+ export interface SyncInfo {
445
+ snippet: Snippet;
446
+ pathInput: string;
447
+ writtenFiles: Array<FileNode>;
448
+ timeStamp: number;
449
+ }
417
450
  export {};