@total_onion/onion-library 3.2.0 → 3.2.2
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/.github/workflows/npm-publish.yml +38 -0
- package/.prettierrc +22 -0
- package/__spec__/copyBlockComponent.spec.js +94 -0
- package/__spec__/copyFile.spec.js +78 -0
- package/__spec__/copyFileKeeping.spec.js +74 -0
- package/__spec__/files/source.txt +1 -0
- package/__spec__/update-all-components.spec.js +99 -0
- package/__spec__/update-component.spec.js +165 -0
- package/assembleAssetList.js +69 -0
- package/breakpoints.scss +6 -0
- package/build-library.js +4 -0
- package/checkBuildAssets.js +17 -0
- package/components/block-accent-image-v3/accent-image-v3.js +7 -0
- package/components/block-accent-image-v3/accent-image-v3.scss +4 -0
- package/components/block-accent-image-v3/accent-image-v3.twig +137 -0
- package/components/block-accent-image-v3/group_6890e1233ff2d.json +81 -0
- package/components/block-accordion-v3/accordion-v3.js +119 -0
- package/components/block-accordion-v3/accordion-v3.scss +197 -0
- package/components/block-accordion-v3/accordion-v3.twig +51 -0
- package/components/block-accordion-v3/group_6888d2f0b230b.json +458 -0
- package/components/block-back-to-top-button-v3/back-to-top-button-v3.js +12 -0
- package/components/block-back-to-top-button-v3/back-to-top-button-v3.scss +68 -0
- package/components/block-back-to-top-button-v3/back-to-top-button-v3.twig +40 -0
- package/components/block-back-to-top-button-v3/group_63e24e04a1e61.json +323 -0
- package/components/block-betterreviews-display-v3/betterreviews-display-v3.js +10 -0
- package/components/block-betterreviews-display-v3/betterreviews-display-v3.scss +104 -0
- package/components/block-betterreviews-display-v3/betterreviews-display-v3.twig +24 -0
- package/components/block-betterreviews-display-v3/group_6892880fc1a00.json +182 -0
- package/components/block-block-interactions-v3/block-interactions-v3.js +53 -0
- package/components/block-block-interactions-v3/block-interactions-v3.scss +32 -0
- package/components/block-block-interactions-v3/block-interactions-v3.twig +55 -0
- package/components/block-block-interactions-v3/group_687e1575ba23d.json +700 -0
- package/components/block-carousel-multi-layout-v3/carousel-multi-layout-v3.js +243 -0
- package/components/block-carousel-multi-layout-v3/carousel-multi-layout-v3.scss +156 -0
- package/components/block-carousel-multi-layout-v3/carousel-multi-layout-v3.twig +146 -0
- package/components/block-carousel-multi-layout-v3/group_686bd42e551d6.json +578 -0
- package/components/block-cocktail-recipe-v3/cocktail-recipe-v3.js +127 -0
- package/components/block-cocktail-recipe-v3/cocktail-recipe-v3.scss +345 -0
- package/components/block-cocktail-recipe-v3/cocktail-recipe-v3.twig +93 -0
- package/components/block-cocktail-recipe-v3/group_68fff19fa4dd0.json +202 -0
- package/components/block-cover-link-v3/cover-link-v3.js +7 -0
- package/components/block-cover-link-v3/cover-link-v3.scss +10 -0
- package/components/block-cover-link-v3/cover-link-v3.twig +16 -0
- package/components/block-cover-link-v3/group_687192c28b7eb.json +96 -0
- package/components/block-divider-v3/divider-v3.js +8 -0
- package/components/block-divider-v3/divider-v3.scss +103 -0
- package/components/block-divider-v3/divider-v3.twig +45 -0
- package/components/block-divider-v3/group_686b919696bfe.json +891 -0
- package/components/block-featured-image-gallery-v3/featured-image-gallery-v3.js +44 -0
- package/components/block-featured-image-gallery-v3/featured-image-gallery-v3.scss +93 -0
- package/components/block-featured-image-gallery-v3/featured-image-gallery-v3.twig +43 -0
- package/components/block-featured-image-gallery-v3/group_5f91897095b42.json +88 -0
- package/components/block-form-selection-v3/form-selection-v3.js +78 -0
- package/components/block-form-selection-v3/form-selection-v3.scss +38 -0
- package/components/block-form-selection-v3/form-selection-v3.twig +84 -0
- package/components/block-form-selection-v3/group_68752e7949e53.json +351 -0
- package/components/block-gradient-layer-v3/gradient-layer-v3.js +7 -0
- package/components/block-gradient-layer-v3/gradient-layer-v3.scss +8 -0
- package/components/block-gradient-layer-v3/gradient-layer-v3.twig +78 -0
- package/components/block-gradient-layer-v3/group_686fdadc85df4.json +206 -0
- package/components/block-group-container-v3/group-container-v3.js +7 -0
- package/components/block-group-container-v3/group-container-v3.php +14 -0
- package/components/block-group-container-v3/group-container-v3.scss +45 -0
- package/components/block-group-container-v3/group-container-v3.twig +70 -0
- package/components/block-group-container-v3/group_6865578ada499.json +3660 -0
- package/components/block-lottie-content-v3/group_687197027216d.json +177 -0
- package/components/block-lottie-content-v3/lottie-content-v3.js +25 -0
- package/components/block-lottie-content-v3/lottie-content-v3.scss +2 -0
- package/components/block-lottie-content-v3/lottie-content-v3.twig +15 -0
- package/components/block-market-selector-v3/group_68752075dd831.json +129 -0
- package/components/block-market-selector-v3/market-selector-v3.js +7 -0
- package/components/block-market-selector-v3/market-selector-v3.scss +120 -0
- package/components/block-market-selector-v3/market-selector-v3.twig +40 -0
- package/components/block-modal-form-v3/modal-form-v3.js +59 -0
- package/components/block-modal-form-v3/modal-form-v3.scss +6 -0
- package/components/block-modal-form-v3/modal-form-v3.twig +30 -0
- package/components/block-nav-menu-container-v3/group_687e00b45e9a3.json +187 -0
- package/components/block-nav-menu-container-v3/nav-menu-container-v3.js +7 -0
- package/components/block-nav-menu-container-v3/nav-menu-container-v3.scss +3 -0
- package/components/block-nav-menu-container-v3/nav-menu-container-v3.twig +23 -0
- package/components/block-post-info-v3/group_6866429531436.json +3112 -0
- package/components/block-post-info-v3/post-info-v3/bazaarvoice-inline.twig +13 -0
- package/components/block-post-info-v3/post-info-v3/better-reviews.twig +15 -0
- package/components/block-post-info-v3/post-info-v3/divider.twig +8 -0
- package/components/block-post-info-v3/post-info-v3/drink-description.twig +10 -0
- package/components/block-post-info-v3/post-info-v3/global-image.twig +22 -0
- package/components/block-post-info-v3/post-info-v3/gradient-layer.twig +78 -0
- package/components/block-post-info-v3/post-info-v3/gradient-overlay.twig +10 -0
- package/components/block-post-info-v3/post-info-v3/post-author.twig +17 -0
- package/components/block-post-info-v3/post-info-v3/post-buy-now.twig +116 -0
- package/components/block-post-info-v3/post-info-v3/post-categories.twig +15 -0
- package/components/block-post-info-v3/post-info-v3/post-headline.twig +15 -0
- package/components/block-post-info-v3/post-info-v3/post-image.twig +47 -0
- package/components/block-post-info-v3/post-info-v3/post-info-description.twig +15 -0
- package/components/block-post-info-v3/post-info-v3/post-info-subtitle.twig +14 -0
- package/components/block-post-info-v3/post-info-v3/post-link.twig +42 -0
- package/components/block-post-info-v3/post-info-v3/post-name.twig +12 -0
- package/components/block-post-info-v3/post-info-v3/post-publish-date.twig +12 -0
- package/components/block-post-info-v3/post-info-v3/post-tags.twig +24 -0
- package/components/block-post-info-v3/post-info-v3/post-text-alternative-style.twig +16 -0
- package/components/block-post-info-v3/post-info-v3/post-title.twig +15 -0
- package/components/block-post-info-v3/post-info-v3/post-video.twig +27 -0
- package/components/block-post-info-v3/post-info-v3/reservebar-add-to-cart.twig +32 -0
- package/components/block-post-info-v3/post-info-v3/shopify-add-to-cart.twig +31 -0
- package/components/block-post-info-v3/post-info-v3/social-networks.twig +33 -0
- package/components/block-post-info-v3/post-info-v3/spacer-v3.twig +9 -0
- package/components/block-post-info-v3/post-info-v3.js +10 -0
- package/components/block-post-info-v3/post-info-v3.scss +210 -0
- package/components/block-post-info-v3/post-info-v3.twig +67 -0
- package/components/block-product-info-v3/group_68909995b6550.json +3544 -0
- package/components/block-product-info-v3/product-info-v3/product-abv.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-cask-type-label.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-cask-type.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-colour-label.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-colour.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-description.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-finish-label.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-finish.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-headline.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-image.twig +43 -0
- package/components/block-product-info-v3/product-info-v3/product-name.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-nose-label.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-nose.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-pair-with-label.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-pair-with.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-palate-label.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-palate.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-taste-label.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-taste.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/product-volume.twig +14 -0
- package/components/block-product-info-v3/product-info-v3/spacer-v3.twig +9 -0
- package/components/block-product-info-v3/product-info-v3.js +7 -0
- package/components/block-product-info-v3/product-info-v3.scss +171 -0
- package/components/block-product-info-v3/product-info-v3.twig +43 -0
- package/components/block-raw-html-v3/group_686ba68d603a2.json +212 -0
- package/components/block-raw-html-v3/raw-html-v3.js +7 -0
- package/components/block-raw-html-v3/raw-html-v3.scss +2 -0
- package/components/block-raw-html-v3/raw-html-v3.twig +17 -0
- package/components/block-responsive-table-v3/group_6617ecc987ddd.json +394 -0
- package/components/block-responsive-table-v3/responsive-table-v3.js +7 -0
- package/components/block-responsive-table-v3/responsive-table-v3.scss +49 -0
- package/components/block-responsive-table-v3/responsive-table-v3.twig +47 -0
- package/components/block-scrolling-banner-v3/group_68e67fca1ec80.json +664 -0
- package/components/block-scrolling-banner-v3/scrolling-banner-v3.js +144 -0
- package/components/block-scrolling-banner-v3/scrolling-banner-v3.scss +104 -0
- package/components/block-scrolling-banner-v3/scrolling-banner-v3.twig +72 -0
- package/components/block-section-separator-v3/group_6874c8d79b84b.json +576 -0
- package/components/block-section-separator-v3/section-separator-v3.js +7 -0
- package/components/block-section-separator-v3/section-separator-v3.scss +42 -0
- package/components/block-section-separator-v3/section-separator-v3.twig +46 -0
- package/components/block-single-column-container-v3/group_6887640458d61.json +481 -0
- package/components/block-single-column-container-v3/single-column-container-v3.js +7 -0
- package/components/block-single-column-container-v3/single-column-container-v3.scss +14 -0
- package/components/block-single-column-container-v3/single-column-container-v3.twig +30 -0
- package/components/block-single-responsive-image-v3/group_6867bcf24c2fc.json +128 -0
- package/components/block-single-responsive-image-v3/single-responsive-image-v3.js +7 -0
- package/components/block-single-responsive-image-v3/single-responsive-image-v3.scss +9 -0
- package/components/block-single-responsive-image-v3/single-responsive-image-v3.twig +24 -0
- package/components/block-site-copyright-notice-v3/group_66296c3716b4f.json +304 -0
- package/components/block-site-copyright-notice-v3/index.html +33 -0
- package/components/block-site-copyright-notice-v3/site-copyright-notice-v3.js +58 -0
- package/components/block-site-copyright-notice-v3/site-copyright-notice-v3.scss +21 -0
- package/components/block-site-copyright-notice-v3/site-copyright-notice-v3.twig +30 -0
- package/components/block-site-logo-container-v3/group_687e3b887b508.json +175 -0
- package/components/block-site-logo-container-v3/site-logo-container-v3.js +7 -0
- package/components/block-site-logo-container-v3/site-logo-container-v3.scss +29 -0
- package/components/block-site-logo-container-v3/site-logo-container-v3.twig +40 -0
- package/components/block-site-title-and-tagline-v3/site-title-and-tagline-v3.js +7 -0
- package/components/block-site-title-and-tagline-v3/site-title-and-tagline-v3.scss +16 -0
- package/components/block-site-title-and-tagline-v3/site-title-and-tagline-v3.twig +24 -0
- package/components/block-smash-balloon-social-media-v3/smash-balloon-social-media-v3.js +8 -0
- package/components/block-smash-balloon-social-media-v3/smash-balloon-social-media-v3.scss +31 -0
- package/components/block-smash-balloon-social-media-v3/smash-balloon-social-media-v3.twig +18 -0
- package/components/block-social-networks-v3/group_6891d4d7db414.json +146 -0
- package/components/block-social-networks-v3/social-networks-v3.js +7 -0
- package/components/block-social-networks-v3/social-networks-v3.scss +7 -0
- package/components/block-social-networks-v3/social-networks-v3.twig +24 -0
- package/components/block-spacer-v3/group_686b8cb48c708.json +131 -0
- package/components/block-spacer-v3/spacer-v3.js +8 -0
- package/components/block-spacer-v3/spacer-v3.scss +19 -0
- package/components/block-spacer-v3/spacer-v3.twig +13 -0
- package/components/block-spotify-embed-v3/group_67d04c4c4cf78.json +120 -0
- package/components/block-spotify-embed-v3/spotify-embed-v3.js +7 -0
- package/components/block-spotify-embed-v3/spotify-embed-v3.scss +11 -0
- package/components/block-spotify-embed-v3/spotify-embed-v3.twig +23 -0
- package/components/block-standard-content-v3/group_68655756737c9.json +344 -0
- package/components/block-standard-content-v3/standard-content-v3.js +39 -0
- package/components/block-standard-content-v3/standard-content-v3.scss +11 -0
- package/components/block-standard-content-v3/standard-content-v3.twig +46 -0
- package/components/block-sticky-buy-cta-v3/group_68b061bb56543.json +172 -0
- package/components/block-sticky-buy-cta-v3/sticky-buy-cta-v3.js +7 -0
- package/components/block-sticky-buy-cta-v3/sticky-buy-cta-v3.scss +2 -0
- package/components/block-sticky-buy-cta-v3/sticky-buy-cta-v3.twig +92 -0
- package/components/block-sub-group-container-v3/group_686ceba7d6066.json +2142 -0
- package/components/block-sub-group-container-v3/sub-group-container-v3.js +9 -0
- package/components/block-sub-group-container-v3/sub-group-container-v3.scss +27 -0
- package/components/block-sub-group-container-v3/sub-group-container-v3.twig +59 -0
- package/components/block-video-content-v3/group_687190b8d26df.json +169 -0
- package/components/block-video-content-v3/video-content-v3.js +12 -0
- package/components/block-video-content-v3/video-content-v3.scss +123 -0
- package/components/block-video-content-v3/video-content-v3.twig +26 -0
- package/components/component-accent-image-v3/accent-image-v3.twig +119 -0
- package/components/component-accent-image-v3/group_686cd5547efd2.json +975 -0
- package/components/component-accent-text-v3/accent-text-v3-extra.scss +2 -0
- package/components/component-accent-text-v3/accent-text-v3.scss +60 -0
- package/components/component-accent-text-v3/group_686b91fed8f5f.json +220 -0
- package/components/component-accordion-v3/accordion-v3.js +113 -0
- package/components/component-accordion-v3/accordion-v3.scss +189 -0
- package/components/component-accordion-v3/accordion-v3.twig +39 -0
- package/components/component-accordion-v3/group_66ab7edfc6d63.json +535 -0
- package/components/component-animations-style-v3/animations-style-v3.twig +5 -0
- package/components/component-animations-v3/animations-v3.scss +161 -0
- package/components/component-animations-v3/animations-v3.twig +19 -0
- package/components/component-animations-v3/group_689f39c37980a.json +499 -0
- package/components/component-better-reviews-v3/better-reviews-v3.scss +137 -0
- package/components/component-block-padding-v3/block-padding-v3.scss +64 -0
- package/components/component-block-padding-v3/block-padding-v3.twig +33 -0
- package/components/component-block-padding-v3/group_689f66f3e26df.json +535 -0
- package/components/component-block-settings-v3/block-settings-v3.scss +46 -0
- package/components/component-block-settings-v3/block-settings-v3.twig +34 -0
- package/components/component-block-settings-v3/group_689f649af2ac4.json +983 -0
- package/components/component-blockquote-v3/blockquote-v3.scss +54 -0
- package/components/component-box-shadow-v3/box-shadow-v3.scss +12 -0
- package/components/component-buy-now-button-v3/buy-now-buttons-v3.twig +69 -0
- package/components/component-carousel-fields-v3/group_686fd30f4d873.json +3025 -0
- package/components/component-child-block-video-fields/group_6852a4f384204.json +536 -0
- package/components/component-content-box-settings-v3/content-box-settings-v3.scss +205 -0
- package/components/component-content-box-settings-v3/content-box-settings-v3.twig +156 -0
- package/components/component-content-box-settings-v3/group_686e6ec702acc.json +1729 -0
- package/components/component-content-box-v3/content-box-v3.js +6 -0
- package/components/component-content-box-v3/content-box-v3.scss +28 -0
- package/components/component-content-box-v3/content-box-v3.twig +23 -0
- package/components/component-content-box-v3/group_686b8a4f1fe5d.json +568 -0
- package/components/component-content-image-v3/content-image-v3.scss +33 -0
- package/components/component-content-image-v3/content-image-v3.twig +77 -0
- package/components/component-content-image-v3/group_68722935c428f.json +647 -0
- package/components/component-core-body-close-v3/core-body-close-v3.twig +2 -0
- package/components/component-core-body-open-v3/core-body-open-v3.twig +32 -0
- package/components/component-core-group-container-styles-v3/core-group-container-styles-v3.scss +48 -0
- package/components/component-core-head-v3/core-head-v3.twig +62 -0
- package/components/component-cta-selection-v3/cta-selection-v3.twig +256 -0
- package/components/component-cta-selection-v3/group_686e93eb832a6.json +1117 -0
- package/components/component-e-shop-settings-v3/e-shop-settings-v3.twig +114 -0
- package/components/component-element-positioning-v3/element-positioning-v3.scss +41 -0
- package/components/component-element-positioning-v3/element-positioning-v3.twig +42 -0
- package/components/component-element-positioning-v3/group_6882281544263.json +635 -0
- package/components/component-endpoints/endpoints.php +32 -0
- package/components/component-flex-layout-container-v3/flex-layout-container-v3.scss +38 -0
- package/components/component-flex-layout-container-v3/flex-layout-container-v3.twig +28 -0
- package/components/component-flex-layout-container-v3/group_6887a026bbc33.json +773 -0
- package/components/component-global-content-max-width-v3/global-content-max-width-v3.twig +10 -0
- package/components/component-global-content-max-width-v3/group_63c83de4f0a99.json +58 -0
- package/components/component-gradient-overlay-v3/gradient-overlay-v3.scss +43 -0
- package/components/component-gradient-overlay-v3/gradient-overlay-v3.twig +58 -0
- package/components/component-gradient-overlay-v3/group_686fd9ca50b63.json +495 -0
- package/components/component-grid-gap-mults-v3/grid-gap-mults-v3.twig +10 -0
- package/components/component-grid-gap-mults-v3/group_689221b94ce69.json +220 -0
- package/components/component-grid-layout-container-v3/grid-layout-container-v3.scss +154 -0
- package/components/component-grid-layout-container-v3/grid-layout-container-v3.twig +88 -0
- package/components/component-grid-layout-container-v3/group_6882282e65bf2.json +1525 -0
- package/components/component-grid-layout-element-v3/grid-layout-element-v3.scss +47 -0
- package/components/component-grid-layout-element-v3/grid-layout-element-v3.twig +23 -0
- package/components/component-grid-layout-element-v3/group_68822860bda9f.json +728 -0
- package/components/component-nav-menu-v3/group_68da703f710ff.json +432 -0
- package/components/component-nav-menu-v3/nav-menu-v3.scss +43 -0
- package/components/component-nav-menu-v3/nav-menu-v3.twig +75 -0
- package/components/component-responsive-image-v3/group_6867bc53f1da8.json +1515 -0
- package/components/component-responsive-image-v3/responsive-image-v3.scss +63 -0
- package/components/component-responsive-image-v3/responsive-image-v3.twig +71 -0
- package/components/component-responsive-picture-element-v3/responsive-picture-element-v3.twig +35 -0
- package/components/component-responsive-show-hide/responsive-show-hide-v3.twig +9 -0
- package/components/component-social-media-share-v3/social-media-share-v3-extra.scss +6 -0
- package/components/component-social-media-share-v3/social-media-share-v3.scss +131 -0
- package/components/component-social-networks-v3/social-networks-v3.scss +73 -0
- package/components/component-social-networks-v3/social-networks-v3.twig +43 -0
- package/components/component-text-editor-settings-container-classes-v3/text-editor-settings-container-classes-v3.twig +9 -0
- package/components/component-text-editor-settings-element-classes-v3/text-editor-settings-element-classes-v3.twig +13 -0
- package/components/component-text-editor-settings-v3/group_687a4e2334e37.json +1377 -0
- package/components/component-text-editor-settings-variables-v3/text-editor-settings-variables-v3.twig +61 -0
- package/components/component-video-component-v3/video-component-v3.twig +90 -0
- package/components/component-video-fields-v3/group_6872282f44634.json +1013 -0
- package/components/component-video-trigger-button-v3/video-trigger-button-v3.twig +14 -0
- package/components/component-wysiwyg-editor-v3/group_6867e153af466.json +127 -0
- package/components/component-wysiwyg-editor-v3/wysiwyg-editor-v3.twig +18 -0
- package/components/core-block-editor-assets-v3/core-block-editor-assets-v3.php +14 -0
- package/components/core-core-block-render-function-v3/core-block-render-function-v3.php +39 -0
- package/components/core-core-design-settings-v3/core-design-settings-v3.php +43 -0
- package/components/core-core-post-overrides-v3/core-post-overrides-v3.php +21 -0
- package/components/core-core-themes/core-themes-v3.php +68 -0
- package/components/core-core-typography-v3/core-typography-v3.php +239 -0
- package/components/core-globals/globals.php +39 -0
- package/components/entrypoint-entry-point-classes-v3/entry-point-classes-v3.twig +12 -0
- package/components/entrypoint-entry-point-html-v3/entry-point-html-v3.twig +19 -0
- package/components/entrypoint-entry-point-style-v3/entry-point-style-v3.twig +11 -0
- package/components/fields-acf-wysiwyg-options-v3/acf-wysiwyg-options-v3.php +221 -0
- package/components/fields-animations-v3/animations-v3.scss +127 -0
- package/components/fields-archive-pages-v3/group_635e777ce46d4.json +150 -0
- package/components/fields-cocktail-info-v3/group_64c29b7f188ca.json +686 -0
- package/components/fields-content-container-settings-v3/content-container-settings-v3.scss +213 -0
- package/components/fields-content-container-v3/content-container-v3.js +96 -0
- package/components/fields-content-container-v3/content-container-v3.scss +31 -0
- package/components/fields-core-critical-v3/core-critical-v3.scss +13 -0
- package/components/fields-core-css-modules-v3/core-css-modules-v3.scss +13 -0
- package/components/fields-core-css-sizing-vars-v3/core-css-sizing-vars-v3.scss +125 -0
- package/components/fields-core-cta-v3/core-cta-v3.scss +276 -0
- package/components/fields-core-functions-v3/core-functions-v3.scss +30 -0
- package/components/fields-core-generic-v3/core-generic-v3.scss +299 -0
- package/components/fields-core-mixins-v3/core-mixins-v3.scss +744 -0
- package/components/fields-core-root-variables-v3/core-root-variables-v3.scss +47 -0
- package/components/fields-core-typography-mixins-v3/core-typography-mixins-v3.scss +1080 -0
- package/components/fields-core-typography-v3/core-typography-v3.scss +457 -0
- package/components/fields-core-wordpress-block-editor-preview-v3/core-wordpress-block-editor-preview-v3.js +270 -0
- package/components/fields-core-wordpress-block-editor-preview-v3/core-wordpress-block-editor-preview-v3.scss +106 -0
- package/components/fields-drink-responsibly-notice-v3/group_68751257883ad.json +266 -0
- package/components/fields-dynamic-critical-css-v3/group_65abcd463e8d0.json +126 -0
- package/components/fields-e-shop-settings-v3/e-shop-settings-v3.twig +87 -0
- package/components/fields-e-shop-settings-v3/group_650b24b4e623d.json +803 -0
- package/components/fields-global-preload-v3/group_65e0bd35e781b.json +289 -0
- package/components/fields-image-management-service-v3/group_677813165b633.json +149 -0
- package/components/fields-ingredients-list/group_6900f19dadebf.json +225 -0
- package/components/fields-modal-popup-content-v3/group_689876f1ee3fc.json +403 -0
- package/components/fields-modal-popup-content-v3/modal-popup-content-v3.twig +18 -0
- package/components/fields-post-info-v3/group_6867bbe167dd2.json +1089 -0
- package/components/fields-product-info-v3/group_689098dd3a131.json +721 -0
- package/components/fields-upload-filesize-limit-v3/group_659d259760a1d.json +56 -0
- package/components/fields-video-management-services-v3/group_67b4cac05cb30.json +146 -0
- package/components/webc-counter-display/counter-display.css +2 -0
- package/components/webc-counter-display/counter-display.html +5 -0
- package/components/webc-counter-display/counter-display.js +30 -0
- package/components/webc-counter-display/index.html +30 -0
- package/components/webc-layout-container/index.html +108 -0
- package/components/webc-layout-container/layout-container.css +9 -0
- package/components/webc-layout-container/layout-container.html +5 -0
- package/components/webc-layout-container/layout-container.js +22 -0
- package/components/webc-loadmore-trigger/index.html +30 -0
- package/components/webc-loadmore-trigger/loadmore-trigger.css +20 -0
- package/components/webc-loadmore-trigger/loadmore-trigger.html +6 -0
- package/components/webc-loadmore-trigger/loadmore-trigger.js +34 -0
- package/components/webc-post-carousel-display-module/index.html +30 -0
- package/components/webc-post-carousel-display-module/post-carousel-display-module.css +36 -0
- package/components/webc-post-carousel-display-module/post-carousel-display-module.html +5 -0
- package/components/webc-post-carousel-display-module/post-carousel-display-module.js +48 -0
- package/components/webc-post-filter-module/dev-content/amber.webp +0 -0
- package/components/webc-post-filter-module/dev-content/bluey.webp +0 -0
- package/components/webc-post-filter-module/dev-content/chucky-vanille.webp +0 -0
- package/components/webc-post-filter-module/dev-content/dev-content.js +347 -0
- package/components/webc-post-filter-module/dev-content/dev-contentlocal.js +362 -0
- package/components/webc-post-filter-module/dev-content/fat-gigio-basket-life.webp +0 -0
- package/components/webc-post-filter-module/dev-content/fat-gigio-kitten.webp +0 -0
- package/components/webc-post-filter-module/dev-content/fat-gigio-sleepy.webp +0 -0
- package/components/webc-post-filter-module/dev-content/kai-lounging.webp +0 -0
- package/components/webc-post-filter-module/dev-content/kai-selfie.webp +0 -0
- package/components/webc-post-filter-module/dev-content/kai.webp +0 -0
- package/components/webc-post-filter-module/dev-content/lulu-mad.webp +0 -0
- package/components/webc-post-filter-module/dev-content/lulu-serious.webp +0 -0
- package/components/webc-post-filter-module/dev-content/martha-on-the-mat.webp +0 -0
- package/components/webc-post-filter-module/dev-content/max-on-the-mat.webp +0 -0
- package/components/webc-post-filter-module/dev-content/mephy-dreams-of-mice.webp +0 -0
- package/components/webc-post-filter-module/dev-content/mr-business-doing-work.webp +0 -0
- package/components/webc-post-filter-module/dev-content/mr-business-on-top.webp +0 -0
- package/components/webc-post-filter-module/dev-content/peanut-keeping-an-eye.webp +0 -0
- package/components/webc-post-filter-module/dev-content/pete-at-work.webp +0 -0
- package/components/webc-post-filter-module/dev-content/pete-bath.webp +0 -0
- package/components/webc-post-filter-module/dev-content/pete-dinosaur.webp +0 -0
- package/components/webc-post-filter-module/dev-content/pete-lawn.webp +0 -0
- package/components/webc-post-filter-module/dev-content/pete-snacks.webp +0 -0
- package/components/webc-post-filter-module/dev-content/ramses-kitten.webp +0 -0
- package/components/webc-post-filter-module/dev-content/ramses-school-day.webp +0 -0
- package/components/webc-post-filter-module/dev-content/ramses-tired.webp +0 -0
- package/components/webc-post-filter-module/dev-content/remy-garden-contemplation.webp +0 -0
- package/components/webc-post-filter-module/dev-content/sky-field.webp +0 -0
- package/components/webc-post-filter-module/dev-content/sky-luxury-2.webp +0 -0
- package/components/webc-post-filter-module/dev-content/sky-luxury.webp +0 -0
- package/components/webc-post-filter-module/dev-content/sky-puppy-good-dog.webp +0 -0
- package/components/webc-post-filter-module/dev-content/sky-puppy-pose.webp +0 -0
- package/components/webc-post-filter-module/dev-content/sky-security.webp +0 -0
- package/components/webc-post-filter-module/dev-content/vanille-asleep.webp +0 -0
- package/components/webc-post-filter-module/dev-content/vanille-bass.webp +0 -0
- package/components/webc-post-filter-module/dev-content/vanille-party.webp +0 -0
- package/components/webc-post-filter-module/dev-content/vanille-puppy-eyes.webp +0 -0
- package/components/webc-post-filter-module/dev-content/vanille-puppy.webp +0 -0
- package/components/webc-post-filter-module/index.html +30 -0
- package/components/webc-post-filter-module/post-filter-module.css +59 -0
- package/components/webc-post-filter-module/post-filter-module.html +13 -0
- package/components/webc-post-filter-module/post-filter-module.js +359 -0
- package/components/webc-post-filter-module-no-group/index.html +30 -0
- package/components/webc-post-filter-module-no-group/post-filter-module-no-group.css +59 -0
- package/components/webc-post-filter-module-no-group/post-filter-module-no-group.html +13 -0
- package/components/webc-post-filter-module-no-group/post-filter-module-no-group.js +312 -0
- package/components/webc-post-grid-display-module/index.html +30 -0
- package/components/webc-post-grid-display-module/post-grid-display-module.css +42 -0
- package/components/webc-post-grid-display-module/post-grid-display-module.html +6 -0
- package/components/webc-post-grid-display-module/post-grid-display-module.js +48 -0
- package/components/webc-ptfg-9000/index.html +108 -0
- package/components/webc-ptfg-9000/ptfg-9000.css +14 -0
- package/components/webc-ptfg-9000/ptfg-9000.html +1 -0
- package/components/webc-ptfg-9000/ptfg-9000.js +42 -0
- package/components/webc-responsive-image/index.html +108 -0
- package/components/webc-responsive-image/layout-container.css +9 -0
- package/components/webc-responsive-image/layout-container.js +22 -0
- package/components/webc-responsive-image/responsive-image.html +15 -0
- package/components/webc-slot-test/slot-test.html +25 -0
- package/components/webc-text-input-trigger/index.html +30 -0
- package/components/webc-text-input-trigger/text-input-trigger.css +6 -0
- package/components/webc-text-input-trigger/text-input-trigger.html +4 -0
- package/components/webc-text-input-trigger/text-input-trigger.js +33 -0
- package/components/webc-toggle-trigger/index.html +30 -0
- package/components/webc-toggle-trigger/toggle-trigger.css +13 -0
- package/components/webc-toggle-trigger/toggle-trigger.html +8 -0
- package/components/webc-toggle-trigger/toggle-trigger.js +53 -0
- package/createDynamicBlockScss-v3.js +25 -0
- package/createJsAssets-v3.js +35 -0
- package/createJsAssets.js +31 -0
- package/createNewBlock.js +131 -0
- package/createNewChildBlock2.js +140 -0
- package/createPreviewScss.js +35 -0
- package/datalayer-tools.mjs +2 -0
- package/duplicateBlock.js +123 -0
- package/esbuild.mjs +87 -0
- package/exportAllBlocks.js +147 -0
- package/exportBlock.js +109 -0
- package/exportChildBlock.js +102 -0
- package/exportCustomCachesToLibrary.js +76 -0
- package/exportEntrypointToLibrary.js +79 -0
- package/exportImagesToLibrary.js +68 -0
- package/exportSEOExtrasToLibrary.js +76 -0
- package/exportToLibrary.js +551 -0
- package/importBlock.js +92 -0
- package/importChildBlock.js +76 -0
- package/install-component.js +204 -0
- package/list-components.js +9 -0
- package/new-block-templates/template-acf-pattern.js +30 -0
- package/new-block-templates/template-block-json.js +37 -0
- package/new-block-templates/template-default.js +24 -0
- package/new-block-templates/template-js-blank.js +12 -0
- package/new-block-templates/template-scss-blank.js +6 -0
- package/no-audio.vtt +4 -0
- package/onion-loader-dev.js +260 -0
- package/onion-loader-local.js +222 -0
- package/onion-loader-v2.js +285 -0
- package/onion-loader.js +14 -22
- package/package.json +1 -9
- package/public/.gitkeep +0 -0
- package/public/assetList.mjs +3 -0
- package/public/block-accent-image-v3/accent-image-v3.css +2 -0
- package/public/block-accent-image-v3/accent-image-v3.js +7 -0
- package/public/block-accordion-v3/accordion-v3.css +380 -0
- package/public/block-accordion-v3/accordion-v3.js +117 -0
- package/public/block-back-to-top-button-v3/back-to-top-button-v3.css +64 -0
- package/public/block-back-to-top-button-v3/back-to-top-button-v3.js +12 -0
- package/public/block-betterreviews-display-v3/betterreviews-display-v3.css +95 -0
- package/public/block-betterreviews-display-v3/betterreviews-display-v3.js +7 -0
- package/public/block-block-interactions-v3/block-interactions-v3.css +36 -0
- package/public/block-block-interactions-v3/block-interactions-v3.js +44 -0
- package/public/block-carousel-multi-layout-v3/carousel-multi-layout-v3.css +187 -0
- package/public/block-carousel-multi-layout-v3/carousel-multi-layout-v3.js +185 -0
- package/public/block-cocktail-recipe-v3/cocktail-recipe-v3.css +268 -0
- package/public/block-cocktail-recipe-v3/cocktail-recipe-v3.js +95 -0
- package/public/block-cover-link-v3/cover-link-v3.css +8 -0
- package/public/block-cover-link-v3/cover-link-v3.js +7 -0
- package/public/block-divider-v3/divider-v3.css +74 -0
- package/public/block-divider-v3/divider-v3.js +7 -0
- package/public/block-featured-image-gallery-v3/featured-image-gallery-v3.css +98 -0
- package/public/block-featured-image-gallery-v3/featured-image-gallery-v3.js +44 -0
- package/public/block-form-selection-v3/form-selection-v3.css +31 -0
- package/public/block-form-selection-v3/form-selection-v3.js +61 -0
- package/public/block-gradient-layer-v3/gradient-layer-v3.css +45 -0
- package/public/block-gradient-layer-v3/gradient-layer-v3.js +7 -0
- package/public/block-group-container-v3/group-container-v3.css +303 -0
- package/public/block-group-container-v3/group-container-v3.js +7 -0
- package/public/block-lottie-content-v3/lottie-content-v3.css +0 -0
- package/public/block-lottie-content-v3/lottie-content-v3.js +25 -0
- package/public/block-market-selector-v3/market-selector-v3.css +136 -0
- package/public/block-market-selector-v3/market-selector-v3.js +7 -0
- package/public/block-modal-form-v3/modal-form-v3.css +0 -0
- package/public/block-modal-form-v3/modal-form-v3.js +48 -0
- package/public/block-nav-menu-container-v3/nav-menu-container-v3.css +3 -0
- package/public/block-nav-menu-container-v3/nav-menu-container-v3.js +7 -0
- package/public/block-post-info-v3/post-info-v3.css +1148 -0
- package/public/block-post-info-v3/post-info-v3.js +7 -0
- package/public/block-post-type-filter-grid-v3/post-type-filter-grid-v3.css +873 -0
- package/public/block-post-type-filter-grid-v3/post-type-filter-grid-v3.js +13 -0
- package/public/block-product-info-v3/product-info-v3.css +846 -0
- package/public/block-product-info-v3/product-info-v3.js +7 -0
- package/public/block-raw-html-v3/raw-html-v3.css +0 -0
- package/public/block-raw-html-v3/raw-html-v3.js +7 -0
- package/public/block-responsive-table-v3/responsive-table-v3.css +50 -0
- package/public/block-responsive-table-v3/responsive-table-v3.js +7 -0
- package/public/block-scrolling-banner-v3/scrolling-banner-v3.css +93 -0
- package/public/block-scrolling-banner-v3/scrolling-banner-v3.js +118 -0
- package/public/block-section-separator-v3/section-separator-v3.css +43 -0
- package/public/block-section-separator-v3/section-separator-v3.js +7 -0
- package/public/block-single-column-container-v3/single-column-container-v3.css +14 -0
- package/public/block-single-column-container-v3/single-column-container-v3.js +7 -0
- package/public/block-single-responsive-image-v3/single-responsive-image-v3.css +61 -0
- package/public/block-single-responsive-image-v3/single-responsive-image-v3.js +7 -0
- package/public/block-site-copyright-notice-v3/site-copyright-notice-v3.css +20 -0
- package/public/block-site-copyright-notice-v3/site-copyright-notice-v3.js +44 -0
- package/public/block-site-logo-container-v3/site-logo-container-v3.css +18 -0
- package/public/block-site-logo-container-v3/site-logo-container-v3.js +7 -0
- package/public/block-site-title-and-tagline-v3/site-title-and-tagline-v3.css +12 -0
- package/public/block-site-title-and-tagline-v3/site-title-and-tagline-v3.js +7 -0
- package/public/block-smash-balloon-social-media-v3/smash-balloon-social-media-v3.css +25 -0
- package/public/block-smash-balloon-social-media-v3/smash-balloon-social-media-v3.js +8 -0
- package/public/block-social-networks-v3/social-networks-v3.css +74 -0
- package/public/block-social-networks-v3/social-networks-v3.js +7 -0
- package/public/block-spacer-v3/spacer-v3.css +16 -0
- package/public/block-spacer-v3/spacer-v3.js +2 -0
- package/public/block-spotify-embed-v3/spotify-embed-v3.css +7 -0
- package/public/block-spotify-embed-v3/spotify-embed-v3.js +7 -0
- package/public/block-standard-content-v3/standard-content-v3.css +423 -0
- package/public/block-standard-content-v3/standard-content-v3.js +7 -0
- package/public/block-sticky-buy-cta-v3/sticky-buy-cta-v3.css +0 -0
- package/public/block-sticky-buy-cta-v3/sticky-buy-cta-v3.js +7 -0
- package/public/block-sub-group-container-v3/sub-group-container-v3.css +288 -0
- package/public/block-sub-group-container-v3/sub-group-container-v3.js +2 -0
- package/public/block-video-content-v3/video-content-v3.css +102 -0
- package/public/block-video-content-v3/video-content-v3.js +11 -0
- package/public/dynamicBlockScss-v3.css +6392 -0
- package/public/dynamicBlockScss-v3.scss +37 -0
- package/public/jsAssets.mjs +4 -0
- package/public/publicBundleBase.css +4742 -0
- package/public/publicBundleBase.scss +11 -0
- package/removeBlock.js +124 -0
- package/update-all-components.js +96 -0
- package/update-component.js +538 -0
- package/update-template.js +538 -0
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import fse from 'fs-extra';
|
|
4
|
+
import {globSync} from 'glob';
|
|
5
|
+
import yargs from 'yargs/yargs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import {fileURLToPath} from 'node:url';
|
|
8
|
+
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const templateOptions = yargs(process.argv.slice(2)).argv._;
|
|
11
|
+
const themePath =
|
|
12
|
+
process.env.THEME_PATH || 'web/wp-content/themes/global-theme';
|
|
13
|
+
|
|
14
|
+
// paths for blocks
|
|
15
|
+
const srcPathJsBlock = `${themePath}/assets/js/blocks/`;
|
|
16
|
+
const srcPathScssBlock = `${themePath}/assets/scss/blocks/`;
|
|
17
|
+
const srcPathTwigBlock = `${themePath}/views/blocks/`;
|
|
18
|
+
const srcPathPhpBlock = `${themePath}/inc/acf-blocks/`;
|
|
19
|
+
const srcPathVueBlock = `${themePath}/assets/vue/blocks/`;
|
|
20
|
+
|
|
21
|
+
// paths for components
|
|
22
|
+
const srcPathJsComponent = `${themePath}/assets/js/modules/library-modules`;
|
|
23
|
+
const srcPathScssComponent = `${themePath}/assets/scss/modules/library-modules`;
|
|
24
|
+
const srcPathTwigComponent = `${themePath}/views/components`;
|
|
25
|
+
|
|
26
|
+
// paths for fields
|
|
27
|
+
const srcPathJsFields = `${themePath}/assets/js/modules/library-modules`;
|
|
28
|
+
const srcPathScssFields = `${themePath}/assets/scss/modules/library-modules`;
|
|
29
|
+
const srcPathPhpFields = `${themePath}/inc/custom-extras`;
|
|
30
|
+
const srcPathTwigFields = `${themePath}/views/components`;
|
|
31
|
+
|
|
32
|
+
// paths for controller
|
|
33
|
+
const srcPathCssController = `${themePath}/assets/css/`;
|
|
34
|
+
const srcPathTwigController = `${themePath}/views/components/`;
|
|
35
|
+
const srcPathPhpController = `${themePath}/controller/`;
|
|
36
|
+
|
|
37
|
+
// path for security files
|
|
38
|
+
const srcPathPhpSecurity = `${themePath}/inc/security-extras`;
|
|
39
|
+
|
|
40
|
+
// path for seopress files
|
|
41
|
+
const srcPathPhpSeopress = `${themePath}/inc/seo-extras`;
|
|
42
|
+
|
|
43
|
+
const destPath = path.join(
|
|
44
|
+
__dirname,
|
|
45
|
+
'../../../../../../../../onion-library/components/'
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const bColors = {
|
|
49
|
+
HEADER: '\u001b[95m',
|
|
50
|
+
OKBLUE: '\u001b[94m',
|
|
51
|
+
OKGREEN: '\u001b[92m',
|
|
52
|
+
WARNING: '\u001b[93m',
|
|
53
|
+
FAIL: '\u001b[91m',
|
|
54
|
+
ENDC: '\u001b[0m',
|
|
55
|
+
BOLD: '\u001b[1m',
|
|
56
|
+
UNDERLINE: '\u001b[4m',
|
|
57
|
+
ORANGE: '\u001b[93m',
|
|
58
|
+
MAGENTA: '\u001b[95m',
|
|
59
|
+
CYAN: '\u001b[96m'
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const icons = {
|
|
63
|
+
SMILE: '\uD83D\uDE00',
|
|
64
|
+
BEER_MUG: '\uD83C\uDF7A',
|
|
65
|
+
BEER_CHEERS: '\uD83C\uDF7B',
|
|
66
|
+
CROWN: '\uD83D\uDC51',
|
|
67
|
+
CLAP_HANDS: '\uD83D\uDC4F',
|
|
68
|
+
CROSS_MARK: '\u274C'
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
if (!fs.existsSync(`${destPath}`)) {
|
|
72
|
+
console.error('❌ Please check the library component path.');
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
templateOptions.forEach((componentName) => {
|
|
77
|
+
let componentType = '';
|
|
78
|
+
let component = '';
|
|
79
|
+
|
|
80
|
+
if (componentName.startsWith('block-')) {
|
|
81
|
+
componentType = 'block';
|
|
82
|
+
component = componentName.substring(6);
|
|
83
|
+
} else if (componentName.startsWith('component-')) {
|
|
84
|
+
componentType = 'component';
|
|
85
|
+
component = componentName.substring(10);
|
|
86
|
+
} else if (componentName.startsWith('fields-')) {
|
|
87
|
+
componentType = 'fields';
|
|
88
|
+
component = componentName.substring(7);
|
|
89
|
+
} else if (componentName.startsWith('controller-')) {
|
|
90
|
+
componentType = 'controller';
|
|
91
|
+
component = componentName.substring(11);
|
|
92
|
+
} else if (componentName.startsWith('security-')) {
|
|
93
|
+
componentType = 'security';
|
|
94
|
+
component = componentName.substring(9);
|
|
95
|
+
} else if (componentName.startsWith('seopress-')) {
|
|
96
|
+
componentType = 'seopress';
|
|
97
|
+
component = componentName.substring(9);
|
|
98
|
+
} else {
|
|
99
|
+
console.error(
|
|
100
|
+
`${bColors.FAIL}Invalid component type. Use block-, component- or fields- prefixes.${bColors.ENDC}`
|
|
101
|
+
);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
let isValid = validateComponentExists(component, componentType);
|
|
106
|
+
if (!isValid) {
|
|
107
|
+
console.log(
|
|
108
|
+
`${bColors.OKBLUE}${componentName} : ${bColors.FAIL}[INVALID] Component does not exist${bColors.ENDC}`
|
|
109
|
+
);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let success = 0;
|
|
114
|
+
if (componentType === 'block') {
|
|
115
|
+
success = copyBlockContent(`${destPath}block-${component}/`, component);
|
|
116
|
+
} else if (componentType === 'component') {
|
|
117
|
+
success = copyComponentContent(
|
|
118
|
+
`${destPath}component-${component}/`,
|
|
119
|
+
component
|
|
120
|
+
);
|
|
121
|
+
} else if (componentType === 'fields') {
|
|
122
|
+
success = copyFieldsContent(
|
|
123
|
+
`${destPath}fields-${component}/`,
|
|
124
|
+
component
|
|
125
|
+
);
|
|
126
|
+
} else if (componentType === 'controller') {
|
|
127
|
+
success = copyControllerContent(
|
|
128
|
+
`${destPath}controller-${component}/`,
|
|
129
|
+
component
|
|
130
|
+
);
|
|
131
|
+
} else if (componentType === 'security') {
|
|
132
|
+
success = copySecurityContent(
|
|
133
|
+
`${destPath}security-${component}/`,
|
|
134
|
+
component
|
|
135
|
+
);
|
|
136
|
+
} else if (componentType === 'seopress') {
|
|
137
|
+
success = copySeopressContent(
|
|
138
|
+
`${destPath}seopress-${component}/`,
|
|
139
|
+
component
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (success === 1) {
|
|
144
|
+
console.log(
|
|
145
|
+
`${bColors.OKBLUE}${componentName} : ${bColors.OKGREEN}[OK]${bColors.ENDC}`
|
|
146
|
+
);
|
|
147
|
+
console.log(
|
|
148
|
+
`${bColors.CYAN}` + '---------------------------------------'
|
|
149
|
+
);
|
|
150
|
+
console.log(
|
|
151
|
+
'\x1b[32m',
|
|
152
|
+
`👑 👑 👑 Hurrah!${icons.BEER_CHEERS} You successfully exported all blocks to Library 👑 👑 👑`
|
|
153
|
+
);
|
|
154
|
+
} else {
|
|
155
|
+
console.log(
|
|
156
|
+
`${bColors.OKBLUE}${componentName} : ${bColors.FAIL}[PARTIAL/FAIL]${bColors.ENDC}`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
function validateComponentExists(component, type) {
|
|
162
|
+
let exists = false;
|
|
163
|
+
if (type === 'block') {
|
|
164
|
+
exists =
|
|
165
|
+
fs.existsSync(`${srcPathJsBlock}${component}.js`) ||
|
|
166
|
+
fs.existsSync(`${srcPathScssBlock}${component}.scss`) ||
|
|
167
|
+
fs.existsSync(`${srcPathTwigBlock}${component}.twig`) ||
|
|
168
|
+
fs.existsSync(`${srcPathPhpBlock}${component}.php`) ||
|
|
169
|
+
fs.existsSync(`${srcPathVueBlock}${component}`) ||
|
|
170
|
+
fs.existsSync(`${srcPathVueBlock}${component}.vue`);
|
|
171
|
+
} else if (type === 'component') {
|
|
172
|
+
exists =
|
|
173
|
+
fs.existsSync(`${srcPathTwigComponent}/${component}.twig`) ||
|
|
174
|
+
fs.existsSync(
|
|
175
|
+
`${srcPathScssComponent}/${component}/${component}.scss`
|
|
176
|
+
) ||
|
|
177
|
+
fs.existsSync(`${srcPathJsComponent}/${component}/${component}.js`);
|
|
178
|
+
} else if (type === 'fields') {
|
|
179
|
+
exists =
|
|
180
|
+
fs.existsSync(`${srcPathPhpFields}/${component}.php`) ||
|
|
181
|
+
fs.existsSync(`${srcPathJsFields}/${component}/${component}.js`) ||
|
|
182
|
+
fs.existsSync(`${srcPathTwigFields}/${component}.twig`) ||
|
|
183
|
+
fs.existsSync(
|
|
184
|
+
`${srcPathScssFields}/${component}/${component}.scss`
|
|
185
|
+
);
|
|
186
|
+
} else if (type === 'controller') {
|
|
187
|
+
exists =
|
|
188
|
+
fs.existsSync(`${srcPathCssController}${component}.css`) ||
|
|
189
|
+
fs.existsSync(`${srcPathPhpController}${component}.php`) ||
|
|
190
|
+
fs.existsSync(`${srcPathTwigController}${component}.twig`);
|
|
191
|
+
} else if (type === 'security') {
|
|
192
|
+
exists = fs.existsSync(`${srcPathPhpSecurity}/${component}.php`);
|
|
193
|
+
} else if (type === 'seopress') {
|
|
194
|
+
exists = fs.existsSync(`${srcPathPhpSeopress}/${component}.php`);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const acfJsonFiles = globSync(`${themePath}/acf-json/*.json`);
|
|
198
|
+
const acfJsonExists = acfJsonFiles.some((file) => {
|
|
199
|
+
let rawdata = fs.readFileSync(file);
|
|
200
|
+
let blockData = JSON.parse(rawdata);
|
|
201
|
+
const title = blockData.title
|
|
202
|
+
.replace(/(Block: |Component: |Fields: |Options: )/, '')
|
|
203
|
+
.replace(' - Library', '')
|
|
204
|
+
.replaceAll(' ', '-')
|
|
205
|
+
.toLowerCase();
|
|
206
|
+
return title === component;
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
return exists || acfJsonExists;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function copyBlockContent(destDir, blockName) {
|
|
213
|
+
let SUCCESS = 0;
|
|
214
|
+
if (fs.existsSync(destDir)) {
|
|
215
|
+
fs.rmSync(destDir, {recursive: true, force: true});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (!fs.existsSync(destDir)) {
|
|
219
|
+
try {
|
|
220
|
+
fs.mkdirSync(destDir);
|
|
221
|
+
if (fs.existsSync(`${srcPathJsBlock}${blockName}.js`)) {
|
|
222
|
+
fs.copyFileSync(
|
|
223
|
+
`${srcPathJsBlock}${blockName}.js`,
|
|
224
|
+
`${destDir}${blockName}.js`
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
const extraJsPath = `${srcPathJsBlock}/${blockName}/${blockName}-extra.js`;
|
|
228
|
+
if (fs.existsSync(extraJsPath)) {
|
|
229
|
+
fs.copyFileSync(
|
|
230
|
+
extraJsPath,
|
|
231
|
+
`${destDir}${blockName}-extra.js`
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (fs.existsSync(`${srcPathScssBlock}${blockName}.scss`)) {
|
|
236
|
+
fs.copyFileSync(
|
|
237
|
+
`${srcPathScssBlock}${blockName}.scss`,
|
|
238
|
+
`${destDir}${blockName}.scss`
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
if (
|
|
242
|
+
fs.existsSync(
|
|
243
|
+
`${srcPathScssBlock}${blockName}/${blockName}-extra.scss`
|
|
244
|
+
)
|
|
245
|
+
) {
|
|
246
|
+
fs.copyFileSync(
|
|
247
|
+
`${srcPathScssBlock}${blockName}/${blockName}-extra.scss`,
|
|
248
|
+
`${destDir}${blockName}-extra.scss`
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
if (fs.existsSync(`${srcPathTwigBlock}${blockName}.twig`)) {
|
|
252
|
+
fs.copyFileSync(
|
|
253
|
+
`${srcPathTwigBlock}${blockName}.twig`,
|
|
254
|
+
`${destDir}${blockName}.twig`
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const blockSubfolderDir = `${srcPathTwigBlock}${blockName}`;
|
|
259
|
+
const destBlockSubfolderDir = `${destDir}${blockName}`;
|
|
260
|
+
|
|
261
|
+
if (
|
|
262
|
+
fs.existsSync(blockSubfolderDir) &&
|
|
263
|
+
fs.statSync(blockSubfolderDir).isDirectory()
|
|
264
|
+
) {
|
|
265
|
+
if (!fs.existsSync(destBlockSubfolderDir)) {
|
|
266
|
+
fs.mkdirSync(destBlockSubfolderDir);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const blockSubfolderFiles = globSync(`${blockSubfolderDir}/*`);
|
|
270
|
+
blockSubfolderFiles.forEach((file) => {
|
|
271
|
+
const fileName = path.basename(file);
|
|
272
|
+
fs.copyFileSync(
|
|
273
|
+
file,
|
|
274
|
+
path.join(destBlockSubfolderDir, fileName)
|
|
275
|
+
);
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
if (fs.existsSync(`${srcPathPhpBlock}${blockName}.php`)) {
|
|
279
|
+
fs.copyFileSync(
|
|
280
|
+
`${srcPathPhpBlock}${blockName}.php`,
|
|
281
|
+
`${destDir}${blockName}.php`
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
if (
|
|
285
|
+
fs.existsSync(`${srcPathVueBlock}${blockName}`) &&
|
|
286
|
+
fs.statSync(`${srcPathVueBlock}${blockName}`).isDirectory()
|
|
287
|
+
) {
|
|
288
|
+
fse.copySync(
|
|
289
|
+
`${srcPathVueBlock}${blockName}`,
|
|
290
|
+
`${destDir}${blockName}`
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
if (fs.existsSync(`${srcPathVueBlock}${blockName}.vue`)) {
|
|
294
|
+
fs.copyFileSync(
|
|
295
|
+
`${srcPathVueBlock}${blockName}.vue`,
|
|
296
|
+
`${destDir}${blockName}.vue`
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
copyBlockJson(blockName, 'block');
|
|
300
|
+
|
|
301
|
+
SUCCESS = 1;
|
|
302
|
+
} catch (e) {
|
|
303
|
+
SUCCESS = 0;
|
|
304
|
+
return SUCCESS;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return SUCCESS;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function copyComponentContent(destDir, componentName) {
|
|
312
|
+
let SUCCESS = 0;
|
|
313
|
+
if (fs.existsSync(destDir)) {
|
|
314
|
+
fs.rmSync(destDir, {recursive: true, force: true});
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (!fs.existsSync(destDir)) {
|
|
318
|
+
try {
|
|
319
|
+
fs.mkdirSync(destDir);
|
|
320
|
+
|
|
321
|
+
if (
|
|
322
|
+
fs.existsSync(`${srcPathTwigComponent}/${componentName}.twig`)
|
|
323
|
+
) {
|
|
324
|
+
fs.copyFileSync(
|
|
325
|
+
`${srcPathTwigComponent}/${componentName}.twig`,
|
|
326
|
+
`${destDir}${componentName}.twig`
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (
|
|
331
|
+
fs.existsSync(
|
|
332
|
+
`${srcPathScssComponent}/${componentName}/${componentName}.scss`
|
|
333
|
+
)
|
|
334
|
+
) {
|
|
335
|
+
fs.copyFileSync(
|
|
336
|
+
`${srcPathScssComponent}/${componentName}/${componentName}.scss`,
|
|
337
|
+
`${destDir}${componentName}.scss`
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
// Check and copy the -extra.scss file if it exists
|
|
341
|
+
const extraScssPath = `${srcPathScssComponent}/${componentName}/${componentName}-extra.scss`;
|
|
342
|
+
if (fs.existsSync(extraScssPath)) {
|
|
343
|
+
fs.copyFileSync(
|
|
344
|
+
extraScssPath,
|
|
345
|
+
`${destDir}${componentName}-extra.scss`
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (
|
|
351
|
+
fs.existsSync(
|
|
352
|
+
`${srcPathJsComponent}/${componentName}/${componentName}.js`
|
|
353
|
+
)
|
|
354
|
+
) {
|
|
355
|
+
fs.copyFileSync(
|
|
356
|
+
`${srcPathJsComponent}/${componentName}/${componentName}.js`,
|
|
357
|
+
`${destDir}${componentName}.js`
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
copyBlockJson(componentName, 'component');
|
|
362
|
+
SUCCESS = 1;
|
|
363
|
+
} catch (e) {
|
|
364
|
+
SUCCESS = 0;
|
|
365
|
+
return SUCCESS;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return SUCCESS;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function copyFieldsContent(destDir, fieldsName) {
|
|
373
|
+
let SUCCESS = 0;
|
|
374
|
+
if (fs.existsSync(destDir)) {
|
|
375
|
+
fs.rmSync(destDir, {recursive: true, force: true});
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (!fs.existsSync(destDir)) {
|
|
379
|
+
try {
|
|
380
|
+
fs.mkdirSync(destDir);
|
|
381
|
+
|
|
382
|
+
if (
|
|
383
|
+
fs.existsSync(
|
|
384
|
+
`${srcPathJsFields}/${fieldsName}/${fieldsName}.js`
|
|
385
|
+
)
|
|
386
|
+
) {
|
|
387
|
+
fs.copyFileSync(
|
|
388
|
+
`${srcPathJsFields}/${fieldsName}/${fieldsName}.js`,
|
|
389
|
+
`${destDir}${fieldsName}.js`
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (fs.existsSync(`${srcPathPhpFields}/${fieldsName}.php`)) {
|
|
394
|
+
fs.copyFileSync(
|
|
395
|
+
`${srcPathPhpFields}/${fieldsName}.php`,
|
|
396
|
+
`${destDir}${fieldsName}.php`
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
if (fs.existsSync(`${srcPathTwigFields}/${fieldsName}.twig`)) {
|
|
401
|
+
fs.copyFileSync(
|
|
402
|
+
`${srcPathTwigFields}/${fieldsName}.twig`,
|
|
403
|
+
`${destDir}${fieldsName}.twig`
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (
|
|
408
|
+
fs.existsSync(
|
|
409
|
+
`${srcPathScssFields}/${fieldsName}/${fieldsName}.scss`
|
|
410
|
+
)
|
|
411
|
+
) {
|
|
412
|
+
fs.copyFileSync(
|
|
413
|
+
`${srcPathScssFields}/${fieldsName}/${fieldsName}.scss`,
|
|
414
|
+
`${destDir}${fieldsName}.scss`
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
copyBlockJson(fieldsName, 'fields');
|
|
419
|
+
SUCCESS = 1;
|
|
420
|
+
} catch (e) {
|
|
421
|
+
SUCCESS = 0;
|
|
422
|
+
return SUCCESS;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
return SUCCESS;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function copyControllerContent(destDir, controllerName) {
|
|
430
|
+
let SUCCESS = 0;
|
|
431
|
+
if (fs.existsSync(destDir)) {
|
|
432
|
+
fs.rmSync(destDir, {recursive: true, force: true});
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
if (!fs.existsSync(destDir)) {
|
|
436
|
+
try {
|
|
437
|
+
fs.mkdirSync(destDir);
|
|
438
|
+
|
|
439
|
+
if (fs.existsSync(`${srcPathCssController}${controllerName}.css`)) {
|
|
440
|
+
fs.copyFileSync(
|
|
441
|
+
`${srcPathCssController}${controllerName}.css`,
|
|
442
|
+
`${destDir}${controllerName}.css`
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
if (fs.existsSync(`${srcPathPhpController}${controllerName}.php`)) {
|
|
447
|
+
fs.copyFileSync(
|
|
448
|
+
`${srcPathPhpController}${controllerName}.php`,
|
|
449
|
+
`${destDir}${controllerName}.php`
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if (
|
|
454
|
+
fs.existsSync(`${srcPathTwigController}${controllerName}.twig`)
|
|
455
|
+
) {
|
|
456
|
+
fs.copyFileSync(
|
|
457
|
+
`${srcPathTwigController}${controllerName}.twig`,
|
|
458
|
+
`${destDir}${controllerName}.twig`
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
SUCCESS = 1;
|
|
463
|
+
} catch (e) {
|
|
464
|
+
console.error(e);
|
|
465
|
+
SUCCESS = 0;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
return SUCCESS;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function copySecurityContent(destDir, securityName) {
|
|
473
|
+
let SUCCESS = 0;
|
|
474
|
+
if (fs.existsSync(destDir)) {
|
|
475
|
+
fs.rmSync(destDir, {recursive: true, force: true});
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
if (!fs.existsSync(destDir)) {
|
|
479
|
+
try {
|
|
480
|
+
fs.mkdirSync(destDir);
|
|
481
|
+
|
|
482
|
+
if (fs.existsSync(`${srcPathPhpSecurity}/${securityName}.php`)) {
|
|
483
|
+
fs.copyFileSync(
|
|
484
|
+
`${srcPathPhpSecurity}/${securityName}.php`,
|
|
485
|
+
`${destDir}${securityName}.php`
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
SUCCESS = 1;
|
|
490
|
+
} catch (e) {
|
|
491
|
+
console.error(e);
|
|
492
|
+
SUCCESS = 0;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return SUCCESS;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function copySeopressContent(destDir, seopressName) {
|
|
500
|
+
let SUCCESS = 0;
|
|
501
|
+
if (fs.existsSync(destDir)) {
|
|
502
|
+
fs.rmSync(destDir, {recursive: true, force: true});
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
if (!fs.existsSync(destDir)) {
|
|
506
|
+
try {
|
|
507
|
+
fs.mkdirSync(destDir);
|
|
508
|
+
|
|
509
|
+
if (fs.existsSync(`${srcPathPhpSeopress}/${seopressName}.php`)) {
|
|
510
|
+
fs.copyFileSync(
|
|
511
|
+
`${srcPathPhpSeopress}/${seopressName}.php`,
|
|
512
|
+
`${destDir}${seopressName}.php`
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
SUCCESS = 1;
|
|
517
|
+
} catch (e) {
|
|
518
|
+
console.error(e);
|
|
519
|
+
SUCCESS = 0;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
return SUCCESS;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function copyBlockJson(name, type) {
|
|
527
|
+
const existingAcfFiles = globSync(`${themePath}/acf-json/*.json`);
|
|
528
|
+
|
|
529
|
+
const typeMapping = {
|
|
530
|
+
block: ['Block: '],
|
|
531
|
+
component: ['Component: '],
|
|
532
|
+
fields: ['Fields: ', 'Options: ']
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
existingAcfFiles.forEach((file) => {
|
|
536
|
+
let rawdata = fs.readFileSync(file);
|
|
537
|
+
let blockData = JSON.parse(rawdata);
|
|
538
|
+
const title = (typeMapping[type] || [])
|
|
539
|
+
.reduce((acc, replaceValue) => {
|
|
540
|
+
return acc.replace(replaceValue, '');
|
|
541
|
+
}, blockData.title)
|
|
542
|
+
.replace(' - Library', '')
|
|
543
|
+
.replaceAll(' ', '-')
|
|
544
|
+
.toLowerCase();
|
|
545
|
+
|
|
546
|
+
if (title === name) {
|
|
547
|
+
const fileName = path.basename(file);
|
|
548
|
+
fs.copyFileSync(file, `${destPath}${type}-${name}/${fileName}`);
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
}
|
package/importBlock.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import {globSync} from 'glob';
|
|
4
|
+
import yargs from 'yargs/yargs';
|
|
5
|
+
import compressing from 'compressing';
|
|
6
|
+
const templateOptions = yargs(process.argv.slice(2)).argv._;
|
|
7
|
+
const blockName = templateOptions[0];
|
|
8
|
+
const exportedFolder = '../../../../exported-blocks';
|
|
9
|
+
const themePath =
|
|
10
|
+
process.env.THEME_PATH || 'web/wp-content/themes/global-theme';
|
|
11
|
+
|
|
12
|
+
const existingBlocks = globSync(`${themePath}/assets/js/blocks/*.js`).map(
|
|
13
|
+
(path) => {
|
|
14
|
+
const assetKey = path
|
|
15
|
+
.replace('assets/js/blocks/', '')
|
|
16
|
+
.replace('.js', '');
|
|
17
|
+
return assetKey;
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const handleError = (err) => console.error(err);
|
|
22
|
+
|
|
23
|
+
const decompressDone = () => {
|
|
24
|
+
const dirs = {
|
|
25
|
+
js: `${themePath}/assets/js/blocks`,
|
|
26
|
+
scss: `${themePath}/assets/scss/blocks`,
|
|
27
|
+
twig: `${themePath}/views/blocks`,
|
|
28
|
+
php: `${themePath}/inc/acf-blocks`,
|
|
29
|
+
json: `${themePath}/acf-json`,
|
|
30
|
+
vue: `${themePath}/assets/vue/blocks`
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
for (const [key, dir] of Object.entries(dirs)) {
|
|
34
|
+
if (key === 'json') {
|
|
35
|
+
const files = fs.readdirSync(`${exportedFolder}/${blockName}`);
|
|
36
|
+
const jsonFile = files.filter((file) => {
|
|
37
|
+
if (file.search(/(.json)+/) !== -1) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
});
|
|
42
|
+
if (!fs.existsSync(`${dir}/${jsonFile}`)) {
|
|
43
|
+
console.log(`copying - ${jsonFile}`);
|
|
44
|
+
fs.copyFileSync(
|
|
45
|
+
`${exportedFolder}/${blockName}/${jsonFile}`,
|
|
46
|
+
`${dir}/${jsonFile}`
|
|
47
|
+
);
|
|
48
|
+
} else {
|
|
49
|
+
console.log(
|
|
50
|
+
`Did not copy ${jsonFile} as there was already a json file with that name.`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (!fs.existsSync(`${dir}/${blockName}.${key}`)) {
|
|
55
|
+
if (
|
|
56
|
+
fs.existsSync(
|
|
57
|
+
`${exportedFolder}/${blockName}/${blockName}.${key}`
|
|
58
|
+
)
|
|
59
|
+
) {
|
|
60
|
+
console.log(`copying - ${blockName}.${key}`);
|
|
61
|
+
fs.copyFileSync(
|
|
62
|
+
`${exportedFolder}/${blockName}/${blockName}.${key}`,
|
|
63
|
+
`${dir}/${blockName}.${key}`
|
|
64
|
+
);
|
|
65
|
+
} else {
|
|
66
|
+
console.log('no source file to copy');
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
console.log(
|
|
70
|
+
`Did not copy ${blockName}.${key} as there was already a file with that name.`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
fs.rmdirSync(`${exportedFolder}/${blockName}`, {recursive: true});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
if (!existingBlocks.includes(blockName)) {
|
|
78
|
+
if (!blockName) {
|
|
79
|
+
console.log('Aborting because of bad name!');
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
if (!fs.existsSync(`${exportedFolder}/${blockName}.zip`)) {
|
|
83
|
+
console.log('Aborting as could not find the zip file');
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
compressing.zip
|
|
87
|
+
.uncompress(`${exportedFolder}/${blockName}.zip`, `${exportedFolder}/`)
|
|
88
|
+
.then(decompressDone)
|
|
89
|
+
.catch(handleError);
|
|
90
|
+
} else {
|
|
91
|
+
console.log('Aborting as this block was already listed');
|
|
92
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import {globSync} from 'glob';
|
|
4
|
+
import yargs from 'yargs/yargs';
|
|
5
|
+
import compressing from 'compressing';
|
|
6
|
+
const templateOptions = yargs(process.argv.slice(2)).argv._;
|
|
7
|
+
const blockName = templateOptions[0];
|
|
8
|
+
const exportedFolder = '../../../../exported-blocks';
|
|
9
|
+
const themePath =
|
|
10
|
+
process.env.THEME_PATH || 'web/wp-content/themes/global-theme';
|
|
11
|
+
|
|
12
|
+
const existingBlocks = globSync(`${themePath}/assets/js/blocks/*.js`).map(
|
|
13
|
+
(path) => {
|
|
14
|
+
const assetKey = path
|
|
15
|
+
.replace('assets/js/blocks/', '')
|
|
16
|
+
.replace('.js', '');
|
|
17
|
+
return assetKey;
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const handleError = (err) => console.error(err);
|
|
22
|
+
|
|
23
|
+
const decompressDone = () => {
|
|
24
|
+
const dirs = {
|
|
25
|
+
// js: `${themePath}/assets/js/blocks`,
|
|
26
|
+
// scss: `${themePath}/assets/scss/blocks`,
|
|
27
|
+
twig: `${themePath}/views/blocks`,
|
|
28
|
+
php: `${themePath}/inc/acf-blocks`,
|
|
29
|
+
json: `${themePath}/acf-json`
|
|
30
|
+
// vue: `${themePath}/assets/vue/blocks`
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
for (const [key, dir] of Object.entries(dirs)) {
|
|
34
|
+
if (key === 'json') {
|
|
35
|
+
const files = fs.readdirSync(`${exportedFolder}/${blockName}`);
|
|
36
|
+
const jsonFile = files.filter((file) => {
|
|
37
|
+
if (file.search(/(.json)+/) !== -1) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
console.log(`copying - ${jsonFile}`);
|
|
44
|
+
fs.copyFileSync(
|
|
45
|
+
`${exportedFolder}/${blockName}/${jsonFile}`,
|
|
46
|
+
`${dir}/${jsonFile}`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (
|
|
51
|
+
fs.existsSync(`${exportedFolder}/${blockName}/${blockName}.${key}`)
|
|
52
|
+
) {
|
|
53
|
+
console.log(`copying - ${blockName}.${key}`);
|
|
54
|
+
fs.copyFileSync(
|
|
55
|
+
`${exportedFolder}/${blockName}/${blockName}.${key}`,
|
|
56
|
+
`${dir}/${blockName}.${key}`
|
|
57
|
+
);
|
|
58
|
+
} else {
|
|
59
|
+
console.log('no source file to copy');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
fs.rmdirSync(`${exportedFolder}/${blockName}`, {recursive: true});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
if (!blockName) {
|
|
66
|
+
console.log('Aborting because of bad name!');
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
if (!fs.existsSync(`${exportedFolder}/${blockName}.zip`)) {
|
|
70
|
+
console.log('Aborting as could not find the zip file');
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
compressing.zip
|
|
74
|
+
.uncompress(`${exportedFolder}/${blockName}.zip`, `${exportedFolder}/`)
|
|
75
|
+
.then(decompressDone)
|
|
76
|
+
.catch(handleError);
|