@ikas/storefront-next 4.4.0-alpha.2 → 4.4.0-alpha.4

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"archiver";import o 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,o){return e(void 0,void 0,void 0,(function(){var e,l,f,y,v,S,w,j,b;return t(this,(function(t){switch(t.label){case 0:return[4,u(s,o)];case 1:t.sent(),e=function(){o.statusCode=200,o.setHeader("Content-Type","application/json"),o.json({status:"ok"})},l=function(){o.statusCode=400,o.setHeader("Content-Type","application/json"),o.json({status:"failed"})},f="",t.label=2;case 2:return t.trys.push([2,10,11,12]),[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 f=l.filter((function(e){return n.lstatSync(r.join(s,e)).isDirectory()})),p={},d=!1;f.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?a:"de"===u?i:c}))}catch(e){console.error(e),d=!0}})),d?t(null):e(p)}))}))];case 4:return v=t.sent(),[4,d(y,v)];case 5:return S=t.sent(),w=!1,"string"!=typeof S?[3,9]:[4,p()];case 6:return f=t.sent(),j=n.statSync(f),[4,h(S,n.readFileSync(f),j.size)];case 7:return(w=t.sent())?[4,m()]:[3,9];case 8:w=t.sent(),t.label=9;case 9:return w?e():l(),[3,12];case 10:return b=t.sent(),console.error(b),l(),[3,12];case 11:return f&&function(e){try{n.unlinkSync(e)}catch(e){console.error(e)}}(f),[7];case 12:return[2]}}))}))},f={};function p(){return e(this,void 0,void 0,(function(){var e,o,i,c,a;return t(this,(function(t){switch(t.label){case 0:return e=r.join(process.cwd()),"theme.zip",o=r.join(process.cwd(),"theme.zip"),i=n.createWriteStream(o),(c=s("zip",{zlib:{level:9}})).on("warning",(function(e){if("ENOENT"!==e.code)throw e})),c.on("error",(function(e){throw e})),c.pipe(i),a=["node_modules",".next","out",".git"],n.readdirSync(e).forEach((function(t){var s=r.join(e,t);if(n.lstatSync(s).isDirectory()){if(a.includes(t))return;c.directory(s,t)}else c.file(s,{name:t})})),[4,c.finalize()];case 1:return t.sent(),[2,new Promise((function(e){setTimeout((function(){e(o)}),1e4)}))]}}))}))}function d(n,r){return e(this,void 0,void 0,(function(){var e,s,i,c,a;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,y()];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(c=t.sent()).data&&c.data.createNewThemeVersion?[2,c.data.createNewThemeVersion.uploadUrl]:[3,5];case 4:return a=t.sent(),console.log(a),[3,5];case 5:return[2]}}))}))}function h(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 m(){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,y()];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 y(){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{f 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-alpha.2",
3
+ "version": "4.4.0-alpha.4",
4
4
  "description": "Next.js specific functions for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -17,32 +17,32 @@
17
17
  },
18
18
  "peerDependencies": {
19
19
  "next": "12.2.0",
20
- "@ikas/storefront-config": "^4.4.0-alpha.2",
21
- "@ikas/storefront-providers": "^4.4.0-alpha.2",
22
- "@ikas/storefront-models": "^4.4.0-alpha.2",
23
- "@ikas/storefront-api": "^4.4.0-alpha.2",
24
- "@ikas/storefront-assets": "^4.4.0-alpha.2",
20
+ "@ikas/storefront-config": "^4.4.0-alpha.4",
21
+ "@ikas/storefront-providers": "^4.4.0-alpha.4",
22
+ "@ikas/storefront-models": "^4.4.0-alpha.4",
23
+ "@ikas/storefront-api": "^4.4.0-alpha.4",
24
+ "@ikas/storefront-assets": "^4.4.0-alpha.4",
25
25
  "axios": "^0.26.0",
26
26
  "lodash": "^4.17.21",
27
- "archiver": "^5.3.0",
28
- "cors": "^2.8.5"
27
+ "cors": "^2.8.5",
28
+ "adm-zip": "^0.5.9"
29
29
  },
30
30
  "devDependencies": {
31
- "@ikas/storefront-cmd": "^4.4.0-alpha.2",
32
- "@ikas/storefront-config": "^4.4.0-alpha.2",
33
- "@ikas/storefront-providers": "^4.4.0-alpha.2",
34
- "@ikas/storefront-models": "^4.4.0-alpha.2",
35
- "@ikas/storefront-api": "^4.4.0-alpha.2",
36
- "@ikas/storefront-assets": "^4.4.0-alpha.2",
31
+ "@ikas/storefront-cmd": "^4.4.0-alpha.4",
32
+ "@ikas/storefront-config": "^4.4.0-alpha.4",
33
+ "@ikas/storefront-providers": "^4.4.0-alpha.4",
34
+ "@ikas/storefront-models": "^4.4.0-alpha.4",
35
+ "@ikas/storefront-api": "^4.4.0-alpha.4",
36
+ "@ikas/storefront-assets": "^4.4.0-alpha.4",
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",
40
40
  "rollup-plugin-rename-node-modules": "^1.2.0",
41
- "@types/archiver": "^5.1.0",
42
41
  "@types/node": "^14.14.6",
43
42
  "@types/node-fetch": "^2.5.7",
44
43
  "@types/cors": "^2.8.9",
45
44
  "@types/lodash": "^4.14.168",
45
+ "@types/adm-zip": "^0.5.0",
46
46
  "next": "12.2.0",
47
47
  "prettier": "^2.2.1",
48
48
  "rollup": "^2.75.6",
@@ -54,7 +54,7 @@
54
54
  "typescript-transform-paths": "^2.2.2",
55
55
  "axios": "^0.26.0",
56
56
  "lodash": "^4.17.21",
57
- "archiver": "^5.3.0",
58
- "cors": "^2.8.5"
57
+ "cors": "^2.8.5",
58
+ "adm-zip": "^0.5.9"
59
59
  }
60
60
  }