@ikas/storefront-next 4.0.0-beta.7 → 4.0.0-beta.8
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/build/api/uploadTheme.js +1 -1
- package/package.json +12 -12
package/build/api/uploadTheme.js
CHANGED
|
@@ -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 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(s,o){return e(void 0,void 0,void 0,(function(){var l,d,v,y,T,j,b;return t(this,(function(
|
|
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 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(s,o){return e(void 0,void 0,void 0,(function(){var l,d,v,y,T,j,b;return t(this,(function(S){switch(S.label){case 0:return[4,u(s,o)];case 1:S.sent(),S.label=2;case 2:return S.trys.push([2,9,,10]),[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 l=S.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()})),f={},p=!1;d.forEach((function(e){var t=r.join(process.cwd(),"public","locales",e);f[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);f[u][l]=JSON.parse(s.toString()),f[u]["checkout-page"]="tr"===u?c:"de"===u?i:a}))}catch(e){console.error(e),p=!0}})),p?t(null):e(f)}))}))];case 4:return d=S.sent(),[4,p(l,d)];case 5:return"string"!=typeof(v=S.sent())?[3,8]:[4,f()];case 6:return y=S.sent(),T=n.statSync(y),[4,h(v,n.readFileSync(y),T.size)];case 7:j=S.sent(),console.log(j),j&&function(){e(this,void 0,void 0,(function(){var e,n,r;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_UPLOAD_GQL_URL,{method:"POST",body:JSON.stringify({query:"\n mutation buildTheme($buildThemeThemeId: String!) {\n buildTheme(themeId: $buildThemeThemeId)\n }\n ",variables:{buildThemeThemeId:e.themeId}}),headers:{"x-api-key":e.apiKey,"Content-Type":"application/json"}})];case 2:return[4,t.sent().json()];case 3:return n=t.sent(),console.log(n),[3,5];case 4:return r=t.sent(),console.log(r),[3,5];case 5:return[2]}}))}))}(),function(e){n.unlinkSync(e)}(y),S.label=8;case 8:return o.statusCode=200,o.setHeader("Content-Type","application/json"),o.json({status:"ok"}),[3,10];case 9:return b=S.sent(),console.log(b),o.statusCode=400,o.setHeader("Content-Type","application/json"),o.json({status:"failed"}),[3,10];case 10:return[2]}}))}))},d={};function f(){return e(this,void 0,void 0,(function(){var e,o,i,a,c;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),(a=s("zip",{zlib:{level:9}})).on("warning",(function(e){if("ENOENT"!==e.code)throw e})),a.on("error",(function(e){throw e})),a.pipe(i),c=["node_modules",".next","out",".git"],n.readdirSync(e).forEach((function(t){var s=r.join(e,t);if(n.lstatSync(s).isDirectory()){if(c.includes(t))return;a.directory(s,t)}else a.file(s,{name:t})})),[4,a.finalize()];case 1:return t.sent(),[2,new Promise((function(e){setTimeout((function(){e(o)}),2e3)}))]}}))}))}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_UPLOAD_GQL_URL,headers:{"x-api-key":i.apiKey,"Content-Type":"application/json"},data:JSON.stringify({query:"\n mutation saveTheme($saveThemeInput: SaveThemeInput!) {\n saveTheme(input: $saveThemeInput) {\n themeVersionId\n uploadUrl\n }\n }\n ",variables:{saveThemeInput:{id:i.themeId,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.saveTheme?[2,a.data.saveTheme.uploadUrl]:[3,5];case 4:return c=t.sent(),console.log(c),[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 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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront-next",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.8",
|
|
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.0.0-beta.
|
|
21
|
-
"@ikas/storefront-providers": "^4.0.0-beta.
|
|
22
|
-
"@ikas/storefront-models": "^4.0.0-beta.
|
|
23
|
-
"@ikas/storefront-api": "^4.0.0-beta.
|
|
24
|
-
"@ikas/storefront-assets": "^4.0.0-beta.
|
|
20
|
+
"@ikas/storefront-config": "^4.0.0-beta.8",
|
|
21
|
+
"@ikas/storefront-providers": "^4.0.0-beta.8",
|
|
22
|
+
"@ikas/storefront-models": "^4.0.0-beta.8",
|
|
23
|
+
"@ikas/storefront-api": "^4.0.0-beta.8",
|
|
24
|
+
"@ikas/storefront-assets": "^4.0.0-beta.8",
|
|
25
25
|
"axios": "^0.21.0",
|
|
26
26
|
"lodash": "^4.17.21",
|
|
27
27
|
"archiver": "^5.3.0",
|
|
28
28
|
"cors": "^2.8.5"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@ikas/storefront-cmd": "^4.0.0-beta.
|
|
32
|
-
"@ikas/storefront-config": "^4.0.0-beta.
|
|
33
|
-
"@ikas/storefront-providers": "^4.0.0-beta.
|
|
34
|
-
"@ikas/storefront-models": "^4.0.0-beta.
|
|
35
|
-
"@ikas/storefront-api": "^4.0.0-beta.
|
|
36
|
-
"@ikas/storefront-assets": "^4.0.0-beta.
|
|
31
|
+
"@ikas/storefront-cmd": "^4.0.0-beta.8",
|
|
32
|
+
"@ikas/storefront-config": "^4.0.0-beta.8",
|
|
33
|
+
"@ikas/storefront-providers": "^4.0.0-beta.8",
|
|
34
|
+
"@ikas/storefront-models": "^4.0.0-beta.8",
|
|
35
|
+
"@ikas/storefront-api": "^4.0.0-beta.8",
|
|
36
|
+
"@ikas/storefront-assets": "^4.0.0-beta.8",
|
|
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",
|