@shoplineos/cli 1.1.7-beta.0 → 1.2.0
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/dist/services/extension/api.js +4 -4
- package/dist/services/extension/const.js +1 -1
- package/dist/services/extension/context.js +1 -1
- package/dist/services/extension/create/index.js +1 -1
- package/dist/services/extension/generate.js +1 -1
- package/dist/services/extension/push/index.js +1 -1
- package/dist/services/extension/push/shopper.js +1 -0
- package/dist/services/extension/schemas.js +1 -1
- package/dist/services/extension/types.js +1 -1
- package/dist/services/extension/utils.js +1 -1
- package/dist/services/theme/3.0/api.js +2 -5
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var e,t,r;Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(exports,{ECategory:()=>e,ERegisterType:()=>t,EExtensionState:()=>r,http:()=>
|
|
2
|
-
error message: ${null==e?void 0:null===(
|
|
3
|
-
trace id: ${
|
|
1
|
+
"use strict";var e,t,r;Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(exports,{ECategory:()=>e,ERegisterType:()=>t,EExtensionState:()=>r,http:()=>L,authHttp:()=>m,changeBaseURL:()=>U,createExtensionInstance:()=>C,pushExtension:()=>N,getAppList:()=>S,getAppExtList:()=>y,getPartnerList:()=>A,getStoreList:()=>I,getAccessToken:()=>b,getAppInfo:()=>H,getStoreInfo:()=>x,getFunctionTemplates:()=>q,registerFunction:()=>B,pushFunction:()=>M});const n=g(require("form-data")),o=g(require("axios")),a=g(require("../../helpers/config")),s=require("./const"),i=g(require("../../utils/debug")),u=require("../../utils/error"),l=require("../../utils/ui/render"),d=require("../../utils/messages"),c=require("../../utils/misc"),p=require("../../helpers/sentry"),E=require("../../utils/const"),f=g(require("../../utils/winston"));function g(e){return e&&e.__esModule?e:{default:e}}function _(e){return`${e}/api/v1/cli/app/ext`}function T(e){return`${e}/api/v3/cli/app/ext`}function h(e){return`${e}/api/v1/cli`}function O(e){return`${e}/api/v3/cli`}function v(e,t={}){let r=e=>{let{loginInfo:t,dfpToken:r,currentPartner:n}=a.default;if(t){n&&(t.a_dc_partnerid=n.id,Object.assign(e.headers,{dc_partner_f:"1"}));let o=Object.keys(t).map(e=>`${e}=${t[e]}`).join(";");Object.assign(e.headers,{cookie:o,"dfp-token":r||""})}};e.interceptors.request.use(e=>(i.default.printRequest(e),t.useThemeAuth&&r(e),e.data instanceof n.default&&Object.assign(e.headers,e.data.getHeaders()),f.default.logHttp({type:"request",method:e.method,url:e.baseURL+e.url,params:e.params}),e),e=>Promise.reject(e)),e.interceptors.response.use(e=>{var t,r,n,o,l,E,g,_;let T=(null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.success)||(null==e?void 0:null===(r=e.data)||void 0===r?void 0:r.code)==="SUCCESS",h=null==e?void 0:null===(n=e.data)||void 0===n?void 0:n.code,{config:O}=e,v=(0,c.getUrlOrigin)(O.baseURL);i.default.printResponse(O,e),(0,p.reportHttpRes)(e);let L=(null==e?void 0:null===(o=e.headers)||void 0===o?void 0:o.traceid)||(null==e?void 0:null===(l=e.data)||void 0===l?void 0:l.trace_id)||(null==e?void 0:null===(E=e.data)||void 0===E?void 0:E.traceId)||"";if(f.default.logHttp({type:"response",method:e.config.method,url:e.config.baseURL+e.config.url,params:e.config.params,body:e.data,status:e.status,traceId:L}),h===s.ERRORS.PARTNER_INFO_NOT_COMPLETE)throw a.default.deleteCurrentPartner(),new u.ApiError({code:h,message:e.data.message,tryMessage:v?(0,d.getMessage)("extension.create.connect.try_partner_info_not_complete_message",{link:`${v}/info/fill`}):void 0});if(h===s.ERRORS.USER_NOT_LOGIN)throw new u.ApiError({code:h,message:e.data.message,tryMessage:(0,d.getMessage)("core.whoami.not_logged_in")});if("boolean"==typeof T&&!1===T){let t="";try{t=JSON.stringify(e.data,null,2)}catch(r){t=`error code: ${h}
|
|
2
|
+
error message: ${null==e?void 0:null===(_=e.data)||void 0===_?void 0:_.message}
|
|
3
|
+
trace id: ${L}`}throw new u.AbortError(`url: ${e.config.baseURL+e.config.url}`,t)}return null===(g=e.data)||void 0===g?void 0:g.data},e=>{if((0,p.reportBug)(e),e.response){var t,r,n,o;(0,p.reportHttpRes)(e.response);let{response:a}=e,s=a.config.url,i=(null==a?void 0:null===(t=a.data)||void 0===t?void 0:t.trace_id)||(null==a?void 0:null===(r=a.data)||void 0===r?void 0:r.traceid)||(null==a?void 0:null===(n=a.data)||void 0===n?void 0:n.traceId)||(null==a?void 0:null===(o=a.headers)||void 0===o?void 0:o["x-request-id"])||"";(0,l.renderFatalError)(Error(`url: ${s}
|
|
4
4
|
status: ${a.status}
|
|
5
5
|
traceId: ${i}
|
|
6
|
-
${e}`))}return Promise.reject(e)})}const
|
|
6
|
+
${e}`))}return Promise.reject(e)})}const L=o.default.create({baseURL:_(s.DEFAULT_EXTENSION_ENDPOINT),maxBodyLength:1/0,maxContentLength:1/0,headers:{"Content-Type":"application/json","User-Agent":E.CLI_USER_AGENT}}),R=o.default.create({baseURL:T(s.DEFAULT_EXTENSION_ENDPOINT),maxBodyLength:1/0,maxContentLength:1/0,headers:{"Content-Type":"application/json","User-Agent":E.CLI_USER_AGENT}});v(L),v(R);const m=o.default.create({baseURL:h(s.DEFAULT_EXTENSION_ENDPOINT),maxBodyLength:1/0,maxContentLength:1/0,headers:{"Content-Type":"application/json"}}),P=o.default.create({baseURL:O(s.DEFAULT_EXTENSION_ENDPOINT),maxBodyLength:1/0,maxContentLength:1/0,headers:{"Content-Type":"application/json"}});function U(e){let t=s.EXTENSION_ENDPOINTS[e];L.defaults.baseURL=_(t),m.defaults.baseURL=h(t),R.defaults.baseURL=T(t),P.defaults.baseURL=O(t)}v(m,{useThemeAuth:!0}),v(P,{useThemeAuth:!0}),function(e){e.CHECKOUT="CHECKOUT",e.THEME="THEME",e.PIXELS="WEB_PIXEL",e.SHOPPER="SHOPPER"}(e||(e={})),function(e){e.THEME_APP_BLOCK="THEME_APP_BLOCK",e.CHECKOUT_UI="CHECKOUT_UI",e.PIXELS="WEB_PIXEL_EXT",e.SHOPPER_CUSTOM_BLOCK="SHOPPER_CUSTOM_BLOCK",e.SHOPPER_CUSTOM_WEB_PAGE="SHOPPER_CUSTOM_WEB_PAGE"}(t||(t={})),function(e){e.DRAFT="DRAFT",e.WORKING_DRAFT="WORKING_DRAFT"}(r||(r={}));const C=e=>R.post("/register",JSON.stringify({...e})),N=e=>R.post("/push",e),S=e=>m.post("/auth/app/list",e),y=e=>P.post("/auth/app/ext/list",e),A=()=>m.get("/auth/partner/list");function I(e){return m.post("/auth/store/list",{partnerId:e})}function b(e){return m.post("/auth/generate/accessToken",e)}function H(e,t){return m.post("/auth/app/queryByAppKey",{partnerId:e,appKey:t})}function x(e,t){return m.post("/auth/store/queryByHandle",{partnerId:e,handle:t})}function q(){return P.post("/function/template/list")}function B(e){return P.post("/function/register",e)}function M(e){return P.post("/function/deploy",e)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,s){for(var o in s)Object.defineProperty(e,o,{enumerable:!0,get:s[o]})}(exports,{EXTENSION_ENDPOINTS:()=>o,DEFAULT_EXTENSION_ENDPOINT:()=>t,DEFAULT_EXTENSION_NAME:()=>
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,s){for(var o in s)Object.defineProperty(e,o,{enumerable:!0,get:s[o]})}(exports,{EXTENSION_ENDPOINTS:()=>o,DEFAULT_EXTENSION_ENDPOINT:()=>t,DEFAULT_EXTENSION_NAME:()=>E,ENVS:()=>_,TARGETS:()=>n,EXTENSION_LINK_PATH:()=>i,APP_VERSION_MANAGE_LINK_PATH:()=>r,TAGS:()=>p,OPTION_TYPES:()=>c,EXTENSION_NAME_LENGTH_LIMIT:()=>N,MAX_ALL_FILE_SIZE:()=>T,MAX_BLOCKS_FILE_COUNT:()=>l,MAX_BLOCKS_FILE_SIZE:()=>a,MAX_BLOCKS_FILE_SIZE_3:()=>O,SUPPORTED_ASSET_EXTS:()=>I,SUPPORTED_ASSET_EXTS_3:()=>m,SUPPORTED_BUCKETS:()=>S,SUPPORTED_BUCKETS_3:()=>d,SUPPORTED_LOCALE_EXTS:()=>u,EXTENSION_CONFIG_FILE:()=>L,CHECKOUT_UI_CONFIG_FILE:()=>P,PIXELS_CONFIG_FILE:()=>A,FUNCTION_CONFIG_FILE:()=>h,SHOPPER_CONFIG_FILE:()=>g,ERRORS:()=>x,ALL_TEMPLATES:()=>R,ALL_TEMPLATES_3:()=>U,EXTENSION_TYPES:()=>F,DEFAULT_EXTENSION_TYPE:()=>C,DEFAULT_CHECKOUT_UI_CUSTOMIZER_NAME:()=>M,DEFAULT_PIXELS_EXTENSION_NAME:()=>v,DEFAULT_SHOPPER_EXTENSION_NAME:()=>y});const e=require("../../utils/messages"),s=require("./types"),o={dev:"https://devcenter.myshoplinedev.com",test:"https://opendoc.myshoplinestg.com",pre:"https://devcenter-pre.myshopline.com",prod:"https://developer.myshopline.com"},t=o.prod,E="shopline-app-extension",_=["dev","test","pre","prod"],n=["section","head","body"],i="app/edit-extension",r="app/version-manage/add",p=["article","aside","div","footer","header","section"],c=["checkbox","radio","select"],N=50,T=10485760,l=25,a=102400,O=102400,I=[".jpg",".js",".css",".png",".svg",".hbs"],m=[".jpg",".js",".css",".png",".svg"],S=["assets","blocks","snippets","locales"],d=["blocks","components","i18n","public","compatibility"],u=[".json"],L=".shopline-cli.yml",P="shopline.ui.customizer.toml",A="shopline.pixels.extension.toml",h="shopline.function.extension.toml",g="shopline.shopper.extension.toml",x={EXTENSION_NAME_LENGTH_LIMIT:(0,e.getMessage)("extension.create.invalid_name",{limit:N}),ENV_INVALID:(0,e.getMessage)("extension.invalid_env",{envs:_.join(", ")}),ENV_FILE_NOT_FOUND:(0,e.getMessage)("extension.no_env_file"),SHOPLINE_CONFIG_NOT_FOUND:(0,e.getMessage)("extension.no_config_file",{config_name:L}),UNSUPPORTED_PROJECT_TYPE:(0,e.getMessage)("extension.invalid_type"),REPEAT_DIR_NAME:"The theme app extension directory already exists. Please rename or use another name.",INVALID_INTERPOLATION:"must be of the form {{ apps.metafields.<namespace>.<key>.value }}",PARTNER_INFO_NOT_COMPLETE:"PARTNER_INFO_NOT_COMPLETE",USER_NOT_LOGIN:"USER_NOT_LOGIN",NOT_IN_PARTNER:"NOT_IN_PARTNER"},R=["index","collections_all","collection","products/detail","cart","blogs/list","blogs/detail","404","products/search","page","customers/login","customers/register","customers/account","customers/reset_password","customers/addresses","customers/order/list","customers/order/detail","password","app_proxy"],U=["index","collections_all","collection","product","cart","blog","article","404","search","page","policy","password","gift_card","customers/login","customers/register","customers/account","customers/addresses","customers/orders","customers/order","customers/activate_account","customers/forgot_password","customers/company","app_proxy"],F=[{label:"Theme App Extension",value:s.EExtensionTypes.themeAppExtension},{label:"Checkout UI Customizer",value:s.EExtensionTypes.checkoutUiCustomizer},!1,{label:"Shopline Shopper Extension",value:s.EExtensionTypes.shopperExtension}].filter(Boolean),C="themeAppExtension",M="checkout-ui-customizer",v="pixels-extension",y="shopper-extension";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(exports,{ensureCurrentEnvs:()=>P,showEnvInfos:()=>c,showPushEnvInfos:()=>u,getCartPathFromExtension:()=>l,getCheckoutPageUrlFromExtension:()=>
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(exports,{ensureCurrentEnvs:()=>P,showEnvInfos:()=>c,showPushEnvInfos:()=>u,getCartPathFromExtension:()=>l,getCheckoutPageUrlFromExtension:()=>p,getPartnerInfoIfNeed:()=>_,ExtensionContext:()=>d});const e=require("../../utils/node-package-manager"),t=require("./const"),n=require("./env"),i=require("./extension"),r=require("./types"),E=require("./utils"),o=require("../../utils/ui/render"),s=require("../../utils/output"),a=require("../../utils/error"),I=require("./connect/context");function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}async function P(e,o,I){let N=await (0,n.resolveEnvContents)(e,o),P={},c="",u="",p="";if(N.PARTNER_ID)P.PARTNER_ID=N.PARTNER_ID,u=await (0,i.getPartnerName)(N.PARTNER_ID);else{let{id:e,partnerName:t}=await (0,i.getSelectedPartner)();P.PARTNER_ID=e,u=t}if(N.SHOPLINE_APP_KEY&&N.SHOPLINE_APP_SECRET&&N.EXTENSION_TITLE&&N.EXTENSION_UUID){P.SHOPLINE_APP_KEY=N.SHOPLINE_APP_KEY,P.SHOPLINE_APP_SECRET=N.SHOPLINE_APP_SECRET,P.EXTENSION_TITLE=N.EXTENSION_TITLE,P.EXTENSION_UUID=N.EXTENSION_UUID;let e=await (0,i.getAppName)(P.PARTNER_ID,N.SHOPLINE_APP_KEY);if(e)p=e;else throw new a.AbortError("The application name corresponding to the app key cannot be found.")}else{let e={id:P.PARTNER_ID,partnerName:u},{appKey:n,appName:r,appSecret:o}=await (0,i.getSelectedApp)(e);p=r,P.SHOPLINE_APP_KEY=n,P.SHOPLINE_APP_SECRET=o,P.EXTENSION_TITLE=t.DEFAULT_CHECKOUT_UI_CUSTOMIZER_NAME,P.EXTENSION_UUID=(0,E.generateDevUUID)()}if(N.SHOP){P.SHOP=N.SHOP;let t=(0,E.getShopHandle)(N.SHOP,e);if(t)c=await (0,i.getStoreId)(N.PARTNER_ID,t);else throw new a.AbortError(`The developer store domain \`${s.outputToken.cyan(N.SHOP)}\` you have currently configured is incorrect.`)}else{let t=await (0,i.getSelectedShop)(P.PARTNER_ID,e);P.SHOP=(0,E.getStoreUrl)(null==t?void 0:t.handle,e),c=t.storeId}if(I===r.EExtensionTypes.checkoutUiCustomizer){let{SHOPLINE_APP_KEY:e,SHOP:t}=P,n=await l(c,e,t);P.EXTENSION_RESOURCE_URL=n}return{envObject:P,partnerName:u,appName:p,storeId:c}}function c(e,t,n,i){let r=[`Org: ${e}`,`App: ${t}`,`Dev store: ${i}`,`Extension name: ${n}`];(0,o.renderInfo)({headline:["Using your previous dev settings",{char:":"}],body:[{list:{items:r}},"\nTo reset your default dev config, run",{command:"sl extension serve --reset"}]})}function u(e,t,n){let i=[`Org: ${e}`,`App: ${t}`,`Extension name: ${n}`];(0,o.renderInfo)({headline:["Your configs for dev were",{char:":"}],body:[{list:{items:i}},"\nTo reset your default dev config, run",{command:"sl extension push --reset"}]})}async function l(e,t,n){let r=await (0,i.getAvailableProductSkuId)(e,t,n);return`/cart/${r}:1`}function p(e){let{url:t,checkoutCartUrl:n,shop:i}=e,r=encodeURIComponent(`${t}/extensions`);return`https://${i}${n}?dev=${r}`}async function _(e,t){try{let r=await (0,n.resolveEnvContents)(e,t);if(r.PARTNER_ID){let e=await (0,i.getPartnerName)(r.PARTNER_ID);return{id:r.PARTNER_ID,partnerName:e}}}catch(e){}return(0,i.getSelectedPartner)()}class d{async getPackageManager(){return(0,e.getPackageManager)(this.cwd)}readEnvContent(){let e=(0,n.resolveEnvContents)(this.env,this.cwd);return e}async getInitializeLocaleEnvInNeed(){let e=await this.getPartnerInfoIfNeed(),t=await this.getAppInfo(e);return{partnerInfo:e,appInfo:t}}async getPartnerInfoIfNeed(){if(this.envObject.PARTNER_ID){let e=this.envObject.PARTNER_ID,t=await (0,i.getPartnerName)(e);return{id:e,partnerName:t}}return(0,i.getSelectedPartner)()}async getExtInfo(e){try{let t=(0,E.getExtType)(this.type),n=await (0,I.getAppExts)(e,t);return null==n?void 0:n[0]}catch(e){return null}}async getExt(e){var t,n,i;let r=await this.getExtInfo(e),o=null===(t=await (0,E.getExtensionConfig)(this.type,this.cwd))||void 0===t?void 0:t.name;return{extensionId:(null==r?void 0:r.id)?String(r.id):"",extensionUuid:null!==(n=null==r?void 0:r.uuid)&&void 0!==n?n:"",extensionName:null!==(i=null==r?void 0:r.name)&&void 0!==i?i:o}}async getFuncAppInfo(e){if(this.envObject.SHOPLINE_APP_KEY&&this.envObject.SHOPLINE_APP_SECRET&&this.envObject.EXTENSION_TITLE&&this.envObject.EXTENSION_UUID){let{SHOPLINE_APP_KEY:t,SHOPLINE_APP_SECRET:n,EXTENSION_TITLE:r,EXTENSION_UUID:E}=this.envObject,o=await (0,i.getAppName)(e.id,this.envObject.SHOPLINE_APP_KEY);if(o)return{EXTENSION_TITLE:r,appName:o,EXTENSION_UUID:E,SHOPLINE_APP_KEY:t,SHOPLINE_APP_SECRET:n};throw new a.AbortError("The application name corresponding to the app key cannot be found.")}{let{appKey:t,appName:n,appSecret:r}=await (0,i.getSelectedApp)(e),E=await this.getExt(t);return{EXTENSION_TITLE:E.extensionName,EXTENSION_UUID:E.extensionUuid,appName:n,SHOPLINE_APP_KEY:t,SHOPLINE_APP_SECRET:r}}}async getOtherAppInfo(e){if(this.envObject.SHOPLINE_APP_KEY&&this.envObject.SHOPLINE_APP_SECRET&&this.envObject.EXTENSION_TITLE&&this.envObject.EXTENSION_UUID&&this.envObject.EXTENSION_ID){let{SHOPLINE_APP_KEY:t,SHOPLINE_APP_SECRET:n,EXTENSION_TITLE:r,EXTENSION_UUID:E,EXTENSION_ID:o}=this.envObject,s=await (0,i.getAppName)(e.id,this.envObject.SHOPLINE_APP_KEY);if(s)return{EXTENSION_ID:o,EXTENSION_TITLE:r,appName:s,EXTENSION_UUID:E,SHOPLINE_APP_KEY:t,SHOPLINE_APP_SECRET:n};throw new a.AbortError("The application name corresponding to the app key cannot be found.")}if(this.type===r.EExtensionTypes.checkoutUiCustomizer||this.type.startsWith(r.EExtensionTypes.shopperExtension)){if(this.reset){var t;let{appKey:n,appName:r,appSecret:o}=await (0,i.getSelectedApp)(e),s=await (0,i.getSelectedExts)(n,(0,E.getExtType)(this.type)),a=null===(t=await (0,E.getExtensionConfig)(this.type,this.cwd))||void 0===t?void 0:t.name;return{EXTENSION_TITLE:(null==s?void 0:s.name)||a,EXTENSION_UUID:(null==s?void 0:s.uuid)||"",EXTENSION_ID:(null==s?void 0:s.id)?String(s.id):"",appName:r,SHOPLINE_APP_KEY:n,SHOPLINE_APP_SECRET:o}}let n=await (0,i.getAppName)(e.id,this.envObject.SHOPLINE_APP_KEY);return{EXTENSION_TITLE:this.envObject.EXTENSION_TITLE,EXTENSION_UUID:this.envObject.EXTENSION_UUID,EXTENSION_ID:"",appName:n,SHOPLINE_APP_KEY:this.envObject.SHOPLINE_APP_KEY,SHOPLINE_APP_SECRET:this.envObject.SHOPLINE_APP_SECRET}}{let{appKey:t,appName:n,appSecret:r}=await (0,i.getSelectedApp)(e),E=await this.getExt(t);return{EXTENSION_TITLE:E.extensionName,EXTENSION_UUID:E.extensionUuid,EXTENSION_ID:E.extensionId,appName:n,SHOPLINE_APP_KEY:t,SHOPLINE_APP_SECRET:r}}}async getAppInfo(e){return[r.EExtensionTypes.checkoutUiCustomizer,r.EExtensionTypes.themeAppExtension,r.EExtensionTypes.pixelsExtension].includes(this.type)||this.type.startsWith(r.EExtensionTypes.shopperExtension)?this.getOtherAppInfo(e):this.getFuncAppInfo(e)}constructor(e,t,n,i=!1){N(this,"type",void 0),N(this,"cwd",void 0),N(this,"env",void 0),N(this,"envObject",void 0),N(this,"reset",void 0),this.type=null!=e?e:r.EExtensionTypes.themeAppExtension,this.env=t,this.cwd=null!=n?n:process.cwd(),this.envObject=this.readEnvContent(),this.reset=i}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(exports,{createEntry:()=>x,beforeCreate:()=>
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(exports,{createEntry:()=>x,beforeCreate:()=>g,getSelectedExtType:()=>y,buildGenerateOptions:()=>E,renderSuccessMessage:()=>m});const e=require("fs-extra"),t=require("../../../utils/ui/ui"),n=require("../env"),r=require("../extension"),i=require("../types"),o=require("../utils"),s=require("../api"),u=require("../generate"),a=require("../../../utils/error"),p=require("../const"),l=require("../../../utils/path"),c=require("../../../utils/output"),d=require("../../../utils/ui/render"),f=require("../functions/info"),h=function(e){return e&&e.__esModule?e:{default:e}}(require("../../../utils/winston"));async function x(e){let t=await g(e),n=await E(t),r=await (0,u.generateExtension)(n);await m(r),h.default.log(`Extension created: ${r.directory}`)}async function g(t){var i;let s=null==t?void 0:t.name,u=null!==(i=null==t?void 0:t.cwd)&&void 0!==i?i:process.cwd(),d=await (0,n.getEnv)();h.default.log(`Current store environment: ${d}`);let f=await y(),x=(0,o.getExtensionName)(s,f);h.default.log(`Current extension name: ${x}`),function(t,n){if(!t)throw new a.AbortError("Please specify an extension name");if(t.length>p.EXTENSION_NAME_LENGTH_LIMIT)throw new a.AbortError(p.ERRORS.EXTENSION_NAME_LENGTH_LIMIT);if((0,e.existsSync)((0,l.joinPath)(n,t)))throw new a.AbortError((0,c.outputContent)`${c.outputToken.cyan(t)} directory already exists.`.value)}(x,u);let g=await (0,r.getSelectedPartner)(),E=await (0,r.getSelectedApp)(g);return{extensionName:x,cwd:u,env:d,partnerInfo:g,appInfo:E,type:f}}async function y(){let e=[];h.default.log("Loading function extension templates..."),e=await (0,s.getFunctionTemplates)(),h.default.log("Choosing extension type to create...");let n=await (0,t.renderSelectPrompt)({message:"What type of extension are you creating?",choices:(0,o.buildExtensionTypeChoice)(e)});return h.default.log(`Current selected extension type: ${n}`),n}async function E(e){let{extensionName:t,appInfo:n,type:r,env:o,cwd:s,partnerInfo:u}=e,a=async()=>{if(r===i.EExtensionTypes.themeAppExtension)return"https://github.com/shoplineos/theme-app-extension-template.git";if(r===i.EExtensionTypes.checkoutUiCustomizer)return"https://github.com/shoplineos/checkout-ui-customizer-template.git";if(r===i.EExtensionTypes.pixelsExtension)return"https://github.com/shoplinedev/checkout-ui-extensions-template.git";if(r===i.EExtensionTypes.shopperExtension)return"https://github.com/shoplineos/shopper-app-template.git";let e=await (0,f.getFunctionInfo)(r);if(e)return e.templateGit},p=await a();return h.default.log(`Current clone url: ${p}`),{name:t,app:{appKey:n.appKey,appSecret:n.appSecret},partnerId:u.id,type:r,cloneUrl:p,env:o,cwd:s}}async function m(e){let{specification:t}=e,n={headline:["Your extension was created in",{filePath:e.directory},{char:"."}],nextSteps:[],reference:[]};t.type===i.EExtensionTypes.checkoutUiCustomizer&&n.nextSteps.push(["To preview this extension along with the rest of the project, run",{command:"sl extension serve"}]),(0,d.renderSuccess)(n)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"generateExtension",{enumerable:!0,get:()=>g});const e=f(require("pathe")),t=require("./types"),a=require("./clone-repo"),i=require("../../utils/path"),n=require("../../utils/hbs"),o=require("../../utils/fs"),l=require("../../utils/node-package-manager"),r=require("../../utils/ui/ui"),s=require("../../utils/output"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"generateExtension",{enumerable:!0,get:()=>g});const e=f(require("pathe")),t=require("./types"),a=require("./clone-repo"),i=require("../../utils/path"),n=require("../../utils/hbs"),o=require("../../utils/fs"),l=require("../../utils/node-package-manager"),r=require("../../utils/ui/ui"),s=require("../../utils/output"),p=require("./env"),u=require("./utils"),d=require("./functions/generate"),c=f(require("../../utils/winston"));function f(e){return e&&e.__esModule?e:{default:e}}async function g(a){switch(a.type){case t.EExtensionTypes.themeAppExtension:await E(a);break;case t.EExtensionTypes.checkoutUiCustomizer:await w(a);break;case t.EExtensionTypes.pixelsExtension:await y(a);break;case t.EExtensionTypes.shopperExtension:await m(a);break;default:await (0,d.initFunctionExtension)(a)}return{directory:(0,i.relativizePath)(e.default.join(a.cwd,a.name),a.cwd),specification:a}}async function y(e){let{app:{appKey:t,appSecret:l},name:r,env:s,cwd:p,cloneUrl:u,partnerId:d}=e,f=(0,i.joinPath)(p,`.${r}`);c.default.log(`Downloading repository: ${u}`),await (0,a.downloadRepository)(u,f,p);let g=(0,i.joinPath)(f,"templates"),y=(0,i.joinPath)(p,r);(0,o.pathExists)(g)&&(c.default.log(`Copying template files from ${g} to ${y}`),await (0,n.recursiveHbsTemplateCopy)(g,y,{name:r},f),await h(y),c.default.log(`Write .env.${s} file`),$({partnerId:d,appKey:t,appSecret:l,name:r},s,p))}async function w(e){let{app:{appKey:t,appSecret:l},name:r,env:s,cwd:p,cloneUrl:u,partnerId:d}=e,f=(0,i.joinPath)(p,`.${r}`);c.default.log(`Downloading repository: ${u}`),await (0,a.downloadRepository)(u,f,p);let g=(0,i.joinPath)(p,r);(0,o.pathExists)(f)&&(c.default.log(`Copying template files from ${f} to ${g}`),await (0,n.recursiveHbsTemplateCopy)(f,g,{name:r},f),await h(g),c.default.log(`Write .env.${s} file`),$({partnerId:d,appKey:t,appSecret:l,name:r},s,p))}async function E(e){let{app:{appKey:t,appSecret:o},name:l,env:r,cwd:s,cloneUrl:p,partnerId:u}=e,d=(0,i.joinPath)(s,`.${l}`),f=(0,i.joinPath)(s,l);c.default.log(`Downloading repository: ${p}`),await (0,a.downloadRepository)(p,d,s,{"--branch":"main"}),c.default.log(`Copying template files from .${l} to ${l}`),await (0,n.recursiveThemeTemplateCopy)(d,f),c.default.log(`Write .env.${r} file`),$({partnerId:u,appKey:t,appSecret:o,name:l},r,s)}async function m(e){let{app:{appKey:t,appSecret:l},name:r,env:s,cwd:p,cloneUrl:u,partnerId:d}=e,f=(0,i.joinPath)(p,`.${r}`);c.default.log(`Downloading repository: ${u}`),await (0,a.downloadRepository)(u,f,p);let g=(0,i.joinPath)(p,r);(0,o.pathExists)(f)&&(c.default.log(`Copying template files from ${f} to ${g}`),await (0,n.recursiveHbsTemplateCopy)(f,g,{name:r},f),c.default.log(`Write .env.${s} file`),$({partnerId:d,appKey:t,appSecret:l,name:r},s,p))}function $(e,t,a){let i={PARTNER_ID:e.partnerId,SHOPLINE_APP_KEY:e.appKey,SHOPLINE_APP_SECRET:e.appSecret,EXTENSION_TITLE:e.name,EXTENSION_UUID:(0,u.generateDevUUID)()};(0,p.writeEnvFile)(t,i,`${a}/${e.name}`),(0,s.outputCompleted)((0,s.outputContent)`.env saved to project root`)}async function h(e){c.default.log("Get package manager...");let t=await (0,l.getPackageManager)(e);c.default.log(`Using ${t}`),c.default.log("Installing dependencies..."),await (0,r.renderTasks)([{title:`Installing dependencies with ${t}`,task:async()=>{await (0,l.addNPMDependencies)([],{type:"prod",directory:e,packageManager:t})}}]),c.default.log("Dependencies installed successfully"),(0,s.outputCompleted)((0,s.outputContent)`Dependencies installed`)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"pushExtension",{enumerable:!0,get:()=>
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"pushExtension",{enumerable:!0,get:()=>h});const e=require("../../../utils/error"),t=require("../context"),n=require("../env"),i=require("../types"),r=require("../utils"),o=require("./checkout-ui"),s=require("./pixels"),u=require("./shopper"),a=require("./theme"),l=require("./show"),p=require("../functions/push"),x=function(e){return e&&e.__esModule?e:{default:e}}(require("../../../utils/winston"));async function h(h,E){var c;let{env:w}=h,d=null!==(c=null==h?void 0:h.cwd)&&void 0!==c?c:process.cwd(),f=await (0,n.getEnv)(w);x.default.log(`Current store environment: ${f}`);let q=await (0,r.getExtensionType)(d);if(x.default.log(`Current selected extension type: ${q}`),!q)throw new e.AbortError("Unknown extension type");h.reset&&(x.default.log("Clearing environment variables..."),(0,n.clearEnvFile)(f,d));let v=new t.ExtensionContext(q,f,d,h.reset);E||(x.default.log("Show environment information..."),await (0,l.showReuseInfo)(v)),q===i.EExtensionTypes.themeAppExtension?await (0,a.pushThemeExt)(v):q===i.EExtensionTypes.checkoutUiCustomizer?await (0,o.pushCheckoutUiCustomizer)(v):q===i.EExtensionTypes.pixelsExtension?await (0,s.pushPixelsExtension)(v):q.startsWith(i.EExtensionTypes.shopperExtension)?await (0,u.pushShopperExtension)(v):await (0,p.pushFunctionExt)(v)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(exports,{getShopperType:()=>P,pushShopperExtension:()=>f});const e=g(require("fs")),t=g(require("archiver")),r=g(require("form-data")),n=require("../../../utils/error"),i=require("../api"),o=require("../../../utils/ui/ui"),a=require("../env"),s=require("../const"),u=require("../../../utils/path"),p=require("../zip"),l=require("../../../utils/ui/render"),E=require("../utils"),d=require("../../../utils/output"),c=g(require("../../../utils/winston"));function g(e){return e&&e.__esModule?e:{default:e}}function P(e){let t={1:i.ERegisterType.SHOPPER_CUSTOM_BLOCK,2:i.ERegisterType.SHOPPER_CUSTOM_WEB_PAGE},r=e.split("--")[1];return t[r]}async function f(r){var i;let o=r.readEnvContent(),l=P(r.type);c.default.log("Create web shopper extension instance...");let E=await S(o,l);(0,d.outputDebug)((0,d.outputContent)`Write ${d.outputToken.json(E)} content to ${d.outputToken.cyan(`.env.${r.env}`)} file to ${r.cwd}`),c.default.log(`Write .env.${r.env} file...`),(0,a.writeEnvFile)(r.env,E,r.cwd);let g=(0,u.joinPath)(r.cwd,`${o.EXTENSION_TITLE}.zip`);c.default.log("Compress shopper extension..."),await (i=r.cwd,new Promise((r,o)=>{(0,d.outputDebug)((0,d.outputContent)`Compressing to ${d.outputToken.path(g)}`);let a=(0,t.default)("zip",{zlib:{level:9}}),u=e.default.createWriteStream(g);u.on("close",()=>{}),u.on("finish",()=>{r({size:a.pointer()})}),a.on("error",()=>{o(new n.AbortError("Failed to compress!"))}),a.pipe(u),a.glob("previewImage.png",{cwd:i}).glob("index.html",{cwd:i}).glob("assets/css/**/*.css",{cwd:i}).glob("assets/js/**/*.js",{cwd:i}).glob("assets/images/**/*.{png,jpg,gif,svg,webp,lottie,apng}",{cwd:i}).glob(s.SHOPPER_CONFIG_FILE,{cwd:i}).finalize()})),c.default.log("Push shopper extension..."),await I(E,g,r,l),c.default.log("Push shopper extension success!"),(0,d.outputDebug)("Remove .zip file"),c.default.log("Remove .zip file..."),(0,p.removeZip)(g)}async function S(e,t){let r=e;return r.EXTENSION_ID&&r.EXTENSION_UUID?e:(await (0,o.renderTasks)([{title:"Registering with SHOPLINE",task:async()=>{let o=await (0,i.createExtensionInstance)({appKey:e.SHOPLINE_APP_KEY,appSecret:e.SHOPLINE_APP_SECRET,name:e.EXTENSION_TITLE,type:t,category:i.ECategory.SHOPPER}),{id:a,uuid:s}=o||{};if(!a||!s)throw new n.AbortError("Failed to register. Please retry again!");r.EXTENSION_ID=a,r.EXTENSION_UUID=s}}]),r)}async function I(e,t,r,n){(0,d.outputDebug)((0,d.outputContent)`Pushing ${d.outputToken.path(t)} file to remote`),await (0,o.renderTasks)([{title:"Pushing your extension to Shopline",task:async()=>{await T(e,t,r,n)}}])}async function T(t,o,a,s){let u=e.default.createReadStream(o),p=new r.default;p.append("extensionFile",u),p.append("appKey",t.SHOPLINE_APP_KEY),p.append("appSecret",t.SHOPLINE_APP_SECRET),p.append("extensionId",t.EXTENSION_ID),p.append("extensionUuid",t.EXTENSION_UUID),p.append("type",s),p.append("category",i.ECategory.SHOPPER);let d=await (0,i.pushExtension)(p);if(d){let e=(0,E.getAppVersionManageLink)({appKey:t.SHOPLINE_APP_KEY,env:a.env});(0,l.renderSuccess)({headline:["Pushed",{userInput:t.EXTENSION_TITLE},"to a draft on",(0,E.formatTime)(d.updateTime)],body:["Visit",{link:{label:e,url:e}},"to version and publish your extension",{char:"."}]})}else(0,l.renderFatalError)(new n.AbortError(`Pushed to SHOPLINE with errors on ${(0,E.formatTime)()}`))}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,o){for(var t in o)Object.defineProperty(e,t,{enumerable:!0,get:o[t]})}(exports,{TypeSchema:()=>o,MetafieldSchema:()=>t,NewExtensionPointSchema:()=>i,ApiVersionSchema:()=>a,CapabilitiesSchema:()=>n,BaseUiCustomizerSchema:()=>s});const e=require("../../utils/schema"),o=e.zod.object({type:e.zod.string().default("checkout_ui_customizer"),name:e.zod.string().optional()}),t=e.zod.object({namespace:e.zod.string(),key:e.zod.string()}),i=e.zod.object({target:e.zod.string(),module:e.zod.string(),metafields:e.zod.array(t).optional()}),a=e.zod.string(),n=e.zod.object({network_access:e.zod.boolean().optional(),block_progress:e.zod.boolean().optional(),api_access:e.zod.boolean().optional()}),s=e.zod.object({name:e.zod.string(),type:e.zod.string().default("checkout_ui_customizer"),extensionPoints:e.zod.any().optional(),capabilities:n.optional()});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,o){for(var t in o)Object.defineProperty(e,t,{enumerable:!0,get:o[t]})}(exports,{TypeSchema:()=>o,MetafieldSchema:()=>t,NewExtensionPointSchema:()=>i,ApiVersionSchema:()=>a,CapabilitiesSchema:()=>n,BaseUiCustomizerSchema:()=>s});const e=require("../../utils/schema"),o=e.zod.object({type:e.zod.string().or(e.zod.number()).default("checkout_ui_customizer"),name:e.zod.string().optional()}),t=e.zod.object({namespace:e.zod.string(),key:e.zod.string()}),i=e.zod.object({target:e.zod.string(),module:e.zod.string(),metafields:e.zod.array(t).optional()}),a=e.zod.string(),n=e.zod.object({network_access:e.zod.boolean().optional(),block_progress:e.zod.boolean().optional(),api_access:e.zod.boolean().optional()}),s=e.zod.object({name:e.zod.string(),type:e.zod.string().default("checkout_ui_customizer"),extensionPoints:e.zod.any().optional(),capabilities:n.optional()});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t,n;Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(exports,{ExtensionType:()=>e,EFunctionTypes:()=>t,EExtensionTypes:()=>n}),function(e){e.THEME_APP_EXTENSION="THEME_APP_EXTENSION",e.CHECKOUT_UI_CUSTOMIZER="CHECKOUT_UI_CUSTOMIZER"}(e||(e={})),(t||(t={})).PaymentCustomization="PaymentCustomization",function(e){e.themeAppExtension="themeAppExtension",e.checkoutUiCustomizer="checkoutUiCustomizer",e.pixelsExtension="pixelsExtension"}(n||(n={}));
|
|
1
|
+
"use strict";var e,t,n;Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(exports,{ExtensionType:()=>e,EFunctionTypes:()=>t,EExtensionTypes:()=>n}),function(e){e.THEME_APP_EXTENSION="THEME_APP_EXTENSION",e.CHECKOUT_UI_CUSTOMIZER="CHECKOUT_UI_CUSTOMIZER"}(e||(e={})),(t||(t={})).PaymentCustomization="PaymentCustomization",function(e){e.themeAppExtension="themeAppExtension",e.checkoutUiCustomizer="checkoutUiCustomizer",e.pixelsExtension="pixelsExtension",e.shopperExtension="shopperExtension"}(n||(n={}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var i in t)Object.defineProperty(e,i,{enumerable:!0,get:t[i]})}(exports,{extractSchema:()=>
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var i in t)Object.defineProperty(e,i,{enumerable:!0,get:t[i]})}(exports,{extractSchema:()=>y,removeFile:()=>x,getEnvPath:()=>N,formatTime:()=>I,getExtensionLink:()=>_,getAppVersionManageLink:()=>O,getDeveloperPlatformLink:()=>S,getStoreUrl:()=>w,getShopHandle:()=>v,validateSchemaError:()=>F,isMatchedInterpolation:()=>P,getNonMatchedOptionInterpolation:()=>$,buildPartnerChoice:()=>g,buildAppChoice:()=>C,buildExtChoice:()=>L,buildExtensionTypeChoice:()=>A,buildStoreChoice:()=>U,getExtensionType:()=>b,getExtensionConfig:()=>j,generateDevUUID:()=>q,getExtShowType:()=>D,getExtType:()=>X,getExtensionName:()=>G});const e=require("path"),t=d(require("fs-extra")),i=require("uuid"),n=require("light-date"),o=d(require("js-yaml")),r=require("./const"),s=require("./types"),a=require("./api"),l=d(require("../../utils/colors")),p=require("../../utils/path"),u=require("../../utils/fs"),E=require("../../utils/toml"),c=require("./schemas"),f=require("../../utils/error"),m=require("./functions/schemas"),h=require("./functions/info"),T=require("./push/shopper");function d(e){return e&&e.__esModule?e:{default:e}}function y(e){let t=e.match(/{{\s*#schema\s*}}([\s\S]*?){{\s*\/schema\s*}}/);return t?t[1]:""}function x(e){t.default.existsSync(e)&&t.default.removeSync(e)}function N(t,i=process.cwd()){return t?(0,e.join)(i,`.env.${t}`):(0,e.join)(i,".env")}function I(e=Date.now(),t="{yyyy}-{MM}-{dd} {HH}:{mm}:{ss}"){let i=new Date(e);return(0,n.format)(i,t)}function _(e){let t=r.DEFAULT_EXTENSION_ENDPOINT;return e.env&&(t=r.EXTENSION_ENDPOINTS[e.env]),`${t}/${r.EXTENSION_LINK_PATH}/${e.appKey}/${e.extensionUuid}`}function O(e){let t=r.DEFAULT_EXTENSION_ENDPOINT;return e.env&&(t=r.EXTENSION_ENDPOINTS[e.env]),`${t}/${r.APP_VERSION_MANAGE_LINK_PATH}?appKey=${e.appKey}`}function S(e){return e?r.EXTENSION_ENDPOINTS[e]:r.DEFAULT_EXTENSION_ENDPOINT}function w(e,t){return"dev"===t?`${e}.myshoplinedev.com`:"test"===t?`${e}.myshoplinestg.com`:"pre"===t?`${e}.preview.myshopline.com`:`${e}.myshopline.com`}function v(e,t){if("dev"===t){let t=e.match(/^([^.]+)\.myshoplinedev\.com$/);return null==t?void 0:t[1]}if("test"===t){let t=e.match(/^([^.]+)\.myshoplinestg\.com$/);return null==t?void 0:t[1]}if("pre"===t){let t=e.match(/^([^.]+)\.preview\.myshopline\.com$/);return null==t?void 0:t[1]}if("prod"===t){let t=e.match(/^([^.]+)\.myshopline\.com$/);return null==t?void 0:t[1]}let i=e.match(/^([^.]+)\.myshopline\.com$/);return null==i?void 0:i[1]}function F(e){return(t,i)=>{if(i)throw Error(`[${e}] Invalid tag 'schema': ${i}: ${t}`);if(t)throw Error(`[${e}] Invalid schema: ${t}`);throw Error(`[${e}] Invalid schema`)}}function P(e){return/^{{\s*apps\.metafields\.\w+(\.\w+)+?(?:\.value)\s*}}$/.test(e)}function $(e){let t=e.map((e,t)=>{if(Object.prototype.hasOwnProperty.call(e,"options")&&"string"==typeof e.options){let i=r.OPTION_TYPES.includes(e.type);if(P(e.options)&&i)return{pass:!0,reason:"",field:""};if(P(e.options))return{pass:!1,reason:`must be one of ${r.OPTION_TYPES.join(", ")}`,field:`settings[${t}].type`};if(i)return{pass:!1,reason:r.ERRORS.INVALID_INTERPOLATION,field:`settings[${t}].options`}}return{pass:!0,reason:"",field:""}});return t.filter(e=>!e.pass)}function g(e){return e.map(e=>({label:e.partnerName,value:e.id}))}function C(e,t){return e.map(e=>({label:`${e.appName} ${l.default.magenta(`by ${t}`)}`,value:e}))}function L(e){return[...e.map(e=>({label:`${e.name} ${l.default.magenta(e.type)}`,value:e})),{label:"Register a new extension",value:{}}]}function A(e){let t=r.EXTENSION_TYPES;return e.length>0?t.concat(e.map(e=>({label:`${e.templateName} - Function`,value:e.templateName}))):t}function U(e){return e.map(e=>({label:e.storeName,value:e}))}async function b(e){let i=(0,p.joinPath)(e,r.EXTENSION_CONFIG_FILE),n=(0,p.joinPath)(e,r.CHECKOUT_UI_CONFIG_FILE),a=(0,p.joinPath)(e,r.FUNCTION_CONFIG_FILE),l=(0,p.joinPath)(e,r.PIXELS_CONFIG_FILE),T=(0,p.joinPath)(e,r.SHOPPER_CONFIG_FILE);if(await (0,u.fileExists)(i)){let e=o.default.load(t.default.readFileSync(i,"utf8"));if("extension"===e.project_type)return s.EExtensionTypes.themeAppExtension}if(await (0,u.fileExists)(n)){let e=await (0,u.readFile)(n),t=(0,E.decodeToml)(e),{type:i}=await c.TypeSchema.parse(t);if("checkout_ui_customizer"===i)return s.EExtensionTypes.checkoutUiCustomizer}if(await (0,u.fileExists)(a)){let e=await (0,u.readFile)(a),t=(0,E.decodeToml)(e),{type:i}=await m.FunctionTypeSchema.parse(t);if(await (0,h.isFunctionType)(i))return i}if(await (0,u.fileExists)(l)){let e=await (0,u.readFile)(l),t=(0,E.decodeToml)(e),{type:i}=await c.TypeSchema.parse(t);if("shopline-pixels-extension"===i)return s.EExtensionTypes.pixelsExtension}if(await (0,u.fileExists)(T)){let e=await (0,u.readFile)(T),t=(0,E.decodeToml)(e),{type:i}=await c.TypeSchema.parse(t);if([1,2].includes(i))return`${s.EExtensionTypes.shopperExtension}--${i}`}throw new f.AbortError("The directory you are in is not a valid extension project.")}async function j(e,i){if(e===s.EExtensionTypes.themeAppExtension){let e=(0,p.joinPath)(i,r.EXTENSION_CONFIG_FILE);if(await (0,u.fileExists)(e)){let i=o.default.load(t.default.readFileSync(e,"utf8"));if("extension"===i.project_type)return{type:s.EExtensionTypes.themeAppExtension,name:"theme-app-extension"}}}if(e===s.EExtensionTypes.checkoutUiCustomizer){let e=(0,p.joinPath)(i,r.CHECKOUT_UI_CONFIG_FILE);if(await (0,u.fileExists)(e)){let t=await (0,u.readFile)(e),i=(0,E.decodeToml)(t),{name:n}=await c.TypeSchema.parse(i);return{type:s.EExtensionTypes.checkoutUiCustomizer,name:n}}}if(e===s.EExtensionTypes.pixelsExtension){let e=(0,p.joinPath)(i,r.PIXELS_CONFIG_FILE);if(await (0,u.fileExists)(e)){let t=await (0,u.readFile)(e),i=(0,E.decodeToml)(t),{name:n}=await c.TypeSchema.parse(i);return{type:s.EExtensionTypes.pixelsExtension,name:n}}}let n=(0,p.joinPath)(i,r.FUNCTION_CONFIG_FILE);if(await (0,u.fileExists)(n)){let e=await (0,u.readFile)(n),t=(0,E.decodeToml)(e),{type:i,name:o}=await m.FunctionTypeSchema.parse(t);if(await (0,h.isFunctionType)(i))return{type:i,name:o}}if(e.startsWith(s.EExtensionTypes.shopperExtension)){let t=(0,p.joinPath)(i,r.SHOPPER_CONFIG_FILE);if(await (0,u.fileExists)(t)){let i=await (0,u.readFile)(t),n=(0,E.decodeToml)(i),{name:o}=await c.TypeSchema.parse(n);return{type:(0,T.getShopperType)(e),name:o}}}throw new f.AbortError(`Invalid extension type: ${e}`)}function q(){return`dev-${(0,i.v4)()}`}function D(e){let t=r.EXTENSION_TYPES.find(t=>t.value===e);return null==t?void 0:t.label}function X(e){return e===s.EExtensionTypes.checkoutUiCustomizer?a.ERegisterType.CHECKOUT_UI:e===s.EExtensionTypes.themeAppExtension?a.ERegisterType.THEME_APP_BLOCK:e===s.EExtensionTypes.pixelsExtension?a.ERegisterType.PIXELS:e.startsWith(s.EExtensionTypes.shopperExtension)?(0,T.getShopperType)(e):void 0}function G(e,t){return e||(t===s.EExtensionTypes.checkoutUiCustomizer?"checkout-ui-customizer":t===s.EExtensionTypes.themeAppExtension?"theme-app-extension":t===s.EExtensionTypes.pixelsExtension?"shopline-pixels-extension":t.startsWith(s.EExtensionTypes.shopperExtension)?"shopper-extension":t||r.DEFAULT_EXTENSION_NAME)}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(exports,{createNewTheme:()=>p,getThemes:()=>R,getThemeInfo:()=>g,uploadTheme:()=>
|
|
2
|
-
${JSON.stringify(null!==(
|
|
3
|
-
status: ${l.status}
|
|
4
|
-
traceId: ${s}
|
|
5
|
-
${e}`))}return Promise.reject(e)});const p=e=>v.post("/theme/upload",e),R=async()=>v.get("/themes"),g=e=>v.get(`/theme/${e}`),_=e=>v.post("/files/upload",e),m=e=>v.get("/files",{params:{themeId:e}}),h=(e,t)=>v.delete("/files",{data:{themeId:e,fileNames:t}}),T=e=>v.put("/file",e),O=e=>v.post("/file",e),I=e=>v.get(`/theme/${e}/download`,{responseType:"stream"}),S=(e,t)=>v.get("/files",{params:{themeId:e,fileNames:t.join(",")}});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(exports,{createNewTheme:()=>p,getThemes:()=>R,getThemeInfo:()=>g,uploadTheme:()=>m,getThemeFileList:()=>v,deleteFiles:()=>_,updateFile:()=>O,createFile:()=>T,downloadTheme:()=>h,getThemeFileDetail:()=>I});const e=u(require("axios")),t=u(require("form-data")),r=u(require("../../../helpers/config")),o=require("../../../utils/const"),i=require("../../../utils/error"),l=require("../const"),s=u(require("../../../utils/debug")),n=u(require("../../../utils/winston")),a=require("../../../helpers/sentry"),d=u(require("../no-second-check"));function u(e){return e&&e.__esModule?e:{default:e}}const{loginInfo:c,currentStore:E}=r.default,f=e.default.create({baseURL:`${E}/api/website/admin/theme/cli`,maxContentLength:1/0,maxBodyLength:1/0});f.interceptors.request.use(e=>{if(c){let t=Object.keys(c).map(e=>`${e}=${c[e]}`).join(";"),i=r.default.dfpToken||"";Object.assign(e.headers,{cookie:t,"dfp-token":i,"User-Agent":o.CLI_USER_AGENT})}return(null==e?void 0:e.data)instanceof t.default&&Object.assign(e.headers,null==e?void 0:e.data.getHeaders()),e}),f.interceptors.response.use(async e=>{var t,r,o,u,c,E,f,p,R,g;if("stream"===e.config.responseType)return e;let m=null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.success,v=null==e?void 0:null===(r=e.data)||void 0===r?void 0:r.code,{config:_}=e;if(s.default.printResponse(_,e),(0,a.reportHttpRes)(e),n.default.logHttp({type:"response",method:e.config.method,url:e.config.baseURL+e.config.url,params:e.config.params,body:e.data,status:e.status,traceId:(null==e?void 0:null===(o=e.data)||void 0===o?void 0:o.trace_id)||(null==e?void 0:null===(u=e.headers)||void 0===u?void 0:u["x-request-id"])||""}),l.ERROR_CODES.THEME_COUNT_LIMIT.includes(v))throw Error(l.ERRORS.THEME_COUNT_LIMIT);if(l.ERROR_CODES.DEVELOPMENT_THEME_NOT_EXIST.includes(v))throw Error(l.ERRORS.THEME_IS_INVALID);if(l.ERROR_CODES.FEATURE_KEY_NOT_EXIST.includes(v))throw Error(l.ERRORS.FEATURE_KEY_NOT_EXIST);if(l.ERROR_CODES.NO_SECOND_CHECK.includes(v))await d.default.run();else if(l.ERROR_CODES.INVALID_FILE.includes(v))throw new i.ValidatorError({code:v,errors:e.data.data.errors,message:e.data.msg});if(!m)throw new i.AbortError(`${null!==(p=null==e?void 0:null===(E=e.config)||void 0===E?void 0:E.baseURL)&&void 0!==p?p:""}${null!==(R=null==e?void 0:null===(f=e.config)||void 0===f?void 0:f.url)&&void 0!==R?R:""}
|
|
2
|
+
${JSON.stringify(null!==(g=null==e?void 0:e.data)&&void 0!==g?g:{},null,2)}`);return null==e?void 0:null===(c=e.data)||void 0===c?void 0:c.data},e=>{let t=new i.AbortError(JSON.stringify(e.response.data,null,2));return Promise.reject(t)});const p=e=>f.post("/theme/upload",e),R=async()=>f.get("/themes"),g=e=>f.get(`/theme/${e}`),m=e=>f.post("/files/upload",e),v=e=>f.get("/files",{params:{themeId:e}}),_=(e,t)=>f.delete("/files",{data:{themeId:e,fileNames:t}}),O=e=>f.put("/file",e),T=e=>f.post("/file",e),h=e=>f.get(`/theme/${e}/download`,{responseType:"stream"}),I=(e,t)=>f.get("/files",{params:{themeId:e,fileNames:t.join(",")}});
|