@ikas/storefront-next 4.4.0-beta.5 → 4.4.0-beta.7

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.
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'./../ext/tslib/tslib.es6.js';import n from"fs";import r from"path";import s from"adm-zip";import o from"axios";import i from"@ikas/storefront-assets/checkout/de.js";import a from"@ikas/storefront-assets/checkout/en.js";import c from"@ikas/storefront-assets/checkout/tr.js";import{corsMiddleware as u}from"./middleware.js";var l=function(o,l){return e(void 0,void 0,void 0,(function(){var e,d,m,y,v,S,j,w,b;return t(this,(function(t){switch(t.label){case 0:return[4,u(o,l)];case 1:t.sent(),e=function(){l.statusCode=200,l.setHeader("Content-Type","application/json"),l.json({status:"ok"})},d=function(){l.statusCode=400,l.setHeader("Content-Type","application/json"),l.json({status:"failed"})},m="",t.label=2;case 2:return t.trys.push([2,9,10,11]),[4,new Promise((function(e,t){var s=r.join(process.cwd(),"src","theme.json");n.readFile(s,(function(n,r){if(n)return t(n);e(JSON.parse(r.toString()))}))}))];case 3:return y=t.sent(),[4,new Promise((function(e,t){var s=r.join(process.cwd(),"public","locales"),o=function(e){return e.length?e.split(".")[0]:e};n.readdir(s,(function(u,l){if(u)return t(u);var d=l.filter((function(e){return n.lstatSync(r.join(s,e)).isDirectory()})),p={},f=!1;d.forEach((function(e){var t=r.join(process.cwd(),"public","locales",e);p[e]={};try{var s=n.readdirSync(t);s.forEach((function(t){var s=n.readFileSync(r.join(process.cwd(),"public","locales",e,t)),u=o(e).toLowerCase(),l=o(t);p[u][l]=JSON.parse(s.toString()),p[u]["checkout-page"]="tr"===u?c:"de"===u?i:a}))}catch(e){console.error(e),f=!0}})),f?t(null):e(p)}))}))];case 4:return v=t.sent(),[4,p(y,v)];case 5:return S=t.sent(),j=!1,"string"!=typeof S?[3,8]:(g=r.join(process.cwd()),T="theme.zip",N=r.join(process.cwd(),T),L=new s,k=["node_modules",".next","out",".git"],n.readdirSync(g).forEach((function(e){var t=r.join(g,e);if(n.lstatSync(t).isDirectory()){if(k.includes(e))return;L.addLocalFolder(t,e)}else L.addLocalFile(e)})),L.writeZip(N),m=N,w=n.statSync(m),[4,f(S,n.readFileSync(m),w.size)]);case 6:return(j=t.sent())?[4,h()]:[3,8];case 7:j=t.sent(),t.label=8;case 8:return j?e():d(),[3,11];case 9:return b=t.sent(),console.error(b),d(),[3,11];case 10:return m&&function(e){try{n.unlinkSync(e)}catch(e){console.error(e)}}(m),[7];case 11:return[2]}var g,T,N,L,k}))}))},d={};function p(n,r){return e(this,void 0,void 0,(function(){var e,s,i,a,c;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,4,,5]),e=Object.keys(r),s=e.some((function(e){return"en"===e}))?"en":e[0],[4,m()];case 1:return i=t.sent(),[4,o({method:"post",url:process.env.NEXT_PUBLIC_PARTNER_GQL_URL,headers:{"x-api-key":i.apiKey,"Content-Type":"application/json"},data:JSON.stringify({query:"\n mutation createNewThemeVersion($input: CreateNewThemeVersionInput!) {\n createNewThemeVersion(input: $input) {\n themeVersionId\n uploadUrl\n }\n }\n ",variables:{input:{themeId:i.themeId,themeSecret:i.themeSecret,themeJson:JSON.stringify(n),locales:Object.entries(r).map((function(e){var t=e[0],n=e[1];return{isDefaultLocale:t===s,locale:t,localeJson:JSON.stringify(n)}}))}}})})];case 2:return[4,t.sent().data];case 3:return(a=t.sent()).data&&a.data.createNewThemeVersion?[2,a.data.createNewThemeVersion.uploadUrl]:[3,5];case 4:return c=t.sent(),console.log(c),[3,5];case 5:return[2]}}))}))}function f(n,r,s){return e(this,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:e={headers:{"Content-Type":"application/zip","Content-Length":s+""}},t.label=1;case 1:return t.trys.push([1,3,,4]),[4,o.put(n,r,e)];case 2:return[2,200===t.sent().status];case 3:return i=t.sent(),console.log(i),[2,!1];case 4:return[2]}}))}))}function h(){return e(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,4,,5]),[4,m()];case 1:return e=t.sent(),[4,fetch(process.env.NEXT_PUBLIC_PARTNER_GQL_URL,{method:"POST",body:JSON.stringify({query:"\n mutation buildThemeLatestVersion(\n $themeSecret: String!\n $themeId: String!\n ) {\n buildThemeLatestVersion(\n themeSecret: $themeSecret\n themeId: $themeId\n )\n }\n ",variables:{themeSecret:e.themeSecret,themeId:e.themeId}}),headers:{"x-api-key":e.apiKey,"Content-Type":"application/json"}})];case 2:return[4,t.sent().json()];case 3:return t.sent(),[2,!0];case 4:return n=t.sent(),console.log(n),[2,!1];case 5:return[2]}}))}))}function m(){return new Promise((function(e,t){var s=r.join(process.cwd(),"config.json");n.readFile(s,(function(n,r){if(n)return t(n);e(JSON.parse(r.toString()))}))}))}export{d as config,l as uploadTheme};
1
+ import{__awaiter as e,__generator as r}from'./../ext/tslib/tslib.es6.js';import t from"fs";import n from"path";import o from"adm-zip";import s from"axios";import i from"@ikas/storefront-assets/checkout/de.js";import c from"@ikas/storefront-assets/checkout/en.js";import a from"@ikas/storefront-assets/checkout/tr.js";import{corsMiddleware as u}from"./middleware.js";var l=function(s,l){return e(void 0,void 0,void 0,(function(){var e,d,m,y,v,S,w,g,j;return r(this,(function(r){switch(r.label){case 0:return[4,u(s,l)];case 1:r.sent(),e=function(){l.statusCode=200,l.setHeader("Content-Type","application/json"),l.json({status:"ok"})},d=function(){l.statusCode=400,l.setHeader("Content-Type","application/json"),l.json({status:"failed"})},m="",r.label=2;case 2:return r.trys.push([2,9,10,11]),[4,new Promise((function(e,r){var o=n.join(process.cwd(),"src","theme.json");t.readFile(o,(function(t,n){if(t)return console.error("An error occurred while reading the theme.json file!"),r(t);e(JSON.parse(n.toString()))}))}))];case 3:return y=r.sent(),[4,new Promise((function(e,r){var o=n.join(process.cwd(),"public","locales"),s=function(e){return e.length?e.split(".")[0]:e};t.readdir(o,(function(u,l){if(u)return r(u);var d=l.filter((function(e){return t.lstatSync(n.join(o,e)).isDirectory()})),h={},p=!1;d.forEach((function(e){var r=n.join(process.cwd(),"public","locales",e);h[e]={};try{var o=t.readdirSync(r);o.forEach((function(r){var o=t.readFileSync(n.join(process.cwd(),"public","locales",e,r)),u=s(e).toLowerCase(),l=s(r);h[u][l]=JSON.parse(o.toString()),h[u]["checkout-page"]="tr"===u?a:"de"===u?i:c}))}catch(e){console.error("An error occurred while reading localization files!"),console.error(e),p=!0}})),p?r(null):e(h)}))}))];case 4:return v=r.sent(),[4,h(y,v)];case 5:return S=r.sent(),w=!1,"string"!=typeof S?[3,8]:(b=n.join(process.cwd()),T="theme.zip",N=n.join(process.cwd(),T),L=new o,k=["node_modules",".next","out",".git"],t.readdirSync(b).forEach((function(e){var r=n.join(b,e);if(t.lstatSync(r).isDirectory()){if(k.includes(e))return;L.addLocalFolder(r,e)}else L.addLocalFile(e)})),L.writeZip(N),m=N,g=t.statSync(m),[4,p(S,t.readFileSync(m),g.size)]);case 6:return(w=r.sent())?[4,f()]:[3,8];case 7:w=r.sent(),r.label=8;case 8:return w?e():d(),[3,11];case 9:return j=r.sent(),console.error(j),d(),[3,11];case 10:return m&&function(e){try{t.unlinkSync(e)}catch(e){console.error("An error occurrred while deleting the zip file!"),console.error(e)}}(m),[7];case 11:return[2]}var b,T,N,L,k}))}))},d={};function h(t,n){return e(this,void 0,void 0,(function(){var e,o,i,c,a;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),e=Object.keys(n),o=e.some((function(e){return"en"===e}))?"en":e[0],[4,m()];case 1:return i=r.sent(),[4,s({method:"post",url:process.env.NEXT_PUBLIC_PARTNER_GQL_URL,headers:{"x-api-key":i.apiKey,"Content-Type":"application/json"},data:JSON.stringify({query:"\n mutation createNewThemeVersion($input: CreateNewThemeVersionInput!) {\n createNewThemeVersion(input: $input) {\n themeVersionId\n uploadUrl\n }\n }\n ",variables:{input:{themeId:i.themeId,themeSecret:i.themeSecret,themeJson:JSON.stringify(t),locales:Object.entries(n).map((function(e){var r=e[0],t=e[1];return{isDefaultLocale:r===o,locale:r,localeJson:JSON.stringify(t)}}))}}})})];case 2:return[4,r.sent().data];case 3:return(c=r.sent()).data&&c.data.createNewThemeVersion?[2,c.data.createNewThemeVersion.uploadUrl]:[3,5];case 4:return a=r.sent(),console.error("An error occurred during saveTheme!"),console.log(a),[3,5];case 5:return[2]}}))}))}function p(t,n,o){return e(this,void 0,void 0,(function(){var e,i;return r(this,(function(r){switch(r.label){case 0:e={headers:{"Content-Type":"application/zip","Content-Length":o+""}},r.label=1;case 1:return r.trys.push([1,3,,4]),[4,s.put(t,n,e)];case 2:return[2,200===r.sent().status];case 3:return i=r.sent(),console.error("An error occurred during uploadTheme!"),console.log(i),[2,!1];case 4:return[2]}}))}))}function f(){return e(this,void 0,void 0,(function(){var e,t;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),[4,m()];case 1:return e=r.sent(),[4,fetch(process.env.NEXT_PUBLIC_PARTNER_GQL_URL,{method:"POST",body:JSON.stringify({query:"\n mutation buildThemeLatestVersion(\n $themeSecret: String!\n $themeId: String!\n ) {\n buildThemeLatestVersion(\n themeSecret: $themeSecret\n themeId: $themeId\n )\n }\n ",variables:{themeSecret:e.themeSecret,themeId:e.themeId}}),headers:{"x-api-key":e.apiKey,"Content-Type":"application/json"}})];case 2:return[4,r.sent().json()];case 3:return r.sent(),[2,!0];case 4:return t=r.sent(),console.error("An error occurred during buildTheme!"),console.log(t),[2,!1];case 5:return[2]}}))}))}function m(){return new Promise((function(e,r){var o=n.join(process.cwd(),"config.json");t.readFile(o,(function(t,n){if(t)return console.error("An error occurred while reading the storefront config!"),r(t);e(JSON.parse(n.toString()))}))}))}export{d as config,l as uploadTheme};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront-next",
3
- "version": "4.4.0-beta.5",
3
+ "version": "4.4.0-beta.7",
4
4
  "description": "Next.js specific functions for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -17,23 +17,23 @@
