@lightspeed/crane 0.1.0 → 1.0.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.
Files changed (64) hide show
  1. package/README.md +113 -0
  2. package/dist/app.mjs +1 -1
  3. package/dist/cli.mjs +6 -6
  4. package/package.json +12 -3
  5. package/template/package.json +2 -2
  6. package/template/sections/example-section/ExampleSection.vue +53 -0
  7. package/template/sections/example-section/assets/autumn_looks_mobile_high.jpeg +0 -0
  8. package/template/sections/example-section/assets/autumn_looks_mobile_low.jpeg +0 -0
  9. package/template/sections/example-section/assets/autumn_looks_pc_high.jpeg +0 -0
  10. package/template/sections/example-section/assets/autumn_looks_pc_low.jpeg +0 -0
  11. package/template/sections/example-section/assets/bianka_wardrobe_mobile_high.jpeg +0 -0
  12. package/template/sections/example-section/assets/bianka_wardrobe_mobile_low.jpeg +0 -0
  13. package/template/sections/example-section/assets/bianka_wardrobe_pc_high.jpeg +0 -0
  14. package/template/sections/example-section/assets/bianka_wardrobe_pc_low.jpeg +0 -0
  15. package/template/sections/example-section/assets/custom_section_showcase_1_preview.jpg +0 -0
  16. package/template/sections/example-section/assets/custom_section_showcase_2_preview.png +0 -0
  17. package/template/sections/example-section/assets/new_arrivals_mobile_high.jpeg +0 -0
  18. package/template/sections/example-section/assets/new_arrivals_mobile_low.jpeg +0 -0
  19. package/template/sections/example-section/assets/new_arrivals_pc_high.jpeg +0 -0
  20. package/template/sections/example-section/assets/new_arrivals_pc_low.jpeg +0 -0
  21. package/template/sections/example-section/assets/new_tshirts_collection_mobile_high.jpeg +0 -0
  22. package/template/sections/example-section/assets/new_tshirts_collection_mobile_low.jpeg +0 -0
  23. package/template/sections/example-section/assets/new_tshirts_collection_pc_high.jpeg +0 -0
  24. package/template/sections/example-section/assets/new_tshirts_collection_pc_low.jpeg +0 -0
  25. package/template/sections/example-section/assets/sport_look_mobile_high.jpeg +0 -0
  26. package/template/sections/example-section/assets/sport_look_mobile_low.jpeg +0 -0
  27. package/template/sections/example-section/assets/sport_look_pc_high.jpeg +0 -0
  28. package/template/sections/example-section/assets/sport_look_pc_low.jpeg +0 -0
  29. package/template/sections/example-section/assets/story_of_jane_mobile_high.jpeg +0 -0
  30. package/template/sections/example-section/assets/story_of_jane_mobile_low.jpeg +0 -0
  31. package/template/sections/example-section/assets/story_of_jane_pc_high.jpeg +0 -0
  32. package/template/sections/example-section/assets/story_of_jane_pc_low.jpeg +0 -0
  33. package/template/sections/example-section/assets/summer_accessories_mobile_high.jpeg +0 -0
  34. package/template/sections/example-section/assets/summer_accessories_mobile_low.jpeg +0 -0
  35. package/template/sections/example-section/assets/summer_accessories_pc_high.jpeg +0 -0
  36. package/template/sections/example-section/assets/summer_accessories_pc_low.jpeg +0 -0
  37. package/template/sections/example-section/assets/trending_footwear_mobile_high.jpeg +0 -0
  38. package/template/sections/example-section/assets/trending_footwear_mobile_low.jpeg +0 -0
  39. package/template/sections/example-section/assets/trending_footwear_pc_high.jpeg +0 -0
  40. package/template/sections/example-section/assets/trending_footwear_pc_low.jpeg +0 -0
  41. package/template/sections/example-section/client.ts +5 -0
  42. package/template/sections/example-section/component/image/Image.vue +161 -0
  43. package/template/sections/example-section/component/image/ImagesGrid.vue +244 -0
  44. package/template/sections/example-section/component/title/Title.vue +53 -0
  45. package/template/sections/example-section/entity/color.ts +4 -0
  46. package/template/sections/example-section/server.ts +5 -0
  47. package/template/sections/example-section/settings/content.ts +68 -0
  48. package/template/sections/{block-example → example-section}/settings/design.ts +30 -43
  49. package/template/sections/example-section/settings/translations.ts +59 -0
  50. package/template/sections/example-section/showcases/1.ts +160 -0
  51. package/template/sections/example-section/showcases/2.ts +156 -0
  52. package/template/sections/example-section/showcases/translations.ts +41 -0
  53. package/template/templates/template.ts +102 -79
  54. package/template/sections/block-example/CustomBlock.vue +0 -58
  55. package/template/sections/block-example/assets/showcase_preview_1.png +0 -0
  56. package/template/sections/block-example/assets/showcase_preview_2.png +0 -0
  57. package/template/sections/block-example/client.ts +0 -5
  58. package/template/sections/block-example/server.ts +0 -5
  59. package/template/sections/block-example/settings/content.ts +0 -41
  60. package/template/sections/block-example/settings/translations.ts +0 -35
  61. package/template/sections/block-example/showcases/1.ts +0 -88
  62. package/template/sections/block-example/showcases/2.ts +0 -88
  63. package/template/sections/block-example/showcases/translations.ts +0 -23
  64. /package/template/sections/{block-example → example-section}/type.ts +0 -0
