@webflow/webflow-cli 1.6.4 → 1.6.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @webflow/webflow-cli
2
2
 
3
+ ## 1.6.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updating extension cli
8
+
3
9
  ## 1.6.4
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1035,7 +1035,7 @@ ${s.message}`,s}},_ri={loadJs:dri,loadJsSync:Kdt,loadJson:hri,loadYaml:mri};L_e.
1035
1035
  `).trim(),{parser:"css"});return Qat(s)}catch{return N5.log(WI("There was a problem skipping global tags from CSS. Falling back to normal global CSS.")),e}}function tst(e){return e.reduce((r,i)=>(i.name==="global"?r.globalCss=i:r.rest.push(i),r),{rest:[]})}var kF=class extends Error{constructor(r){super(r)}},jEe=e=>N5.render({text:`${Xce("Something went wrong while trying to export your components:")} ${Sk.red(e.message)}
1036
1036
  ${e==null?void 0:e.stack}`});function rst(e){if(e.status>=200&&e.status<300){switch(e.status){case 206:N5.log(WI("You exceeded the limit of components and some components were not exported."));break;case 207:N5.log(WI("Certain components couldn't be exported due to an unexpected error."));break}return}switch(e.status){case 400:throw new kF("Something unexpected happened. Report a bug here: https://airtable.com/shr47EWPVsV9xCwOH");case 401:throw new kF("Your access token is invalid for the provided siteId. Double check your configs in your .webflowrc configuration file.");case 404:throw new kF("You're not currently enrolled in the DevLink beta. You can apply for access here: https://webflow.com/devlink");default:throw new kF("Something went wrong. Try again later or report a bug here: https://airtable.com/shr47EWPVsV9xCwOH")}}async function ZUn(e){try{let{siteId:r,host:i,authToken:s,components:l,cssModules:c}=e,p=new URLSearchParams({cssModules:c?"true":"false"});l&&p.append("components",encodeURIComponent(l));let h=`?${p.toString()}`,g=await QI(`${i}/devlink/${r}${h}`,{headers:{Authorization:`Bearer ${s}`},timeout:6e4});rst(g);let v=await g.json();return v.components||v}catch(r){if(r instanceof kF)jEe(r),process.exit(1);else throw r}}async function e$n(e){try{let{siteId:r,host:i,authToken:s}=e,l=await QI(`${i}/devlink/${r}/engine`,{headers:{Authorization:`Bearer ${s}`},timeout:6e4});return rst(l),await l.json()}catch(r){if(r instanceof kF)jEe(r),process.exit(1);else throw r}}async function REe(e){let{rootDir:r}=e;N5.render({text:`Exporting components into ${e.rootDir}.`,showSpinner:!0});try{let[i,s]=await Promise.all([ZUn(e),e$n(e)]),l=s;if(e.skipTagSelectors===!0){let{rest:c,globalCss:p}=tst(i),h=est(p);l.push(...c,h)}else l.push(...i);await pUe(l,e),N5.render({text:Yce(`Succesfully exported components into ${r} folder.`),flushLogs:!0})}catch(i){i instanceof Error&&(jEe(i),MH(i))}}async function ist(e){Brt();let r={...e&&e.length>0?{components:abe(e),overwriteModule:!1}:{overwriteModule:!0}},i=await npe(r);if(!i)return nst.default.exit();await REe(i)}var Cht=jc(require("http"));var wht=jc(dot()),d8=require("fs"),Z5=jc(require("path")),GSe=require("commander");var yht=jc(l1t()),HSe=require("commander"),K_e=require("fs");var fht=jc(pht()),dht=require("commander"),$_e=async(e,r)=>{let i=await Uri(r);return{filepath:i.filepath,config:{publicDir:e,...i.config}}},Uri=async e=>{let i=await(0,fht.cosmiconfig)("webflow",{searchPlaces:[e]}).search();return i||dht.program.error(`No ${e} file was found. Run this command within your extension folder.`),i};var bht=jc(vht()),z_e=jc(require("path")),Jri=5*1024*1024,Yri=new Set(["application/javascript","application/json","application/xml","image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/vnd.microsoft.icon","image/x-icon","video/webm","font/ttf","font/otf","font/woff","font/woff2","text/plain","text/markdown","text/html","text/css"]),Dht=async(e,r,i)=>{let{config:s,filepath:l}=await $_e(e,r),c=z_e.join(l,".."),p=!0,h=!1,g=D=>{let E=D.name,S=bht.default.lookup(E);return E==="index.html"&&(h=!0),E&&E.endsWith(".DS_Store")||!S?!1:Yri.has(S)?D:(console.log(`Invalid file type: ${S} for file: ${E}`),p=!1,!1)},v=D=>{(0,K_e.unlink)(i,E=>{E&&console.error(`Failed to delete file: ${E}`),HSe.program.error(D)})};return console.log(`Packaging the contents of the ${s.publicDir} folder into ${i}...`),new Promise(D=>{let E=(0,yht.default)("zip",{zlib:{level:9}}),S=(0,K_e.createWriteStream)(z_e.join(c,i));S.on("close",()=>{D(void 0)}),E.directory(z_e.join(c,s.publicDir),!1,g),E.file(l,{name:r}),E.pipe(S),E.finalize(),E.on("warning",w=>{console.log(w)}),E.on("error",w=>{HSe.program.error(w.message)}),E.on("finish",()=>{if(!h){v("Could not find index.html in your `publicDir`, all Designer Extension code needs to be inside of `publicDir`");return}if(!p){v("Bundling failed due to invalid file types");return}if(!E.pointer()||E.pointer()===0){v("Bundling failed with no output");return}if(E.pointer()>=Jri){v("Bundling failed due to the bundle exceeding 5MB");return}console.log(`${E.pointer()} total bytes written`),console.log(`Done! ${i} is ready for you to upload to your Webflow app.`)})})};var Tae=e=>JSON.stringify(e,null,2),Eht=1337,WSe="webflow.json",Xri="index.html",Aht="bundle.zip",IG="public",Qri=e=>{let r="\u2500".repeat(e.length+2);return"\u256D"+r+`\u256E
1037
1037
  \u2502 `+e+` \u2502
1038
- \u2570`+r+"\u256F"},Sht=async()=>{let{config:e,filepath:r}=await $_e(IG,WSe),i=Z5.join(r,"..",e.publicDir,Xri),l=(await Hz([],!0)).extensionTemplateDomain||"webflow-ext.com",p=await(await QI(`https://${l}/template?name=${e.name}`)).text();new Cht.Server((g,v)=>{if(g.url==="/"){d8.promises.readFile(i,{encoding:"utf-8"}).catch(D=>{GSe.program.error(D.message)}).then(D=>{let E=p.replace("{{ui}}",D);return v.writeHead(200,{"Content-Length":Buffer.byteLength(E),"Content-Type":"text/html"}),v.end(E)});return}if(g.url==="/__webflow")return v.writeHead(200,{"Content-Length":Buffer.byteLength(Tae(e)),"Content-Type":"application/json","Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"*"}),v.end(Tae(e));(0,wht.default)(g,v,{public:e.publicDir,cleanUrls:!1,directoryListing:!1})}).listen(Eht),console.log(Qri(`Serving your extension at http://localhost:${Eht}`)+`
1038
+ \u2570`+r+"\u256F"},Sht=async()=>{let{config:e,filepath:r}=await $_e(IG,WSe),i=Z5.join(r,"..",e.publicDir,Xri),l=(await Hz([],!0)).extensionTemplateDomain||"webflow-ext.com",c=e.apiVersion==="2"?"template/v2":"template",h=await(await QI(`https://${l}/${c}?name=${e.name}`)).text();new Cht.Server((v,D)=>{if(v.url==="/"){d8.promises.readFile(i,{encoding:"utf-8"}).catch(E=>{GSe.program.error(E.message)}).then(E=>{let S=h.replace("{{ui}}",E);return D.writeHead(200,{"Content-Length":Buffer.byteLength(S),"Content-Type":"text/html"}),D.end(S)});return}if(v.url==="/__webflow")return D.writeHead(200,{"Content-Length":Buffer.byteLength(Tae(e)),"Content-Type":"application/json","Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"*"}),D.end(Tae(e));(0,wht.default)(v,D,{public:e.publicDir,cleanUrls:!1,directoryListing:!1})}).listen(Eht),console.log(Qri(`Serving your extension at http://localhost:${Eht}`)+`
1039
1039
  `)},Zri=`<link href="styles.css" rel="stylesheet" />
1040
1040
  <form id="lorem">
1041
1041
  <div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webflow/webflow-cli",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "bin": {
6
6
  "webflow": "./dist/index.js"