17
17
  },
18
18
  "peerDependencies": {
19
19
  "next": "12.2.0",
20
- "@ikas/storefront-config": "^4.4.0-beta.5",
21
- "@ikas/storefront-providers": "^4.4.0-beta.5",
22
- "@ikas/storefront-models": "^4.4.0-beta.5",
23
- "@ikas/storefront-api": "^4.4.0-beta.5",
24
- "@ikas/storefront-assets": "^4.4.0-beta.5",
20
+ "@ikas/storefront-config": "^4.4.0-beta.7",
21
+ "@ikas/storefront-providers": "^4.4.0-beta.7",
22
+ "@ikas/storefront-models": "^4.4.0-beta.7",
23
+ "@ikas/storefront-api": "^4.4.0-beta.7",
24
+ "@ikas/storefront-assets": "^4.4.0-beta.7",
25
25
  "axios": "^0.26.0",
26
26
  "lodash": "^4.17.21",
27
27
  "cors": "^2.8.5",
28
28
  "adm-zip": "^0.5.9"
29
29
  },
30
30
  "devDependencies": {
31
- "@ikas/storefront-cmd": "^4.4.0-beta.5",
32
- "@ikas/storefront-config": "^4.4.0-beta.5",
33
- "@ikas/storefront-providers": "^4.4.0-beta.5",
34
- "@ikas/storefront-models": "^4.4.0-beta.5",
35
- "@ikas/storefront-api": "^4.4.0-beta.5",
36
- "@ikas/storefront-assets": "^4.4.0-beta.5",
31
+ "@ikas/storefront-cmd": "^4.4.0-beta.7",
32
+ "@ikas/storefront-config": "^4.4.0-beta.7",
33
+ "@ikas/storefront-providers": "^4.4.0-beta.7",
34
+ "@ikas/storefront-models": "^4.4.0-beta.7",
35
+ "@ikas/storefront-api": "^4.4.0-beta.7",
36
+ "@ikas/storefront-assets": "^4.4.0-beta.7",
37
37
  "@rollup/plugin-node-resolve": "^13.3.0",
38
38
  "@rollup/plugin-commonjs": "^22.0.0",
39
39
  "@rollup/plugin-json": "^4.1.0",