@ikas/storefront-next 5.0.85 → 5.0.86
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 r}from'./../ext/tslib/tslib.es6.js';import
|
|
1
|
+
import{__awaiter as e,__generator as r}from'./../ext/tslib/tslib.es6.js';import n from"fs";import t from"path";import o from"adm-zip";import s 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/fr.js";import u from"@ikas/storefront-assets/checkout/tr.js";import{corsMiddleware as l}from"./middleware.js";var d=function(s,d){return e(void 0,void 0,void 0,(function(){var e,p,y,T,g,j,v,w,b,S,k;return r(this,(function(r){switch(r.label){case 0:return[4,l(s,d)];case 1:if(r.sent(),"POST"!==s.method)return d.statusCode=405,d.setHeader("Allow","POST"),d.setHeader("Content-Type","application/json"),d.json({status:"failed",message:"Method not allowed. Use POST."}),[2];if(!(e=function(e){if(!e||"object"!=typeof e)return null;var r=e.uploadToken;return"string"==typeof r&&r.trim().length?r:null}(s.body)))return d.statusCode=400,d.setHeader("Content-Type","application/json"),d.json({status:"failed",message:"uploadToken is required and must be a non-empty string."}),[2];p=function(){d.statusCode=200,d.setHeader("Content-Type","application/json"),d.json({status:"ok"})},y=function(){d.statusCode=400,d.setHeader("Content-Type","application/json"),d.json({status:"failed"})},T=function(){d.statusCode=403,d.setHeader("Content-Type","application/json"),d.json({status:"failed",code:"UNAUTHORIZED"})},g="",r.label=2;case 2:return r.trys.push([2,9,10,11]),[4,new Promise((function(e,r){var o=t.join(process.cwd(),"src","theme.json");n.readFile(o,(function(n,t){if(n)return console.error("An error occurred while reading the theme.json file!"),r(n);e(JSON.parse(t.toString()))}))}))];case 3:return j=r.sent(),[4,new Promise((function(e,r){var o=t.join(process.cwd(),"public","locales"),s=function(e){return e.length?e.split(".")[0]:e};n.readdir(o,(function(l,d){if(l)return r(l);var p=d.filter((function(e){return n.lstatSync(t.join(o,e)).isDirectory()})),f={},h=!1;p.forEach((function(e){var r=t.join(process.cwd(),"public","locales",e);f[e]={};try{var o=n.readdirSync(r);o.forEach((function(r){var o=n.readFileSync(t.join(process.cwd(),"public","locales",e,r)),l=s(e).toLowerCase(),d=s(r);f[l][d]=JSON.parse(o.toString()),f[l]["checkout-page"]="tr"===l?u:"de"===l?i:"fr"===l?c:a}))}catch(e){console.error("An error occurred while reading localization files!"),console.error(e),h=!0}})),h?r(null):e(f)}))}))];case 4:return v=r.sent(),[4,f(j,v,e)];case 5:return null===(w=r.sent())?(T(),[2]):(b=!1,"string"!=typeof w?[3,8]:(C=t.join(process.cwd()),N="theme.zip",L=t.join(process.cwd(),N),O=new o,A=["node_modules",".next","out",".git"],n.readdirSync(C).forEach((function(e){var r=t.join(C,e);if(n.lstatSync(r).isDirectory()){if(A.includes(e))return;O.addLocalFolder(r,e)}else O.addLocalFile(e)})),O.writeZip(L),g=L,S=n.statSync(g),[4,h(w,n.readFileSync(g),S.size)]));case 6:return(b=r.sent())?[4,m(e)]:[3,8];case 7:b=r.sent(),r.label=8;case 8:return b?p():y(),[3,11];case 9:return k=r.sent(),console.error(k),y(),[3,11];case 10:return g&&function(e){try{n.unlinkSync(e)}catch(e){console.error("An error occurrred while deleting the zip file!"),console.error(e)}}(g),[7];case 11:return[2]}var C,N,L,O,A}))}))},p={};function f(n,t,o){return e(this,void 0,void 0,(function(){var e,i,a,c,u;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),e=Object.keys(t),i=e.some((function(e){return"en"===e}))?"en":e[0],[4,T()];case 1:return a=r.sent(),[4,s({method:"post",url:process.env.NEXT_PUBLIC_PARTNER_GQL_URL,headers:{"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:a.themeId,uploadToken:o,themeJson:JSON.stringify(n),locales:Object.entries(t).map((function(e){var r=e[0],n=e[1];return{isDefaultLocale:r===i,locale:r,localeJson:JSON.stringify(n)}}))}}})})];case 2:return[4,r.sent().data];case 3:return(c=r.sent()).data&&c.data.createNewThemeVersion?[2,c.data.createNewThemeVersion.uploadUrl]:(y("saveTheme",c.errors),!c.errors&&c.data&&null===c.data.createNewThemeVersion?[2,null]:[3,5]);case 4:return u=r.sent(),console.error("An error occurred during saveTheme!",null==u?void 0:u.message),[3,5];case 5:return[2]}}))}))}function h(n,t,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+""},maxBodyLength:104857600,maxContentLength:104857600},r.label=1;case 1:return r.trys.push([1,3,,4]),[4,s.put(n,t,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 m(n){return e(this,void 0,void 0,(function(){var e,t,o;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),[4,T()];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 $themeId: String!\n $uploadToken: String!\n ) {\n buildThemeLatestVersion(\n themeId: $themeId\n uploadToken: $uploadToken\n )\n }\n ",variables:{themeId:e.themeId,uploadToken:n}}),headers:{"Content-Type":"application/json"}})];case 2:return[4,r.sent().json()];case 3:return!(t=r.sent()).errors&&t.data&&!0===t.data.buildThemeLatestVersion?[2,!0]:(y("buildTheme",t.errors),[2,!1]);case 4:return o=r.sent(),console.error("An error occurred during buildTheme!",null==o?void 0:o.message),[2,!1];case 5:return[2]}}))}))}function y(e,r){var n=Array.isArray(r)?r.map((function(e){return e&&e.message})):[];console.error("".concat(e," failed!"),n)}function T(){return new Promise((function(e,r){var o=t.join(process.cwd(),"config.json");n.readFile(o,(function(n,t){if(n)return console.error("An error occurred while reading the storefront config!"),r(n);e(JSON.parse(t.toString()))}))}))}export{p as config,d as uploadTheme};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront-next",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.86",
|
|
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": "^5.0.
|
|
21
|
-
"@ikas/storefront-providers": "^5.0.
|
|
22
|
-
"@ikas/storefront-models": "^5.0.
|
|
23
|
-
"@ikas/storefront-api": "^5.0.
|
|
24
|
-
"@ikas/storefront-assets": "^5.0.
|
|
20
|
+
"@ikas/storefront-config": "^5.0.86",
|
|
21
|
+
"@ikas/storefront-providers": "^5.0.86",
|
|
22
|
+
"@ikas/storefront-models": "^5.0.86",
|
|
23
|
+
"@ikas/storefront-api": "^5.0.86",
|
|
24
|
+
"@ikas/storefront-assets": "^5.0.86",
|
|
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": "^5.0.
|
|
32
|
-
"@ikas/storefront-config": "^5.0.
|
|
33
|
-
"@ikas/storefront-providers": "^5.0.
|
|
34
|
-
"@ikas/storefront-models": "^5.0.
|
|
35
|
-
"@ikas/storefront-api": "^5.0.
|
|
36
|
-
"@ikas/storefront-assets": "^5.0.
|
|
31
|
+
"@ikas/storefront-cmd": "^5.0.86",
|
|
32
|
+
"@ikas/storefront-config": "^5.0.86",
|
|
33
|
+
"@ikas/storefront-providers": "^5.0.86",
|
|
34
|
+
"@ikas/storefront-models": "^5.0.86",
|
|
35
|
+
"@ikas/storefront-api": "^5.0.86",
|
|
36
|
+
"@ikas/storefront-assets": "^5.0.86",
|
|
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",
|