package/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # Crane
2
+
3
+ ### Preface
4
+
5
+ Crane is a command line interface that aids the creation, build and deployment of fully customisable website components (so-called sections)
6
+ within the Lightspeed E-Commerce ecosystem.
7
+
8
+ ### Glossary
9
+
10
+ - Custom application: a small project that defines the boundaries of custom building-blocks that belong to one particular topic.
11
+ - Custom section: smallest building block to define a particular custom functionality.
12
+ - Default section: existing building block within the Lightspeed E-Commerce product.
13
+ - Settings
14
+ - Content: configuration regarding the content of a custom section, e.g.: titles, buttons and texts.
15
+ - Design: similarly, the design aspects of a custom section configuration, e.g.: colours and font size.
16
+ - Showcase: the highlight of a custom section with very specific configuration values.
17
+
18
+ ### Prerequisites
19
+
20
+ In order to use this utility, first a Lightspeed specific application needs to be created containing the necessary
21
+ permissions granted, as well as an optional test site in order to verify the changes made in a custom application.
22
+
23
+ ```For both the test site and the permission, please contact you Partner Manager!```
24
+
25
+ ### Installation
26
+
27
+ The following commands need to be performed to install the required dependencies and Crane utility, along with our linter:
28
+ ```
29
+ npm install vite
30
+ npm install vue
31
+ npm install @lightspeed/crane@latest
32
+ npm install @lightspeed/eslint-config-crane@latest
33
+ ```
34
+
35
+ ### Commands
36
+
37
+ ```
38
+ npx @lightspeed/crane@latest init --app <name>
39
+ ```
40
+ Creates an application folder inside the current directory with default resources (configuration, assets and JS files).
41
+ By default, there is one custom section located in the folder "sections" named "example-section".
42
+
43
+ ```
44
+ npx @lightspeed/crane@latest init --section <name>
45
+ ```
46
+ Creates an additional custom section. The command will create files necessary for this section and locate them in
47
+ folder "sections" under the directory with the given name.
48
+
49
+ ```
50
+ npx @lightspeed/crane@latest build
51
+ ```
52
+ Builds the application. Upon a successful build, the following directories can be located inside the application folder: ```dist``` and ```node_modules```.
53
+ A prompt describing the next steps will be shown.
54
+
55
+ ```
56
+ npx @lightspeed/crane@latest deploy
57
+ ```
58
+ Deploys the application to the Lightspeed E-Commerce platform.
59
+
60
+ ```
61
+ npx @lightspeed/crane@latest --help
62
+ ```
63
+ Displays list of available commands, resource descriptions and actions.
64
+
65
+ ### Example
66
+
67
+ The following example will demonstrate how to create a custom application with 2 sections and to deploy it to
68
+ Lightspeed E-Series, provided the necessary prerequisites are fulfilled.
69
+
70
+ 1. Initialization of the application with the name: 'my-app'
71
+ ```
72
+ npx @lightspeed/crane@latest init --app my-app
73
+ ```
74
+ 2. Switching the directory
75
+ ```
76
+ cd my-app
77
+ ```
78
+ 3. Creation of additional custom sections, in case it is necessary. **Optional**
79
+ ```
80
+ npx @lightspeed/crane@latest init --section my-section
81
+ ```
82
+ 4. Editing ```crane.config.json```
83
+
84
+ In order to successfully deploy a custom application, its credentials are need to be specified.
85
+ This can be done by specifying the proper ```client_id``` and ```client_secret``` in ```crane.config.json```, located in the root of the custom application.
86
+ ```json
87
+ {
88
+ "app_client_id": "{client_id}",
89
+ "app_secret_key": "{client_secret}"
90
+ }
91
+ ```
92
+ 5. Building the application
93
+ ```
94
+ npx @lightspeed/crane@latest build
95
+ ```
96
+ 6. Deploying the application
97
+ ```
98
+ npx @lightspeed/crane@latest deploy
99
+ ```
100
+
101
+ ### Common issues and remedies
102
+
103
+ 1. In case of a failed build command execution, the following action needs to be
104
+ performed, followed by a repeat execution of said command:
105
+ ```
106
+ npm install
107
+ ```
108
+
109
+ 2. HTTP 401 during deployment:
110
+ Invalid credentials provided, please verify that the ```crane.config.json``` file is correct.
111
+
112
+ 3. HTTP 403 during deployment:
113
+ Insufficient permissions, please contact your Partner Manager regarding the necessary permissions.
package/dist/app.mjs CHANGED
@@ -1 +1 @@
1
- import{getCurrentInstance as k,ref as b,computed as o,reactive as d,createSSRApp as E}from"vue";import{renderToString as C}from"vue/server-renderer";const m=new Map;function c(){const n=(r,a,i,u,g)=>{m.set(r._uid,{context:b(a),content:b(i),design:b(u),defaults:b(g)})},t=(r,a,i)=>{const u=m.get(r._uid);u!==void 0&&(u.content.value=a,u.design.value=i)},e=k()?.appContext.app._uid??-1,l=m.get(e);return{init:n,update:t,context:l?.context,content:l?.content,design:l?.design,defaults:l?.defaults}}function x(n){const t=c(),e=o(()=>{const a=t.content.value[n];if(a!==void 0){if(typeof a=="string")return a;throw new Error(`Element ${n} is not inputbox`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value);return d({hasContent:l,value:r})}function h(n){const t=c(),e=o(()=>{const a=t.content.value[n];if(a!==void 0){if(typeof a=="string")return a;throw new Error(`Element ${n} is not textarea`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value);return d({hasContent:l,value:r})}function I(n){return"title"in n&&"type"in n}function $(n){const t=c(),e=o(()=>{const u=t.content.value[n];if(u!==void 0){if(I(u))return u;throw new Error(`Element ${n} is not action link`)}}),l=o(()=>e.value?.title),r=o(()=>e.value?.link),a=o(()=>!!l.value),i=o(()=>!!r.value);return d({title:l,link:r,hasTitle:a,hasLink:i,performAction:()=>{if(e.value!==void 0)switch(e.value.buttonType){case"HYPER_LINK":e.value.link&&window.open(e.value.link,"_blank");break;case"GO_TO_STORE_LINK":window.open("/products");break;case"MAIL_LINK":e.value.email&&window.open(`mailto:${e.value.email}`,"_self");break;case"TEL_LINK":e.value.phone&&window.open(`tel:${e.value.phone}`,"_self");break;case"SCROLL_TO_TILE":{if(typeof document>"u")return;const u=e.value.tileId;document.getElementById(`tile-${u}`)?.scrollIntoView();break}default:throw new Error("Unknown ButtonType: ")}}})}function T(n){return"bucket"in n&&"borderInfo"in n&&"set"in n}function _(n){const t=c(),e=o(()=>{const s=t.content.value[n];if(s!==void 0){if(T(s))return s;throw new Error(`Element ${n} is not image`)}}),l=o(()=>e.value===void 0?"":t.context.value.imageBuckets?.[e.value?.bucket]),r=o(()=>e.value!==void 0),a=o(()=>`${l.value}/${e.value?.set?.["cropped-webp-100x200"]?.url}`),i=o(()=>`${l.value}/${e.value?.set?.["cropped-webp-1000x2000"]?.url}`),u=o(()=>`${l.value}/${e.value?.set?.["webp-200x200"]?.url}`),g=o(()=>`${l.value}/${e.value?.set?.["webp-2000x2000"]?.url}`);return d({hasContent:r,lowResolutionMobileImage:a,highResolutionMobileImage:i,lowResolutionDesktopImage:u,highResolutionDesktopImage:g})}function z(n){return"enabled"in n}function D(n){const t=c(),e=o(()=>{const a=t.content.value[n];if(a!==void 0){if(z(a))return a;throw new Error(`Element ${n} is not toggle`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value?.enabled);return d({hasContent:l,value:r})}function L(n){const t=c(),e=o(()=>{const a=t.content.value[n];if(a!==void 0){if(typeof a=="string")return a;throw new Error(`Element ${n} is not selectbox`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value);return d({hasContent:l,value:r})}function y(n,t){if(t===void 0)return;if(!t.startsWith("global."))return t;const e=t.split(".").at(2);if(e!==void 0)return n.fontFamily[e]}function S(n,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const e=t.split(".").at(2);if(e!==void 0)return n.textSize[e]}function f(n,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const e=t.split(".").at(2);if(e!==void 0)return n.color[e]}function R(n){const t=c(),e=o(()=>{const s=t.design.value[n],v=t.defaults.value[n],p=t.context.value.globalDesign;return{font:s?.font??y(p,v?.font),size:s?.size??S(p,v?.size),bold:s?.bold??v?.bold,italic:s?.italic??v?.italic,color:s?.color??f(p,v?.color),visible:s?.visible??v?.visible??!1}}),l=o(()=>e.value?.font),r=o(()=>e.value?.size),a=o(()=>e.value?.bold),i=o(()=>e.value?.italic),u=o(()=>e.value?.color),g=o(()=>e.value?.visible);return d({font:l,size:r,bold:a,italic:i,color:u,visible:g})}function B(n){const t=c(),e=o(()=>{const s=t.design.value[n],v=t.defaults.value[n],p=t.context.value.globalDesign;return{appearance:s?.appearance??v?.appearance,font:s?.font??y(p,v?.font),size:s?.size??v?.size,style:s?.style??v?.style,color:s?.color??f(p,v?.color),visible:s?.visible??v?.visible??!1}}),l=o(()=>e.value?.appearance),r=o(()=>e.value?.font),a=o(()=>e.value?.size),i=o(()=>e.value?.style),u=o(()=>e.value?.color),g=o(()=>e.value?.visible);return d({appearance:l,font:r,size:a,style:i,color:u,visible:g})}function A(n){const t=c(),e=o(()=>{const a=t.design.value[n],i=t.defaults.value[n],u=t.context.value.globalDesign;return{overlay:{type:a?.overlay?.type??i?.overlay?.type,solid:{color:a?.overlay?.solid?.color??f(u,i?.overlay?.solid?.color)},gradient:{fromColor:a?.overlay?.gradient?.fromColor??f(u,i?.overlay?.gradient?.fromColor),toColor:a?.overlay?.gradient?.toColor??f(u,i?.overlay?.gradient?.toColor)}},visible:a?.visible??i?.visible??!1}}),l=o(()=>e.value?.overlay),r=o(()=>e.value?.visible);return d({overlay:l,visible:r})}function O(n){const t=c(),e=o(()=>{const r=t.design.value[n],a=t.defaults.value[n];return{enabled:r?.enabled??a?.enabled}}),l=o(()=>e.value?.enabled);return d({enabled:l})}function G(n){const t=c(),e=o(()=>{const r=t.design.value[n],a=t.defaults.value[n];return{value:r?.value??a?.value}}),l=o(()=>e.value?.value);return d({value:l})}function K(n){const t=c(),e=o(()=>{const r=t.design.value[n],a=t.defaults.value[n],i=t.context.value.globalDesign;return{background:{type:r?.background?.type??a?.background?.type,solid:{color:r?.background?.solid?.color??f(i,a?.background?.solid?.color)},gradient:{fromColor:r?.background?.gradient?.fromColor??f(i,a?.background?.gradient?.fromColor),toColor:r?.background?.gradient?.toColor??f(i,a?.background?.gradient?.toColor)}}}}),l=o(()=>e.value?.background);return d({background:l})}function w(n){return{app:E(n)}}function M(n,t){return{init:()=>{const{app:e}=w(n);return t?.init?.(e),{render:async(l,r)=>(c().init(e,l,r.content,r.design,r.defaults),t?.render?.(e,l,r),{html:await C(e,{context:l}),state:{context:l,data:r}})}}}}function N(n,t){return{init:()=>{const{app:e}=w(n);return t?.init?.(e),{mount:(l,r)=>{c().init(e,r.context,r.data.content,r.data.design,r.data.defaults),t?.mount?.(e,l,r),e.mount(l)},update:l=>{c().update(e,l.data.content,l.data.design),t?.update?.(e,l)},unmount:()=>{t?.unmount?.(e),e.unmount()}}}}}export{N as createVueClientApp,M as createVueServerApp,K as useBackgroundElementDesign,$ as useButtonElementContent,B as useButtonElementDesign,_ as useImageElementContent,A as useImageElementDesign,x as useInputboxElementContent,L as useSelectboxElementContent,G as useSelectboxElementDesign,R as useTextElementDesign,h as useTextareaElementContent,D as useToggleElementContent,O as useToggleElementDesign,c as useVueBaseProps};
1
+ import{getCurrentInstance as k,ref as b,computed as o,reactive as d,createSSRApp as x}from"vue";import{renderToString as C}from"vue/server-renderer";const w=new Map;function c(){const t=(r,a,i,u,g)=>{w.set(r._uid,{context:b(a),content:b(i),design:b(u),defaults:b(g)})},n=(r,a,i)=>{const u=w.get(r._uid);u!==void 0&&(u.content.value=a,u.design.value=i)},e=k()?.appContext.app._uid??-1,l=w.get(e);return{init:t,update:n,context:l?.context,content:l?.content,design:l?.design,defaults:l?.defaults}}function h(t){const n=c(),e=o(()=>{const a=n.content.value[t];if(a!==void 0){if(typeof a=="string")return a;throw new Error(`Element ${t} is not inputbox`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value);return d({hasContent:l,value:r})}function I(t){const n=c(),e=o(()=>{const a=n.content.value[t];if(a!==void 0){if(typeof a=="string")return a;throw new Error(`Element ${t} is not textarea`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value);return d({hasContent:l,value:r})}function T(t){return"title"in t&&"type"in t}function _(t){const n=c(),e=o(()=>{const u=n.content.value[t];if(u!==void 0){if(T(u))return u;throw new Error(`Element ${t} is not action link`)}}),l=o(()=>e.value?.title),r=o(()=>e.value?.link),a=o(()=>!!l.value),i=o(()=>!!r.value);return d({title:l,link:r,hasTitle:a,hasLink:i,performAction:()=>{if(e.value!==void 0)switch(e.value.buttonType){case"HYPER_LINK":e.value.link&&window.open(e.value.link,"_blank");break;case"GO_TO_STORE_LINK":window.open("/products");break;case"MAIL_LINK":e.value.email&&window.open(`mailto:${e.value.email}`,"_self");break;case"TEL_LINK":e.value.phone&&window.open(`tel:${e.value.phone}`,"_self");break;case"SCROLL_TO_TILE":{if(typeof document>"u")return;const u=e.value.tileId;document.getElementById(`tile-${u}`)?.scrollIntoView();break}default:throw new Error("Unknown ButtonType: ")}}})}function z(t){return"bucket"in t&&"borderInfo"in t&&"set"in t}function m(t,n){const e=new RegExp(/^https?:\/\//);return t!=null&&e.test(t)?t:`${n}/${t}`}function D(t){const n=c(),e=o(()=>{const s=n.content.value[t];if(s!==void 0){if(z(s))return s;throw new Error(`Element ${t} is not image`)}}),l=o(()=>e.value===void 0?"":n.context.value.imageBuckets?.[e.value?.bucket]),r=o(()=>e.value!==void 0),a=o(()=>m(e.value?.set?.["cropped-webp-100x200"]?.url,l.value)),i=o(()=>m(e.value?.set?.["cropped-webp-1000x2000"]?.url,l.value)),u=o(()=>m(e.value?.set?.["webp-200x200"]?.url,l.value)),g=o(()=>m(e.value?.set?.["webp-2000x2000"]?.url,l.value));return d({hasContent:r,lowResolutionMobileImage:a,highResolutionMobileImage:i,lowResolutionDesktopImage:u,highResolutionDesktopImage:g})}function $(t){return"enabled"in t}function L(t){const n=c(),e=o(()=>{const a=n.content.value[t];if(a!==void 0){if($(a))return a;throw new Error(`Element ${t} is not toggle`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value?.enabled);return d({hasContent:l,value:r})}function S(t){const n=c(),e=o(()=>{const a=n.content.value[t];if(a!==void 0){if(typeof a=="string")return a;throw new Error(`Element ${t} is not selectbox`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value);return d({hasContent:l,value:r})}function y(t,n){if(n===void 0)return;if(!n.startsWith("global."))return n;const e=n.split(".").at(2);if(e!==void 0)return t.fontFamily[e]}function R(t,n){if(n===void 0)return;if(typeof n!="string"||!n.startsWith("global."))return n;const e=n.split(".").at(2);if(e!==void 0)return t.textSize[e]}function f(t,n){if(n===void 0)return;if(typeof n!="string"||!n.startsWith("global."))return n;const e=n.split(".").at(2);if(e!==void 0)return t.color[e]}function B(t){const n=c(),e=o(()=>{const s=n.design.value[t],v=n.defaults.value[t],p=n.context.value.globalDesign;return{font:s?.font??y(p,v?.font),size:s?.size??R(p,v?.size),bold:s?.bold??v?.bold,italic:s?.italic??v?.italic,color:s?.color??f(p,v?.color),visible:s?.visible??v?.visible??!1}}),l=o(()=>e.value?.font),r=o(()=>e.value?.size),a=o(()=>e.value?.bold),i=o(()=>e.value?.italic),u=o(()=>e.value?.color),g=o(()=>e.value?.visible);return d({font:l,size:r,bold:a,italic:i,color:u,visible:g})}function A(t){const n=c(),e=o(()=>{const s=n.design.value[t],v=n.defaults.value[t],p=n.context.value.globalDesign;return{appearance:s?.appearance??v?.appearance,font:s?.font??y(p,v?.font),size:s?.size??v?.size,style:s?.style??v?.style,color:s?.color??f(p,v?.color),visible:s?.visible??v?.visible??!1}}),l=o(()=>e.value?.appearance),r=o(()=>e.value?.font),a=o(()=>e.value?.size),i=o(()=>e.value?.style),u=o(()=>e.value?.color),g=o(()=>e.value?.visible);return d({appearance:l,font:r,size:a,style:i,color:u,visible:g})}function O(t){const n=c(),e=o(()=>{const a=n.design.value[t],i=n.defaults.value[t],u=n.context.value.globalDesign;return{overlay:{type:a?.overlay?.type??i?.overlay?.type,solid:{color:a?.overlay?.solid?.color??f(u,i?.overlay?.solid?.color)},gradient:{fromColor:a?.overlay?.gradient?.fromColor??f(u,i?.overlay?.gradient?.fromColor),toColor:a?.overlay?.gradient?.toColor??f(u,i?.overlay?.gradient?.toColor)}},visible:a?.visible??i?.visible??!1}}),l=o(()=>e.value?.overlay),r=o(()=>e.value?.visible);return d({overlay:l,visible:r})}function G(t){const n=c(),e=o(()=>{const r=n.design.value[t],a=n.defaults.value[t];return{enabled:r?.enabled??a?.enabled}}),l=o(()=>e.value?.enabled);return d({enabled:l})}function K(t){const n=c(),e=o(()=>{const r=n.design.value[t],a=n.defaults.value[t];return{value:r?.value??a?.value}}),l=o(()=>e.value?.value);return d({value:l})}function M(t){const n=c(),e=o(()=>{const r=n.design.value[t],a=n.defaults.value[t],i=n.context.value.globalDesign;return{background:{type:r?.background?.type??a?.background?.type,solid:{color:r?.background?.solid?.color??f(i,a?.background?.solid?.color)},gradient:{fromColor:r?.background?.gradient?.fromColor??f(i,a?.background?.gradient?.fromColor),toColor:r?.background?.gradient?.toColor??f(i,a?.background?.gradient?.toColor)}}}}),l=o(()=>e.value?.background);return d({background:l})}function E(t){return{app:x(t)}}function N(t,n){return{init:()=>{const{app:e}=E(t);return n?.init?.(e),{render:async(l,r)=>(c().init(e,l,r.content,r.design,r.defaults),n?.render?.(e,l,r),{html:await C(e,{context:l}),state:{context:l,data:r}})}}}}function V(t,n){return{init:()=>{const{app:e}=E(t);return n?.init?.(e),{mount:(l,r)=>{c().init(e,r.context,r.data.content,r.data.design,r.data.defaults),n?.mount?.(e,l,r),e.mount(l)},update:l=>{c().update(e,l.data.content,l.data.design),n?.update?.(e,l)},unmount:()=>{n?.unmount?.(e),e.unmount()}}}}}export{V as createVueClientApp,N as createVueServerApp,M as useBackgroundElementDesign,_ as useButtonElementContent,A as useButtonElementDesign,D as useImageElementContent,O as useImageElementDesign,h as useInputboxElementContent,S as useSelectboxElementContent,K as useSelectboxElementDesign,B as useTextElementDesign,I as useTextareaElementContent,L as useToggleElementContent,G as useToggleElementDesign,c as useVueBaseProps};
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import Ae from"cac";import d from"node:fs";import f from"node:path";import{fileURLToPath as D}from"node:url";import{red as Ne,yellow as Se,green as j}from"kolorist";import{resolve as r,parse as v,dirname as Ie,sep as Ge}from"path";import{rename as _e,unlink as Re,existsSync as A,writeFileSync as ke,createReadStream as C}from"fs";import{glob as l}from"glob";import{build as h,defineConfig as $}from"vite";import{builtinModules as P}from"module";import U from"@vitejs/plugin-vue";import b from"vite-tsconfig-paths";import Be from"vite-plugin-checker";import{viteExternalsPlugin as Pe}from"vite-plugin-externals";import Ue from"ajv/dist/2020.js";import xe from"ajv-formats";import{readFile as x}from"fs/promises";import Xe from"axios";import{inc as Fe}from"semver";import*as c from"process";import qe from"tinycolor2";import Me from"prompts";function X(e,t){d.statSync(e).isDirectory()?(d.mkdirSync(t,{recursive:!0}),d.readdirSync(e).forEach(o=>{const s=f.resolve(e,o),n=f.resolve(t,o);X(s,n)})):d.copyFileSync(e,t)}function N(e,t,o,s){const n=f.join(e,s?.[o]??o);X(f.join(t,o),n)}const m={error:e=>console.log(Ne(e)),warn:e=>console.log(Se(e)),info:e=>console.log(j(e))},T="_temp";async function F(e){try{const t=e,o=process.cwd(),s=f.join(o,t),n=["templates"],i={_gitignore:".gitignore"};d.existsSync(s)||d.mkdirSync(s);const a=f.resolve(D(import.meta.url),"../..","template");d.readdirSync(a).filter(g=>g!=="package.json").filter(g=>!n.includes(g)).forEach(async g=>N(s,a,g,i));const u=JSON.parse(d.readFileSync(f.join(a,"package.json"),"utf-8"));u.name=e;const y=f.join(s,"package.json");d.writeFileSync(y,`${JSON.stringify(u,null,2)}
2
- `),m.info(`App ${e} created`)}catch(t){m.error(`Error while creating app: ${t.message}`)}}async function q(e){try{const t=e,o=process.cwd(),s=f.join(o,"sections",t);d.existsSync(s)||d.mkdirSync(s);const n=f.resolve(D(import.meta.url),"../..","template/sections/block-example");d.readdirSync(n).forEach(async i=>N(s,n,i)),m.info(`Section ${e} created`)}catch(t){m.error(`Error while creating block: ${t.message}`)}}async function M(e){try{const t=process.cwd(),o=f.join(t,"templates"),s={"template.ts":`${e}.ts`};d.existsSync(o)||d.mkdirSync(o);const n=f.resolve(D(import.meta.url),"../..","template/templates");d.readdirSync(n).forEach(async i=>N(o,n,i,s)),m.info(`Template descriptor file [${e}.ts] has been created`)}catch(t){m.error(`Error while creating template descriptors: ${t.message}`)}}function O(){const e=process.env.npm_lifecycle_event;return Be({typescript:!0,vueTsc:!1,eslint:{lintCommand:`eslint --max-warnings=0 "./sections/**/*.{js,ts,vue}" --cache --cache-location "./build/eslintcache/${e}.json"`}})}function ze(e,t){return{plugins:[U(),b(),O(),Pe({vue:"EcVue"})],define:{"process.env":{NODE_ENV:"production"}},resolve:{alias:{"@":"/src"}},build:{outDir:`./dist/sections/${e}`,emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:r(process.cwd(),t),output:{validate:!0,entryFileNames:"js/[name].js",chunkFileNames:"js/[name].js",assetFileNames:"assets/[name].[ext]"}}}}}function Ke(e,t){return{plugins:[U(),b()],define:{"process.env":{NODE_ENV:"production"}},resolve:{alias:{"@":"/src"}},ssr:{noExternal:!0},build:{ssr:!0,outDir:`./dist/sections/${e}`,emptyOutDir:!0,rollupOptions:{external:[...P,...P.map(o=>`node:${o}`)],preserveEntrySignatures:"strict",input:r(process.cwd(),t),output:{validate:!0,entryFileNames:"js/[name].js"}}}}}function S(e,t){return{plugins:[b(),O()],resolve:{alias:{"@":"/src"}},build:{outDir:`./dist/sections/${e}`,emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:r(process.cwd(),t),output:{validate:!0,entryFileNames:"js/settings/[name].mjs"}}}}}function Je(e,t){return{plugins:[b(),O()],resolve:{alias:{"@":"/src"}},build:{outDir:"./dist/template",emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:r(process.cwd(),e),output:{validate:!0,entryFileNames:`js/[name]${t}.mjs`}}}}}function z(e,t){return{plugins:[b(),O()],resolve:{alias:{"@":"/src"}},build:{outDir:`./dist/sections/${e}`,emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:r(process.cwd(),t),output:{validate:!0,entryFileNames:"js/showcases/[name].mjs"}}}}}function Ve(e,t){return{plugins:[b(),O()],resolve:{alias:{"@":"/src"}},build:{outDir:`./dist/sections/${e}`,emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:r(process.cwd(),t),output:{validate:!0,assetFileNames:"assets/[name].[ext]"}}}}}const K="https://json-schema.org/draft/2020-12/schema",J="https://lightspeedhq.com/template.schema.json",V="Custom Template",H="A custom template enclosing the necessary custom and default blocks",W="object",Z={metadata:{type:"object",properties:{name:{description:"Name of the template",type:"string",minLength:2,maxLength:60},description:{description:"Short description of the template",type:"string",minLength:2,maxLength:150},url:{type:"object",properties:{demo_website:{description:"URL to the demo website",type:"string",format:"uri",pattern:"^(https?|wss?|ftp)://"},cover_image:{description:"URL to the cover image",type:"string",format:"uri",pattern:"^(https?|wss?|ftp)://"}},required:["demo_website","cover_image"]}},required:["name","description","url"]},sections:{description:"List of sections contained by this template",type:"array",items:{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]}},allOf:[{if:{properties:{type:{const:"default"}}},then:{$ref:"template-default.schema.json#/$defs/default-section"}},{if:{properties:{type:{const:"custom"}}},then:{$ref:"template-custom.schema.json#/$defs/custom-section"}}]},minItems:1,uniqueItems:!1}},Y=["metadata","sections"],He={$schema:K,$id:J,title:V,description:H,type:W,properties:Z,required:Y},Q={__proto__:null,$id:J,$schema:K,default:He,description:H,properties:Z,required:Y,title:V,type:W},ee="https://json-schema.org/draft/2020-12/schema",te="https://lightspeedhq.com/template-default.schema.json",oe="Default Section",se="Default section for a Custom Template",ne="object",ie={"default-section":{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]},id:{description:"Identification of the section",type:"string",pattern:"^((header|cover|announcement_bar|slider|special_offer|customer_review|company_info|shipping_payment|location|store|footer)(_\\d{3})?)$"}},required:["type","id"],additionalProperties:!1}},We={$schema:ee,$id:te,title:oe,description:se,type:ne,$defs:ie},Ze={__proto__:null,$defs:ie,$id:te,$schema:ee,default:We,description:se,title:oe,type:ne},re="https://json-schema.org/draft/2020-12/schema",ae="https://lightspeedhq.com/template-custom.schema.json",ce="Custom Section",pe="Custom section for a Custom Template",le="object",de={"custom-section":{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]},id:{description:"Identification of the section",type:"string"},content:{type:"object",patternProperties:{".*":{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]}},allOf:[{if:{properties:{type:{const:"INPUTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/input_box"}},{if:{properties:{type:{const:"TEXTAREA"}}},then:{$ref:"template-custom-content.schema.json#/$defs/text_area"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"template-custom-content.schema.json#/$defs/button"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/select_box"}}]}},minProperties:1},design:{type:"object",patternProperties:{".*":{type:"object",properties:{type:{description:"Type of the design configuration element",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]}},allOf:[{if:{properties:{type:{const:"TEXT"}}},then:{$ref:"template-custom-design.schema.json#/$defs/text"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"template-custom-design.schema.json#/$defs/button"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"template-custom-design.schema.json#/$defs/image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"template-custom-design.schema.json#/$defs/toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"template-custom-design.schema.json#/$defs/select_box"}},{if:{properties:{type:{const:"BACKGROUND"}}},then:{$ref:"template-custom-design.schema.json#/$defs/background"}}]}},minProperties:1}},required:["type","id"],additionalProperties:!1}},Ye={$schema:re,$id:ae,title:ce,description:pe,type:le,$defs:de},Qe={__proto__:null,$defs:de,$id:ae,$schema:re,default:Ye,description:pe,title:ce,type:le},ue="https://json-schema.org/draft/2020-12/schema",fe="https://lightspeedhq.com/template-custom-content.schema.json",me="Custom Section :: Content Configuration",ye="Content tab configuration of a Custom Section for a Custom Template",ge="object",he={input_box:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"},placeholder:{description:"Placeholder of the content configuration element",type:"string"}},required:["type","label","placeholder"],additionalProperties:!1},text_area:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"},placeholder:{description:"Placeholder of the content configuration element",type:"string"}},required:["type","label","placeholder"],additionalProperties:!1},button:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"}},required:["type","label"],additionalProperties:!1},image:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"}},required:["type","label"],additionalProperties:!1},toggle:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"},description:{description:"Description of the content configuration element",type:"string"}},required:["type","label"],additionalProperties:!1},select_box:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"},placeholder:{description:"Placeholder of the content configuration element",type:"string"},description:{description:"Description of the content configuration element",type:"string"},options:{description:"Individual options of the content configuration element",type:"array",items:{type:"object",properties:{value:{description:"Value of the option",type:"string"},label:{description:"Label of the option",type:"string"}},required:["value","label"],additionalProperties:!1},minItems:1}},required:["type","label","placeholder","options"],additionalProperties:!1}},et={$schema:ue,$id:fe,title:me,description:ye,type:ge,$defs:he},tt={__proto__:null,$defs:he,$id:fe,$schema:ue,default:et,description:ye,title:me,type:ge},$e="https://json-schema.org/draft/2020-12/schema",Ee="https://lightspeedhq.com/template-custom-design.schema.json",be="Custom Section :: Design Configuration",Te="Design tab configuration of a Custom Section for a Custom Template",we="object",Oe={text:{type:"object",properties:{type:{description:"Type of the text",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the text",type:"string"},colors:{description:"Color options for the text",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"},minItems:1,uniqueItems:!0},sizes:{description:"Size options for the text",type:"array",items:{type:"integer",minimum:0,exclusiveMaximum:50},minItems:1,uniqueItems:!0},defaults:{description:"Default values for the text",type:"object",properties:{font:{description:"Default font for the text",type:"string"},size:{description:"Default size for the text",type:"integer",minimum:1,exclusiveMaximum:50},bold:{description:"Default boldness for the text",type:"boolean"},italic:{description:"Default italic style for the text",type:"boolean"},color:{description:"Default color for the text",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"}},required:["font","size","bold","italic","color"],additionalProperties:!1}},required:["type","label","colors","sizes","defaults"],additionalProperties:!1},button:{type:"object",properties:{type:{description:"Type of the button",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the button",type:"string"},colors:{description:"Color options for the button",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"},minItems:1,uniqueItems:!0},defaults:{description:"Default values for the button",type:"object",properties:{font:{description:"Default font for the button",type:"string"},size:{description:"Default size for the button",type:"string",enum:["SMALL","MEDIUM","LARGE"]},appearance:{description:"Default appearance for the button",type:"string",enum:["SOLID","OUTLINE","TEXT"]},shape:{description:"Default shape for the button",type:"string",enum:["ROUND_CORNER","RECTANGLE","PILL"]},color:{description:"Default color for the button",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"}},required:["font","size","appearance","shape","color"],additionalProperties:!1}},required:["type","label","colors","defaults"],additionalProperties:!1},image:{type:"object",properties:{type:{description:"Type of the image",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the image",type:"string"},colors:{description:"Color options for the image",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"},minItems:1,uniqueItems:!0},defaults:{description:"Default values for the image",type:"object",properties:{overlay:{description:"Default overlay for the image",type:"string",enum:["COLOR","GRADIENT","NONE"]},color:{description:"Default color for the image",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"}},required:["overlay","color"],additionalProperties:!1}},required:["type","label","colors","defaults"],additionalProperties:!1},toggle:{type:"object",properties:{type:{description:"Type of the toggle",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the toggle",type:"string"},description:{description:"Description of the toggle",type:"string"},defaults:{description:"Default values for the toggle",type:"object",properties:{enabled:{description:"Default enabled status for the toggle",type:"boolean"}},required:["enabled"],additionalProperties:!1}},required:["type","label"],additionalProperties:!1},select_box:{type:"object",properties:{type:{description:"Type of the checkbox",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the checkbox",type:"string"},placeholder:{description:"Placeholder of the checkbox",type:"string"},description:{description:"Description of the checkbox",type:"string"},options:{description:"Individual options of the checkbox",type:"array",items:{type:"object",properties:{value:{description:"Value of the option",type:"string"},label:{description:"Label of the option",type:"string"}},required:["value","label"],additionalProperties:!1},minItems:1},defaults:{description:"Default values for the checkbox",type:"object",properties:{value:{description:"Default option for the checkbox",type:"string"}},required:["value"],additionalProperties:!1}},required:["type","label","placeholder","description","options","defaults"],additionalProperties:!1},background:{type:"object",properties:{type:{description:"Type of the background",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the background",type:"string"},colors:{description:"Color options for the background",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"},minItems:1,uniqueItems:!0},defaults:{description:"Default values for the background",type:"object",properties:{style:{description:"Default style for the background",type:"string",enum:["COLOR","GRADIENT"]},color:{description:"Default color style for the background",type:"string"}},required:["style","color"],additionalProperties:!1}},required:["type","label","colors","defaults"],additionalProperties:!1}},ot={$schema:$e,$id:Ee,title:be,description:Te,type:we,$defs:Oe},st={__proto__:null,$defs:Oe,$id:Ee,$schema:$e,default:ot,description:Te,title:be,type:we};async function nt(){const e=await l("**/server.{js,ts}",{ignore:["node_modules/**","dist/**"]});return Promise.all(e.map(async t=>{const o=Ie(t).split(Ge).pop()??"default",s=await l(`**/${o}/client.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),n=await l(`**/${o}/settings/content.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await l(`**/${o}/settings/design.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),a=await l(`**/${o}/settings/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),u=await l(`**/${o}/showcases/*.{js,ts}`,{ignore:["node_modules/**","dist/**","translations.{js,ts}"]}),y=await l(`**/${o}/showcases/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),g=await l(`**/${o}/assets/*`,{ignore:["node_modules/**","dist/**"]});return{name:o,serverEntrypoint:t,clientEntrypoint:s.at(0),contentSettingsEntrypoint:n.at(0),designSettingsEntrypoint:i.at(0),settingsTranslationsEntrypoint:a.at(0),showcasesEntrypoints:u,showcasesTranslationsEntrypoint:y.at(0),assetsEntrypoints:g}}))}async function it(){return{entryPoints:await l("**/templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]})}}async function I(e,t){try{return(await import(r(process.cwd(),t?`${e}${T}.mjs`:`${e}.mjs`))).default}catch{throw new Error(`File [${e}${T}.mjs] is either invalid or undefined`)}}async function rt(){let e=new Ue({allErrors:!0,schemas:[Q,Ze,Qe,tt,st]});return xe(e),e.compile(Q)}async function at(e,t,o,s){if(e(t)&&s===void 0)new Promise(n=>{_e(`${o}${T}.mjs`,`${o}.mjs`,function(i){i&&n(i)})});else throw new Promise(n=>{Re(`${o}${T}.mjs`,function(i){i&&n(i)})}),new Error(`Invalid file [${v(o).name}].
1
+ import Ge from"cac";import l from"node:fs";import f from"node:path";import{fileURLToPath as I}from"node:url";import{red as _e,yellow as Pe,green as v}from"kolorist";import{resolve as r,parse as C,dirname as Re,sep as xe}from"path";import{rename as ke,unlink as Ue,existsSync as L,writeFileSync as Be,createReadStream as Xe}from"fs";import{glob as m,globSync as X}from"glob";import{build as g,defineConfig as h}from"vite";import{builtinModules as F}from"module";import q from"@vitejs/plugin-vue";import T from"vite-tsconfig-paths";import Fe from"vite-plugin-checker";import{viteExternalsPlugin as qe}from"vite-plugin-externals";import Me from"ajv/dist/2020.js";import ze from"ajv-formats";import{readFile as M}from"fs/promises";import Ke from"axios";import{inc as Je}from"semver";import*as d from"process";import Ve from"tinycolor2";import He from"prompts";function z(e,t){l.statSync(e).isDirectory()?(l.mkdirSync(t,{recursive:!0}),l.readdirSync(e).forEach(o=>{const n=f.resolve(e,o),s=f.resolve(t,o);z(n,s)})):l.copyFileSync(e,t)}function G(e,t,o,n){const s=f.join(e,n?.[o]??o);z(f.join(t,o),s)}const c={error:e=>console.log(_e(e)),warn:e=>console.log(Pe(e)),info:e=>console.log(v(e))},w="_temp";async function K(e){try{const t=e,o=process.cwd(),n=f.join(o,t),s=["templates"],i={_gitignore:".gitignore"};l.existsSync(n)||l.mkdirSync(n);const a=f.resolve(I(import.meta.url),"../..","template");l.readdirSync(a).filter(y=>y!=="package.json").filter(y=>!s.includes(y)).forEach(async y=>G(n,a,y,i));const u=JSON.parse(l.readFileSync(f.join(a,"package.json"),"utf-8"));u.name=e;const b=f.join(n,"package.json");l.writeFileSync(b,`${JSON.stringify(u,null,2)}
2
+ `),c.info(`App ${e} created`)}catch(t){c.error(`Error while creating app: ${t.message}`)}}async function J(e){try{const t=e,o=process.cwd(),n=f.join(o,"sections",t);l.existsSync(n)||l.mkdirSync(n);const s=f.resolve(I(import.meta.url),"../..","template/sections/example-section");l.readdirSync(s).forEach(async i=>G(n,s,i)),c.info(`Section ${e} created`)}catch(t){c.error(`Error while creating block: ${t.message}`)}}async function V(e){try{const t=process.cwd(),o=f.join(t,"templates"),n={"template.ts":`${e}.ts`};l.existsSync(o)||l.mkdirSync(o);const s=f.resolve(I(import.meta.url),"../..","template/templates");l.readdirSync(s).forEach(async i=>G(o,s,i,n)),c.info(`Template descriptor file [${e}.ts] has been created`)}catch(t){c.error(`Error while creating template descriptors: ${t.message}`)}}function j(){const e=process.env.npm_lifecycle_event;return Fe({typescript:!0,vueTsc:!1,eslint:{lintCommand:`eslint --max-warnings=0 "./sections/**/*.{js,ts,vue}" --cache --cache-location "./build/eslintcache/${e}.json"`}})}function We(e,t){return{plugins:[q(),T(),j(),qe({vue:"EcVue"})],define:{"process.env":{NODE_ENV:"production"}},resolve:{alias:{"@":"/src"}},build:{outDir:`./dist/sections/${e}`,emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:r(process.cwd(),t),output:{validate:!0,entryFileNames:"js/[name].js",chunkFileNames:"js/[name].js",assetFileNames:"assets/[name].[ext]"}}}}}function Ze(e,t){return{plugins:[q(),T()],define:{"process.env":{NODE_ENV:"production"}},resolve:{alias:{"@":"/src"}},ssr:{noExternal:!0},build:{ssr:!0,outDir:`./dist/sections/${e}`,emptyOutDir:!0,rollupOptions:{external:[...F,...F.map(o=>`node:${o}`)],preserveEntrySignatures:"strict",input:r(process.cwd(),t),output:{validate:!0,entryFileNames:"js/[name].js"}}}}}function _(e,t){return{plugins:[T(),j()],resolve:{alias:{"@":"/src"}},build:{outDir:`./dist/sections/${e}`,emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:r(process.cwd(),t),output:{validate:!0,entryFileNames:"js/settings/[name].mjs"}}}}}function Ye(e,t){return{plugins:[T(),j()],resolve:{alias:{"@":"/src"}},build:{outDir:"./dist/template",emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:r(process.cwd(),e),output:{validate:!0,entryFileNames:`js/[name]${t}.mjs`}}}}}function H(e,t){return{plugins:[T(),j()],resolve:{alias:{"@":"/src"}},build:{outDir:`./dist/sections/${e}`,emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:r(process.cwd(),t),output:{validate:!0,entryFileNames:"js/showcases/[name].mjs"}}}}}function Qe(e,t){return{plugins:[T(),j()],resolve:{alias:{"@":"/src"}},build:{outDir:`./dist/sections/${e}`,emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:r(process.cwd(),t),output:{validate:!0,assetFileNames:"assets/[name].[ext]"}}}}}const W="https://json-schema.org/draft/2020-12/schema",Z="https://lightspeedhq.com/template.schema.json",Y="Custom Template",Q="A custom template enclosing the necessary custom and default blocks",ee="object",te={metadata:{type:"object",properties:{name:{description:"Name of the template",type:"string",minLength:2,maxLength:60},description:{description:"Short description of the template",type:"string",minLength:2,maxLength:150},url:{type:"object",properties:{demo_website:{description:"URL to the demo website",type:"string",format:"uri",pattern:"^(https?|wss?|ftp)://"},cover_image:{description:"URL to the cover image",type:"string",format:"uri",pattern:"^(https?|wss?|ftp)://"}},required:["demo_website","cover_image"]}},required:["name","description","url"]},sections:{description:"List of sections contained by this template",type:"array",items:{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]}},allOf:[{if:{properties:{type:{const:"default"}}},then:{$ref:"template-default.schema.json#/$defs/default-section"}},{if:{properties:{type:{const:"custom"}}},then:{$ref:"template-custom.schema.json#/$defs/custom-section"}}]},minItems:1,uniqueItems:!1}},oe=["metadata","sections"],et={$schema:W,$id:Z,title:Y,description:Q,type:ee,properties:te,required:oe},ne={__proto__:null,$id:Z,$schema:W,default:et,description:Q,properties:te,required:oe,title:Y,type:ee},se="https://json-schema.org/draft/2020-12/schema",ie="https://lightspeedhq.com/template-default.schema.json",re="Default Section",ae="Default section for a Custom Template",ce="object",pe={"default-section":{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]},id:{description:"Identification of the section",type:"string",pattern:"^((header|cover|announcement_bar|slider|special_offer|customer_review|company_info|shipping_payment|location|store|footer)(_\\d{3})?)$"}},required:["type","id"],additionalProperties:!1}},tt={$schema:se,$id:ie,title:re,description:ae,type:ce,$defs:pe},ot={__proto__:null,$defs:pe,$id:ie,$schema:se,default:tt,description:ae,title:re,type:ce},le="https://json-schema.org/draft/2020-12/schema",de="https://lightspeedhq.com/template-custom.schema.json",ue="Custom Section",fe="Custom section for a Custom Template",me="object",ye={"custom-section":{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]},id:{description:"Identification of the section",type:"string"},content:{type:"object",patternProperties:{".*":{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]}},allOf:[{if:{properties:{type:{const:"INPUTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/input_box"}},{if:{properties:{type:{const:"TEXTAREA"}}},then:{$ref:"template-custom-content.schema.json#/$defs/text_area"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"template-custom-content.schema.json#/$defs/button"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/select_box"}}]}},minProperties:1},design:{type:"object",patternProperties:{".*":{type:"object",properties:{type:{description:"Type of the design configuration element",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]}},allOf:[{if:{properties:{type:{const:"TEXT"}}},then:{$ref:"template-custom-design.schema.json#/$defs/text"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"template-custom-design.schema.json#/$defs/button"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"template-custom-design.schema.json#/$defs/image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"template-custom-design.schema.json#/$defs/toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"template-custom-design.schema.json#/$defs/select_box"}},{if:{properties:{type:{const:"BACKGROUND"}}},then:{$ref:"template-custom-design.schema.json#/$defs/background"}}]}},minProperties:1}},required:["type","id"],additionalProperties:!1}},nt={$schema:le,$id:de,title:ue,description:fe,type:me,$defs:ye},st={__proto__:null,$defs:ye,$id:de,$schema:le,default:nt,description:fe,title:ue,type:me},ge="https://json-schema.org/draft/2020-12/schema",he="https://lightspeedhq.com/template-custom-content.schema.json",$e="Custom Section :: Content Configuration",Ee="Content tab configuration of a Custom Section for a Custom Template",be="object",Te={input_box:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"},placeholder:{description:"Placeholder of the content configuration element",type:"string"}},required:["type","label","placeholder"],additionalProperties:!1},text_area:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"},placeholder:{description:"Placeholder of the content configuration element",type:"string"}},required:["type","label","placeholder"],additionalProperties:!1},button:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"}},required:["type","label"],additionalProperties:!1},image:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"}},required:["type","label"],additionalProperties:!1},toggle:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"},description:{description:"Description of the content configuration element",type:"string"}},required:["type","label"],additionalProperties:!1},select_box:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"},placeholder:{description:"Placeholder of the content configuration element",type:"string"},description:{description:"Description of the content configuration element",type:"string"},options:{description:"Individual options of the content configuration element",type:"array",items:{type:"object",properties:{value:{description:"Value of the option",type:"string"},label:{description:"Label of the option",type:"string"}},required:["value","label"],additionalProperties:!1},minItems:1}},required:["type","label","placeholder","options"],additionalProperties:!1}},it={$schema:ge,$id:he,title:$e,description:Ee,type:be,$defs:Te},rt={__proto__:null,$defs:Te,$id:he,$schema:ge,default:it,description:Ee,title:$e,type:be},we="https://json-schema.org/draft/2020-12/schema",Oe="https://lightspeedhq.com/template-custom-design.schema.json",je="Custom Section :: Design Configuration",ve="Design tab configuration of a Custom Section for a Custom Template",Ce="object",Le={text:{type:"object",properties:{type:{description:"Type of the text",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the text",type:"string"},colors:{description:"Color options for the text",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"},minItems:1,uniqueItems:!0},sizes:{description:"Size options for the text",type:"array",items:{type:"integer",minimum:0,exclusiveMaximum:100},minItems:1,uniqueItems:!0},defaults:{description:"Default values for the text",type:"object",properties:{font:{description:"Default font for the text",type:"string"},size:{description:"Default size for the text",type:"integer",minimum:1,exclusiveMaximum:50},bold:{description:"Default boldness for the text",type:"boolean"},italic:{description:"Default italic style for the text",type:"boolean"},color:{description:"Default color for the text",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},visible:{description:"Default visibility for the text",type:"boolean"}},required:["font","size","bold","italic","color","visible"],additionalProperties:!1}},required:["type","label","colors","sizes","defaults"],additionalProperties:!1},button:{type:"object",properties:{type:{description:"Type of the button",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the button",type:"string"},colors:{description:"Color options for the button",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"},minItems:1,uniqueItems:!0},defaults:{description:"Default values for the button",type:"object",properties:{font:{description:"Default font for the button",type:"string"},size:{description:"Default size for the button",type:"string",enum:["SMALL","MEDIUM","LARGE"]},appearance:{description:"Default appearance for the button",type:"string",enum:["SOLID","OUTLINE","TEXT"]},shape:{description:"Default shape for the button",type:"string",enum:["ROUND_CORNER","RECTANGLE","PILL"]},color:{description:"Default color for the button",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"}},required:["font","size","appearance","shape","color"],additionalProperties:!1}},required:["type","label","colors","defaults"],additionalProperties:!1},image:{type:"object",properties:{type:{description:"Type of the image",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the image",type:"string"},colors:{description:"Color options for the image",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"},minItems:1,uniqueItems:!0},defaults:{description:"Default values for the image",type:"object",properties:{overlay:{description:"Default overlay for the image",type:"string",enum:["COLOR","GRADIENT","NONE"]},color:{description:"Default color for the image",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"}},required:["overlay","color"],additionalProperties:!1}},required:["type","label","colors","defaults"],additionalProperties:!1},toggle:{type:"object",properties:{type:{description:"Type of the toggle",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the toggle",type:"string"},description:{description:"Description of the toggle",type:"string"},defaults:{description:"Default values for the toggle",type:"object",properties:{enabled:{description:"Default enabled status for the toggle",type:"boolean"}},required:["enabled"],additionalProperties:!1}},required:["type","label"],additionalProperties:!1},select_box:{type:"object",properties:{type:{description:"Type of the checkbox",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the checkbox",type:"string"},placeholder:{description:"Placeholder of the checkbox",type:"string"},description:{description:"Description of the checkbox",type:"string"},options:{description:"Individual options of the checkbox",type:"array",items:{type:"object",properties:{value:{description:"Value of the option",type:"string"},label:{description:"Label of the option",type:"string"}},required:["value","label"],additionalProperties:!1},minItems:1},defaults:{description:"Default values for the checkbox",type:"object",properties:{value:{description:"Default option for the checkbox",type:"string"}},required:["value"],additionalProperties:!1}},required:["type","label","placeholder","description","options","defaults"],additionalProperties:!1},background:{type:"object",properties:{type:{description:"Type of the background",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the background",type:"string"},colors:{description:"Color options for the background",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"},minItems:1,uniqueItems:!0},defaults:{description:"Default values for the background",type:"object",properties:{style:{description:"Default style for the background",type:"string",enum:["COLOR","GRADIENT"]},color:{description:"Default color style for the background",type:"string"}},required:["style","color"],additionalProperties:!1}},required:["type","label","colors","defaults"],additionalProperties:!1}},at={$schema:we,$id:Oe,title:je,description:ve,type:Ce,$defs:Le},ct={__proto__:null,$defs:Le,$id:Oe,$schema:we,default:at,description:ve,title:je,type:Ce};async function pt(){const e=await m("**/server.{js,ts}",{ignore:["node_modules/**","dist/**"]});return Promise.all(e.map(async t=>{const o=Re(t).split(xe).pop()??"default",n=await m(`**/${o}/client.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),s=await m(`**/${o}/settings/content.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await m(`**/${o}/settings/design.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),a=await m(`**/${o}/settings/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),u=await m(`**/${o}/showcases/*.{js,ts}`,{ignore:["node_modules/**","dist/**","translations.{js,ts}"]}),b=await m(`**/${o}/showcases/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),y=await m(`**/${o}/assets/*`,{ignore:["node_modules/**","dist/**"]});return{name:o,serverEntrypoint:t,clientEntrypoint:n.at(0),contentSettingsEntrypoint:s.at(0),designSettingsEntrypoint:i.at(0),settingsTranslationsEntrypoint:a.at(0),showcasesEntrypoints:u,showcasesTranslationsEntrypoint:b.at(0),assetsEntrypoints:y}}))}async function lt(){return{entryPoints:await m("**/templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]})}}async function P(e,t){try{return(await import(r(process.cwd(),t?`${e}${w}.mjs`:`${e}.mjs`))).default}catch{throw new Error(`File [${e}${w}.mjs] is either invalid or undefined`)}}async function dt(){let e=new Me({allErrors:!0,schemas:[ne,ot,st,rt,ct]});return ze(e),e.compile(ne)}async function ut(e,t,o,n){if(e(t)&&n===void 0)new Promise(s=>{ke(`${o}${w}.mjs`,`${o}.mjs`,function(i){i&&s(i)})});else throw new Promise(s=>{Ue(`${o}${w}.mjs`,function(i){i&&s(i)})}),new Error(`Invalid file [${C(o).name}].
3
3
  Note: Errors regarding failingKeyword: "then" can sometimes be false negatives. Please focus on fixing other errors first!
4
- Errors: ${JSON.stringify([...e.errors??[],...s??[]],null,2)}`)}async function ct(e){const t=[];for(const o of e.sections){const s=e.sections.indexOf(o);if(s===0&&o.id!=="header"&&t.push({instancePath:`/sections/${s}/id`,message:"The first section must be a default `header`"}),s===e.sections.length-1&&o.id!=="footer"&&t.push({instancePath:`/sections/${s}/id`,message:"The last section must be a default `footer`"}),o.type==="custom")if(!A(`dist/sections/${o.id}`))t.push({instancePath:`/sections/${s}/id`,message:"Custom section must have a corresponding block defined"});else{if(o.content!==void 0)if(!A(`dist/sections/${o.id}/js/settings/content.mjs`))t.push({instancePath:`/sections/${s}/content`,message:"Content descriptor is overridden, please provide a default descriptor in the block's settings folder"});else{const n=await I(`dist/sections/${o.id}/js/settings/content`,!1),i=new Set(Object.keys(n));Object.keys(o.content).every(a=>i.has(a))||t.push({instancePath:`/sections/${s}/content`,message:"Content descriptor must be a subset of the default content descriptor"})}if(o.design!==void 0)if(!A(`dist/sections/${o.id}/js/settings/design.mjs`))t.push({instancePath:`/sections/${s}/design`,message:"Design descriptor is overridden, please provide a default descriptor in the block's settings folder"});else{const n=await I(`dist/sections/${o.id}/js/settings/design`,!1),i=new Set(Object.keys(n));Object.keys(o.design).every(a=>i.has(a))||t.push({instancePath:`/sections/${s}/design`,message:"Design descriptor must be a subset of the default design descriptor"})}}}return t.length===0?void 0:t}async function pt(){try{const e=await nt();for(const s of e){const{name:n,serverEntrypoint:i,clientEntrypoint:a,contentSettingsEntrypoint:u,designSettingsEntrypoint:y,settingsTranslationsEntrypoint:g,showcasesEntrypoints:R,showcaseTranslationsEntrypoint:k,assetsEntrypoints:B}=s;if(await h({configFile:!1,...$(Ke(n,i))}),a!==void 0&&await h({configFile:!1,...$(ze(n,a))}),u!==void 0&&await h({configFile:!1,...$(S(n,u))}),y!==void 0&&await h({configFile:!1,...$(S(n,y))}),g!==void 0&&await h({configFile:!1,...$(S(n,g))}),R!==void 0)for(const L of R)await h({configFile:!1,...$(z(n,L))});if(k!==void 0&&await h({configFile:!1,...$(z(n,k))}),B!==void 0)for(const L of B)await h({configFile:!1,...$(Ve(n,L))})}const t=await rt(),o=await it();for(const s of o.entryPoints){await h({configFile:!1,...$(Je(s,T))});const n=`dist/template/js/${v(s).name}`,i=await I(n,!0);await at(t,i,n,await ct(i))}m.info("Build successful. For deploy run: npx @lightspeed/crane@latest deploy")}catch(e){m.error(`Error while building: ${e.message}`)}}function je(e){if(e!==void 0)return e.startsWith("global.")?{type:"GLOBAL_FONT",font:e}:{type:"PRESET_FONT",font:e}}function E(e){if(e===void 0)return;if(e.startsWith("global."))return{type:"GLOBAL_COLOR",raw:e};const t=qe(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function lt(e){if(e!==void 0)return typeof e=="string"&&e.startsWith("global.")?{type:"GLOBAL_TEXT_SIZE",size:e}:{type:"NUMERIC_TEXT_SIZE",size:e}}const dt={COLOR:"COLOR",GRADIENT:"GRADIENT"};function ut(e){switch(e){case"COLOR":return"solid";case"GRADIENT":return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(dt)}`)}}function ft(e){const t=e.style,o=e.color,s=Array.isArray(o)?o:[o,o];return e.background={type:ut(t),solid:{color:E(s.at(0))},gradient:{fromColor:E(s.at(0)),toColor:E(s.at(1))}},e.style=void 0,e.color=void 0,e}const mt={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"};function yt(e){switch(e){case"SOLID":return"solid-button";case"OUTLINE":return"outline-button";case"TEXT":return"text-link";default:throw new Error(`Unknown button appearance: ${e}. Right options: ${Object.keys(mt)}`)}}const gt={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"};function ht(e){switch(e){case"SMALL":return"small";case"MEDIUM":return"medium";case"LARGE":return"large";default:throw new Error(`Unknown button size: ${e}. Right options: ${Object.keys(gt)}`)}}const $t={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"};function Et(e){switch(e){case"ROUND_CORNER":return"round-corner";case"RECTANGLE":return"rectangle";case"PILL":return"pill";default:throw new Error(`Unknown button shape: ${e}. Right options: ${Object.keys($t)}`)}}function bt(e){const t=e.appearance;t!==void 0&&(e.appearance=yt(t));const o=e.size;o!==void 0&&(e.size=ht(o));const s=e.shape;s!==void 0&&(e.style=Et(s),e.shape=void 0);const n=e.font;e.font=je(n);const i=e.color;return e.color=E(i),e}const Tt={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"};function wt(e){switch(e){case"COLOR":return"solid";case"GRADIENT":return"gradient";case"NONE":return"none";default:throw new Error(`Unknown image overlay type: ${e}. Right options: ${Object.keys(Tt)}`)}}function Ot(e){const t=e.overlay,o=e.color,s=Array.isArray(o)?o:[o,o];return e.overlay={type:wt(t),solid:{color:E(s.at(0))},gradient:{fromColor:E(s.at(0)),toColor:E(s.at(1))}},e.color=void 0,e}function jt(e){const t=e.font;e.font=je(t);const o=e.color;e.color=E(o);const s=e.size;return e.size=lt(s),e}function vt(e){const t=e.color;return e.color=E(t),e}function ve(e){Object.keys(e).forEach(t=>{const o=e[t],s=o.type;Ce(s,o.defaults)})}function Ct(e){Object.keys(e).forEach(t=>{const o=e[t],s=o.type;Ce(s,o)})}function Ce(e,t){switch(e){case"TEXT":{jt(t);break}case"BUTTON":{bt(t);break}case"IMAGE":{Ot(t);break}case"BACKGROUND":{ft(t);break}case"COLOR_PICKER":{vt(t);break}case"TOGGLE":case"SELECTBOX":break;default:throw new Error(`Unknown design editor type: ${e}`)}return t}const Lt="https://blockbuster.ecwid.com";async function Dt(){const e=await x(r(c.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}async function At(){const e=await x(r(c.cwd(),"package.json")),t=JSON.parse(e.toString()),o=Fe(t.version,"patch");return t.version=o,ke(r(c.cwd(),"package.json"),`${JSON.stringify(t,null,2)}
5
- `),t.version}async function Nt(e,t){try{const o=(await import(r(c.cwd(),`dist/sections/${e}/js/settings/content.mjs`))).default;return w(o,t),o}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function St(e,t){try{const o=(await import(r(c.cwd(),`dist/sections/${e}/js/settings/design.mjs`))).default;return ve(o),w(o,t),o}catch(o){const s=o;throw new Error(`Design settings is invalid or undefined. Error ${s.stack}`)}}async function It(e,t){try{const o=await l("*.mjs",{cwd:r(c.cwd(),`dist/sections/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(o.map(async s=>{const n=(await import(r(c.cwd(),`dist/sections/${e}/js/showcases/${s}`))).default;return Ct(n.design),w(n,t),n}))}catch(o){throw new Error(`Showcases is invalid or undefined. Error ${o}`)}}async function Le(e){return await De(`dist/sections/${e}/js/settings/translations.mjs`)}async function Gt(e){return await De(`dist/sections/${e}/js/showcases/translations.mjs`)}async function De(e){const t=(await import(r(c.cwd(),e))).default;return Rt(t)}function w(e,t){if(e&&typeof e=="object"){const o=e;for(let s in o){const n=o[s];typeof n=="string"&&n.startsWith("$")&&(o[s]=_t(t,n)),typeof n=="object"&&w(n,t)}}}function _t(e,t){if(!t)return;const o=e[t];return o===void 0?{en:t}:o}function Rt(e){const t={};for(let o in e){const s=e[o];for(let n in s){const i=t[n],a=s[n];if(i===void 0){const u={};u[o]=a,t[n]=u}else i[o]=a}}return t}async function kt(){const e=await l("*/",{cwd:r(c.cwd(),"dist/sections/")});return Promise.all(e.map(async t=>{const o=await Le(t),s=await Gt(t),n=await Nt(t,o),i=await St(t,o),a=await It(t,s);return{id:t,name:{en:t},contentEditors:n,designEditors:i,showcases:a}}))}async function Bt(e){try{return(await import(r(c.cwd(),e))).default}catch{throw new Error(`Template descriptor [${e}] is either invalid or undefined`)}}async function Pt(){const e=await l("dist/template/js/**.mjs",{ignore:[`dist/template/js/**${T}.mjs`]});return Promise.all(e.map(async t=>{const o=await Bt(t),s=o.sections.filter(n=>n.type==="custom");for(const n of s){const i=await Le(n.id);n.content!==void 0&&w(n.content,i),n.design!==void 0&&(ve(n.design),w(n.design,i))}return{id:`${v(c.cwd()).name.replace(/[^a-zA-Z0-9]/g,"_")}_${v(t).name}`,descriptor:o}}))}async function Ut(e,t,o,s){const n=(await l("server.js",{cwd:r(c.cwd(),`dist/sections/${s}/js/`)})).at(0);n!==void 0&&await e.post("/api/v1/app/resource/upload",{file:C(r(c.cwd(),`dist/sections/${s}/js/server.js`))},{params:{appClientId:t.appClientId,type:"server_js",version:o,block:s,fileName:n},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${t.appSecretKey}`}})}async function xt(e,t,o,s){(await l("*.js",{cwd:r(c.cwd(),`dist/sections/${s}/js/`),ignore:"**/server.js"})).forEach(async n=>{await e.post("/api/v1/app/resource/upload",{file:C(r(c.cwd(),`dist/sections/${s}/js/${n}`))},{params:{appClientId:t.appClientId,type:"client_js",version:o,block:s,fileName:n},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${t.appSecretKey}`}})})}async function Xt(e,t,o,s){(await l("*",{cwd:r(c.cwd(),`dist/sections/${s}/assets/`)})).forEach(async n=>{await e.post("/api/v1/app/resource/upload",{file:C(r(c.cwd(),`dist/sections/${s}/assets/${n}`))},{params:{appClientId:t.appClientId,type:"assets",version:o,block:s,fileName:n},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${t.appSecretKey}`}})})}async function Ft(e,t,o){(await l("package.json")).at(0)!==void 0&&await e.post("/api/v1/app/resource/upload",{file:C(r(c.cwd(),"package.json"))},{params:{appClientId:t.appClientId,type:"dependencies",version:o},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${t.appSecretKey}`}})}async function qt(e,t,o,s){for(const n of s)await Ut(e,t,o,n.id),await xt(e,t,o,n.id),await Xt(e,t,o,n.id),await Ft(e,t,o)}async function Mt(e,t,o,s,n){await e.post("/api/v1/app/manifest",{version:o,name:"Custom Block App",blocks:s,templates:n},{params:{appClientId:t.appClientId},headers:{Authorization:`Bearer ${t.appSecretKey}`}})}async function zt(e){try{const t=e??Lt,o=Xe.create({baseURL:t}),s=await Dt(),n=await At(),i=await kt(),a=await Pt();await qt(o,s,n,i),await Mt(o,s,n,i,a);const u=i.map(y=>y.id);m.info(`Deploy to ${t} successful
6
- Current app version: ${n}
7
- Deployed blocks: ${u.join(", ")}`),a.length>0&&m.info(`Deployed templates: ${a.map(y=>y.id).join(", ")}`)}catch(t){m.error(`Error while deploying: ${t.message}`)}}const Kt="0.1.0",p=Ae("crane");function Jt(){p.command("init","Initialize a new resource in the form of a directory.").option("--app <name>","Creates an app folder inside your current directory.").option("--section <name>","Creates the files necessary for one custom section with the given name, this can be repeated for each section.").option("--template <name>","Creates the directory and files necessary to build a custom template inside your app folder.").action(e=>{if(e.app)return F(e.app);if(e.section)return q(e.section);if(e.template)return M(e.template);p.outputHelp()}),p.command("build","Builds your resource code").action(pt),p.command("deploy","Deploys your resource code into Ecwid"),p.on("command:*",()=>{console.error("Invalid command: %s",p.args.join(" ")),p.outputHelp(),process.exit(1)}),p.on("command:init",()=>{const e=p.options.section,t=p.options.app,o=p.options.template;_(t)?G("app",j("init --app <name>"),F):_(e)?G("section",j("init --section <name>"),q):_(o)&&G("template",j("init --template <name>"),M)}),p.on("command:deploy",()=>zt(p.options.url)),p.help(),p.usage("<action> <resource>"),p.version(Kt),p.parse()}try{Jt()}catch{}async function G(e,t,o){const s=`You can use ${t} to directly specify the name of the ${e}.`;console.log(s);const n=await Me({type:"text",name:"name",message:`Please specify a name for your ${e}:`});if(n.name)return o(n.name);console.log("Please provide a name for the template."),p.outputHelp()}function _(e){return e&&(typeof e!="string"||e.trim().length==0)}
4
+ Errors: ${JSON.stringify([...e.errors??[],...n??[]],null,2)}`)}async function ft(e){const t=[];for(const o of e.sections){const n=e.sections.indexOf(o);if(n===0&&o.id!=="header"&&t.push({instancePath:`/sections/${n}/id`,message:"The first section must be a default `header`"}),n===e.sections.length-1&&o.id!=="footer"&&t.push({instancePath:`/sections/${n}/id`,message:"The last section must be a default `footer`"}),o.type==="custom")if(!L(`dist/sections/${o.id}`))t.push({instancePath:`/sections/${n}/id`,message:"Custom section must have a corresponding block defined"});else{if(o.content!==void 0)if(!L(`dist/sections/${o.id}/js/settings/content.mjs`))t.push({instancePath:`/sections/${n}/content`,message:"Content descriptor is overridden, please provide a default descriptor in the block's settings folder"});else{const s=await P(`dist/sections/${o.id}/js/settings/content`,!1),i=new Set(Object.keys(s));Object.keys(o.content).every(a=>i.has(a))||t.push({instancePath:`/sections/${n}/content`,message:"Content descriptor must be a subset of the default content descriptor"})}if(o.design!==void 0)if(!L(`dist/sections/${o.id}/js/settings/design.mjs`))t.push({instancePath:`/sections/${n}/design`,message:"Design descriptor is overridden, please provide a default descriptor in the block's settings folder"});else{const s=await P(`dist/sections/${o.id}/js/settings/design`,!1),i=new Set(Object.keys(s));Object.keys(o.design).every(a=>i.has(a))||t.push({instancePath:`/sections/${n}/design`,message:"Design descriptor must be a subset of the default design descriptor"})}}}return t.length===0?void 0:t}async function mt(){try{const e=await pt();for(const n of e){const{name:s,serverEntrypoint:i,clientEntrypoint:a,contentSettingsEntrypoint:u,designSettingsEntrypoint:b,settingsTranslationsEntrypoint:y,showcasesEntrypoints:k,showcaseTranslationsEntrypoint:U,assetsEntrypoints:B}=n;if(await g({configFile:!1,...h(Ze(s,i))}),a!==void 0&&await g({configFile:!1,...h(We(s,a))}),u!==void 0&&await g({configFile:!1,...h(_(s,u))}),b!==void 0&&await g({configFile:!1,...h(_(s,b))}),y!==void 0&&await g({configFile:!1,...h(_(s,y))}),k!==void 0)for(const A of k)await g({configFile:!1,...h(H(s,A))});if(U!==void 0&&await g({configFile:!1,...h(H(s,U))}),B!==void 0)for(const A of B)await g({configFile:!1,...h(Qe(s,A))})}const t=await dt(),o=await lt();for(const n of o.entryPoints){await g({configFile:!1,...h(Ye(n,w))});const s=`dist/template/js/${C(n).name}`,i=await P(s,!0);await ut(t,i,s,await ft(i))}c.info("Build successful. For deploy run: npx @lightspeed/crane@latest deploy")}catch(e){c.error(`Error while building: ${e.message}`)}}function Se(e){if(e!==void 0)return e.startsWith("global.")?{type:"GLOBAL_FONT",font:e}:{type:"PRESET_FONT",font:e}}function $(e){if(e===void 0)return;if(e.startsWith("global."))return{type:"GLOBAL_COLOR",raw:e};const t=Ve(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function yt(e){if(e!==void 0)return typeof e=="string"&&e.startsWith("global.")?{type:"GLOBAL_TEXT_SIZE",size:e}:{type:"NUMERIC_TEXT_SIZE",size:e}}const gt={COLOR:"COLOR",GRADIENT:"GRADIENT"};function ht(e){switch(e){case"COLOR":return"solid";case"GRADIENT":return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(gt)}`)}}function $t(e){const t=e.style,o=e.color,n=Array.isArray(o)?o:[o,o];return e.background={type:ht(t),solid:{color:$(n.at(0))},gradient:{fromColor:$(n.at(0)),toColor:$(n.at(1))}},e.style=void 0,e.color=void 0,e}const Et={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"};function bt(e){switch(e){case"SOLID":return"solid-button";case"OUTLINE":return"outline-button";case"TEXT":return"text-link";default:throw new Error(`Unknown button appearance: ${e}. Right options: ${Object.keys(Et)}`)}}const Tt={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"};function wt(e){switch(e){case"SMALL":return"small";case"MEDIUM":return"medium";case"LARGE":return"large";default:throw new Error(`Unknown button size: ${e}. Right options: ${Object.keys(Tt)}`)}}const Ot={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"};function jt(e){switch(e){case"ROUND_CORNER":return"round-corner";case"RECTANGLE":return"rectangle";case"PILL":return"pill";default:throw new Error(`Unknown button shape: ${e}. Right options: ${Object.keys(Ot)}`)}}function vt(e){const t=e.appearance;t!==void 0&&(e.appearance=bt(t));const o=e.size;o!==void 0&&(e.size=wt(o));const n=e.shape;n!==void 0&&(e.style=jt(n),e.shape=void 0);const s=e.font;e.font=Se(s);const i=e.color;return e.color=$(i),e}const Ct={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"};function Lt(e){switch(e){case"COLOR":return"solid";case"GRADIENT":return"gradient";case"NONE":return"none";default:throw new Error(`Unknown image overlay type: ${e}. Right options: ${Object.keys(Ct)}`)}}function St(e){const t=e.overlay,o=e.color,n=Array.isArray(o)?o:[o,o];return e.overlay={type:Lt(t),solid:{color:$(n.at(0))},gradient:{fromColor:$(n.at(0)),toColor:$(n.at(1))}},e.color=void 0,e}function Dt(e){const t=e.font;e.font=Se(t);const o=e.color;e.color=$(o);const n=e.size;return e.size=yt(n),e}function Nt(e){const t=e.color;return e.color=$(t),e}function De(e){Object.keys(e).forEach(t=>{const o=e[t],n=o.type;Ne(n,o.defaults)})}function At(e){Object.keys(e).forEach(t=>{const o=e[t],n=o.type;Ne(n,o)})}function Ne(e,t){switch(e){case"TEXT":{Dt(t);break}case"BUTTON":{vt(t);break}case"IMAGE":{St(t);break}case"BACKGROUND":{$t(t);break}case"COLOR_PICKER":{Nt(t);break}case"TOGGLE":case"SELECTBOX":break;default:throw new Error(`Unknown design editor type: ${e}`)}return t}var E=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.Asset=2]="Asset",e[e.Dependency=3]="Dependency",e))(E||{});const S="dist/sections/",D={[E.Server]:{type:"server_js",isSingleton:!0,toPath:e=>`${S}/${e}/js/`,fileName:"server.js"},[E.Client]:{type:"client_js",isSingleton:!1,toPath:e=>`${S}/${e}/js/`,fileName:"client.js"},[E.Asset]:{type:"assets",isSingleton:!1,toPath:e=>`${S}/${e}/assets/`,fileName:"*"},[E.Dependency]:{type:"dependencies",isSingleton:!0,toPath:()=>{},fileName:"package.json"}},It="https://blockbuster.ecwid.com",Gt="/api/v1/app/resource/upload",_t="/api/v1/app/manifest";async function Pt(){const e=await M(r(d.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}async function Rt(){const e=await M(r(d.cwd(),"package.json")),t=JSON.parse(e.toString()),o=Je(t.version,"patch");return t.version=o,Be(r(d.cwd(),"package.json"),`${JSON.stringify(t,null,2)}
5
+ `),t.version}async function xt(e,t){try{const o=(await import(r(d.cwd(),`dist/sections/${e}/js/settings/content.mjs`))).default;return O(o,t),o}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function kt(e,t){try{const o=(await import(r(d.cwd(),`dist/sections/${e}/js/settings/design.mjs`))).default;return De(o),O(o,t),o}catch(o){const n=o;throw new Error(`Design settings is invalid or undefined. Error ${n.stack}`)}}async function Ut(e,t){try{const o=await m("*.mjs",{cwd:r(d.cwd(),`dist/sections/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(o.map(async n=>{const s=(await import(r(d.cwd(),`dist/sections/${e}/js/showcases/${n}`))).default;return At(s.design),O(s,t),s}))}catch(o){throw new Error(`Showcases is invalid or undefined. Error ${o}`)}}async function Ae(e){return await Ie(`dist/sections/${e}/js/settings/translations.mjs`)}async function Bt(e){return await Ie(`dist/sections/${e}/js/showcases/translations.mjs`)}async function Ie(e){const t=(await import(r(d.cwd(),e))).default;return Ft(t)}function O(e,t){if(e&&typeof e=="object"){const o=e;for(let n in o){const s=o[n];typeof s=="string"&&s.startsWith("$")&&(o[n]=Xt(t,s)),typeof s=="object"&&O(s,t)}}}function Xt(e,t){if(!t)return;const o=e[t];return o===void 0?{en:t}:o}function Ft(e){const t={};for(let o in e){const n=e[o];for(let s in n){const i=t[s],a=n[s];if(i===void 0){const u={};u[o]=a,t[s]=u}else i[o]=a}}return t}async function qt(){const e=await m("*/",{cwd:r(d.cwd(),"dist/sections/")});return Promise.all(e.map(async t=>{const o=await Ae(t),n=await Bt(t),s=await xt(t,o),i=await kt(t,o),a=await Ut(t,n);return{id:t,name:{en:t},contentEditors:s,designEditors:i,showcases:a}}))}async function Mt(e){try{return(await import(r(d.cwd(),e))).default}catch{throw new Error(`Template descriptor [${e}] is either invalid or undefined`)}}async function zt(){const e=await m("dist/template/js/**.mjs",{ignore:[`dist/template/js/**${w}.mjs`]});return Promise.all(e.map(async t=>{const o=await Mt(t),n=o.sections.filter(s=>s.type==="custom");for(const s of n){const i=await Ae(s.id);s.content!==void 0&&O(s.content,i),s.design!==void 0&&(De(s.design),O(s.design,i))}return{id:`${C(d.cwd()).name.replace(/[^a-zA-Z0-9]/g,"_")}_${C(t).name}`,descriptor:o}}))}function Kt(e){const t=e.pathContext,o=t.toPath(e.currentSection),n=o===void 0?X(t.fileName):X(t.fileName,{cwd:r(d.cwd(),o),ignore:t.ignore});return t.isSingleton?n.splice(0):n}function N(e){const t=Kt(e),o=e.pathContext.toPath(e.currentSection);return t.map(n=>e.config.axios.post(Gt,{file:Xe(r(d.cwd(),o!==void 0?o+n:n))},{params:{appClientId:e.config.app.crane.appClientId,type:e.pathContext.type,version:e.config.app.version,...e.currentSection!==void 0&&{block:e.currentSection},...e.pathContext.type!=="dependencies"&&{fileName:n}},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${e.config.app.crane.appSecretKey}`}}).then(s=>s.data).catch(s=>{c.error(`Error while deploying file type[${e.pathContext.type}]: ${s.message}`)}))}function Jt(e){return[...e.app.sections.flatMap(t=>[...N({config:e,currentSection:t.id,pathContext:D[E.Server]}),...N({config:e,currentSection:t.id,pathContext:D[E.Client]}),...N({config:e,currentSection:t.id,pathContext:D[E.Asset]})]),...N({config:e,pathContext:D[E.Dependency]})]}async function Vt(e){try{return e.axios.post(_t,{version:e.app.version,name:"Custom Block App",blocks:e.app.sections,templates:e.app.templates},{params:{appClientId:e.app.crane.appClientId},headers:{Authorization:`Bearer ${e.app.crane.appSecretKey}`}})}catch(t){c.error(`Error while deploying manifest file: ${t.message}`)}}async function Ht(e){try{if(!L(r(d.cwd(),S))){c.error("Error while deploying: dist/sections folder not found");return}c.info("Custom application deployment :: Started");const t=e??It,o=Ke.create({baseURL:t});c.info("Loading configuration files ...");const n=await Promise.all([Pt(),Rt(),qt(),zt()]).then(([i,a,u,b])=>({axios:o,app:{crane:i,version:a,sections:u,templates:b}}));c.info("Uploading asset files ..."),await Promise.all(Jt(n)),c.info("Uploading manifest files ..."),await Vt(n);const s=n.app.sections.map(i=>i.id);c.info(`Custom application deployment [${t}] :: Successful
6
+ Current app version: ${n.app.version}
7
+ Deployed sections: ${s.join(", ")}`),n.app.templates.length>0&&c.info(`Deployed templates: ${n.app.templates.map(i=>i.id).join(", ")}`)}catch(t){c.error(`Error while deploying: ${t.message}`)}}const Wt="1.0.0",p=Ge("crane");function Zt(){p.command("init","Initialize a new resource in the form of a directory.").option("--app <name>","Creates an app folder inside your current directory.").option("--section <name>","Creates the files necessary for one custom section with the given name, this can be repeated for each section.").option("--template <name>","Creates the directory and files necessary to build a custom template inside your app folder.").action(e=>{if(e.app)return K(e.app);if(e.section)return J(e.section);if(e.template)return V(e.template);p.outputHelp()}),p.command("build","Builds your resource code").action(mt),p.command("deploy","Deploys your resource code into Ecwid"),p.on("command:*",()=>{console.error("Invalid command: %s",p.args.join(" ")),p.outputHelp(),process.exit(1)}),p.on("command:init",()=>{const e=p.options.section,t=p.options.app,o=p.options.template;x(t)?R("app",v("init --app <name>"),K):x(e)?R("section",v("init --section <name>"),J):x(o)&&R("template",v("init --template <name>"),V)}),p.on("command:deploy",()=>Ht(p.options.url)),p.help(),p.usage("<action> <resource>"),p.version(Wt),p.parse()}try{Zt()}catch{}async function R(e,t,o){const n=`You can use ${t} to directly specify the name of the ${e}.`;console.log(n);const s=await He({type:"text",name:"name",message:`Please specify a name for your ${e}:`});if(s.name)return o(s.name);console.log("Please provide a name for the template."),p.outputHelp()}function x(e){return e&&(typeof e!="string"||e.trim().length==0)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightspeed/crane",
3
- "version": "0.1.0",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "bin": "bin/crane.js",
6
6
  "main": "./dist/app.mjs",
@@ -24,14 +24,23 @@
24
24
  "scripts": {
25
25
  "dev": "unbuild --stub",
26
26
  "build": "unbuild",
27
- "lint": "eslint \"./{src,test}/**/*.{js,ts}\""
27
+ "lint": "eslint \"./{src,test}/**/*.{js,ts}\"",
28
+ "test": "jest"
28
29
  },
29
30
  "engines": {
30
31
  "node": ">=20"
31
32
  },
32
33
  "devDependencies": {
34
+ "@types/express-fileupload": "^1.5.0",
33
35
  "@types/fs-extra": "^11.0.1",
36
+ "@types/jest": "^29.5.12",
34
37
  "@types/node": "^20.4.5",
38
+ "dir-compare": "^5.0.0",
39
+ "express": "^4.19.2",
40
+ "express-fileupload": "^1.5.1",
41
+ "jest": "^29.7.0",
42
+ "ts-jest": "^29.1.5",
43
+ "ts-node": "^10.9.2",
35
44
  "typescript": "5.4.5",
36
45
  "unbuild": "^2.0.0",
37
46
  "vite-plugin-dts": "^3.4.0",
@@ -39,7 +48,7 @@
39
48
  },
40
49
  "dependencies": {
41
50
  "@jridgewell/sourcemap-codec": "^1.4.15",
42
- "@lightspeed/eslint-config-crane": "0.1.0",
51
+ "@lightspeed/eslint-config-crane": "1.0.0",
43
52
  "@types/prompts": "^2.4.2",
44
53
  "@vitejs/plugin-vue": "^4.1.0",
45
54
  "ajv": "^8.12.0",
@@ -7,8 +7,8 @@
7
7
  "deploy": "crane build && crane deploy"
8
8
  },
9
9
  "dependencies": {
10
- "@lightspeed/crane": "0.1.0",
11
- "@lightspeed/eslint-config-crane": "0.1.0",
10
+ "@lightspeed/crane": "1.0.0",
11
+ "@lightspeed/eslint-config-crane": "1.0.0",
12
12
  "vue": "^3.4.0"
13
13
  },
14
14
  "engines": {
@@ -0,0 +1,53 @@
1
+ <template>
2
+ <div
3
+ class="custom-block"
4
+ :style="backgroundStyle"
5
+ >
6
+ <div>
7
+ <CustomSectionExampleTitle />
8
+ <div class="custom-block__blank_space" />
9
+ <CustomSectionExampleImagesGrid />
10
+ </div>
11
+ </div>
12
+ </template>
13
+
14
+ <script setup lang="ts">
15
+ import { useBackgroundElementDesign } from '@lightspeed/crane';
16
+ import { computed } from 'vue';
17
+ import { Design } from './type.ts';
18
+ import CustomSectionExampleTitle from './component/title/Title.vue';
19
+ import CustomSectionExampleImagesGrid from './component/image/ImagesGrid.vue';
20
+
21
+ const backgroundDesign = useBackgroundElementDesign<Design>('background');
22
+ const background = computed(() => ({
23
+ type: backgroundDesign.background?.type,
24
+ solidColor: backgroundDesign.background?.solid?.color as Color,
25
+ fromColor: backgroundDesign.background?.gradient?.fromColor as Color,
26
+ toColor: backgroundDesign.background?.gradient?.toColor as Color,
27
+ }));
28
+
29
+ const backgroundStyle = computed(() => {
30
+ if (background.value.type === 'gradient') {
31
+ return { 'background-image': `linear-gradient(to right, ${background.value.fromColor.hex}, ${background.value.toColor.hex})` };
32
+ }
33
+ return { 'background-color': background.value.solidColor.hex };
34
+ });
35
+ </script>
36
+
37
+ <style lang="scss" scoped>
38
+ .custom-block {
39
+ padding: 50px;
40
+
41
+ @media screen and (min-width: 700px) {
42
+ padding: 75px;
43
+ }
44
+
45
+ @media screen and (min-width: 1200px) {
46
+ padding: 100px;
47
+ }
48
+
49
+ &__blank_space {
50
+ height: 40px;
51
+ }
52
+ }
53
+ </style>
@@ -0,0 +1,5 @@
1
+ import { createVueClientApp } from '@lightspeed/crane';
2
+ import ExampleSection from './ExampleSection.vue';
3
+ import { Content, Design } from './type.ts';
4
+
5
+ export default createVueClientApp<Content, Design>(ExampleSection);