@total_onion/onion-library 3.0.33 → 3.0.35

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/duplicateBlock.js CHANGED
@@ -3,7 +3,6 @@ const fs = require('fs');
3
3
  const path = require('path');
4
4
  const {globSync} = require('glob');
5
5
  const yargs = require('yargs');
6
- const compressing = require('compressing');
7
6
  const templateOptions = yargs.argv._;
8
7
  const themePath =
9
8
  process.env.THEME_PATH || 'web/wp-content/themes/global-theme';
@@ -11,10 +10,6 @@ const srcPathJs = `${themePath}/assets/js/blocks`;
11
10
  const srcPathScss = `${themePath}/assets/scss/blocks`;
12
11
  const srcPathTwig = `${themePath}/views/blocks`;
13
12
  const srcPathBlockJson = `${themePath}/inc/acf-blocks`;
14
- // exported-blocks lives at the project root, relative to cwd (the theme dir)
15
- const destPath =
16
- process.env.EXPORTED_BLOCKS_PATH ||
17
- path.resolve(process.cwd(), '../../../../exported-blocks');
18
13
  const newName = templateOptions[1];
19
14
 
20
15
  const exisitingBlockNames = [
@@ -49,13 +44,6 @@ if (blockName === newName) {
49
44
  }
50
45
 
51
46
  if (exisitingBlockNames.includes(blockName)) {
52
- const dir = `${destPath}/${newName}`;
53
- if (fs.existsSync(dir)) {
54
- console.log('Removing previous duplication...');
55
- fs.rmSync(dir, {recursive: true, force: true});
56
- console.log('removed');
57
- }
58
- fs.mkdirSync(dir);
59
47
  if (fs.existsSync(`${srcPathJs}/${blockName}.js`)) {
60
48
  const contents = fs.readFileSync(
61
49
  `${srcPathJs}/${blockName}.js`,
@@ -71,7 +59,7 @@ if (exisitingBlockNames.includes(blockName)) {
71
59
  `${newName.toLowerCase().replaceAll(/( |-)/g, '')}`
72
60
  )
73
61
  .replaceAll(`blocks/${blockName}`, `blocks/${newName}`);
74
- fs.writeFileSync(`${dir}/${newName}.js`, replaced, 'utf-8');
62
+ fs.writeFileSync(`${srcPathJs}/${newName}.js`, replaced, 'utf-8');
75
63
  console.log(`👑👑\x1b[32m Successfully duplicated the js file! 👑👑`);
76
64
  }
77
65
  if (fs.existsSync(`${srcPathScss}/${blockName}.scss`)) {
@@ -80,19 +68,31 @@ if (exisitingBlockNames.includes(blockName)) {
80
68
  'utf-8'
81
69
  );
82
70
  const replaced = contents.replaceAll(`${blockName}`, `${newName}`);
83
- fs.writeFileSync(`${dir}/${newName}.scss`, replaced, 'utf-8');
71
+ fs.writeFileSync(`${srcPathScss}/${newName}.scss`, replaced, 'utf-8');
84
72
  console.log(`👑👑\x1b[32m Successfully duplicated the scss file! 👑👑`);
85
73
  }
74
+ if (fs.existsSync(`${srcPathScss}/${blockName}-inline.scss`)) {
75
+ const contents = fs.readFileSync(
76
+ `${srcPathScss}/${blockName}-inline.scss`,
77
+ 'utf-8'
78
+ );
79
+ const replaced = contents.replaceAll(`${blockName}`, `${newName}`);
80
+ fs.writeFileSync(
81
+ `${srcPathScss}/${newName}-inline.scss`,
82
+ replaced,
83
+ 'utf-8'
84
+ );
85
+ console.log(
86
+ `👑👑\x1b[32m Successfully duplicated the inline scss file! 👑👑`
87
+ );
88
+ }
86
89
  if (fs.existsSync(`${srcPathTwig}/${blockName}.twig`)) {
87
90
  const contents = fs.readFileSync(
88
91
  `${srcPathTwig}/${blockName}.twig`,
89
92
  'utf-8'
90
93
  );
91
- const regEx = RegExp(String.raw`(\"${blockName}) `, 'gi');
92
- const replaced = contents.replaceAll(regEx, `"${newName} `);
93
- const regEx2 = RegExp(String.raw`([\"|\']${blockName}[\"|\'])`, 'gi');
94
- const replaced2 = replaced.replaceAll(regEx2, `"${newName}"`);
95
- fs.writeFileSync(`${dir}/${newName}.twig`, replaced2, 'utf-8');
94
+ const replaced = contents.replaceAll(blockName, newName);
95
+ fs.writeFileSync(`${srcPathTwig}/${newName}.twig`, replaced, 'utf-8');
96
96
  console.log(`👑👑\x1b[32m Successfully duplicated the twig file! 👑👑`);
97
97
  }
98
98
  if (fs.existsSync(`${srcPathBlockJson}/${blockName}/block.json`)) {
@@ -109,8 +109,9 @@ if (exisitingBlockNames.includes(blockName)) {
109
109
  if (data.description) {
110
110
  data.description = data.description.replaceAll(blockName, newName);
111
111
  }
112
+ fs.mkdirSync(`${srcPathBlockJson}/${newName}`, {recursive: true});
112
113
  fs.writeFileSync(
113
- `${dir}/block.json`,
114
+ `${srcPathBlockJson}/${newName}/block.json`,
114
115
  JSON.stringify(data, null, '\t'),
115
116
  'utf-8'
116
117
  );
@@ -118,11 +119,5 @@ if (exisitingBlockNames.includes(blockName)) {
118
119
  `👑👑\x1b[32m Successfully duplicated the block.json file! 👑👑`
119
120
  );
120
121
  }
121
- compressing.zip
122
- .compressDir(`${dir}`, `${dir}.zip`)
123
- .then(() => {
124
- fs.rmSync(`${destPath}/${newName}`, {recursive: true});
125
- console.log(`\x1b[32m 🎉 Zip created at ${dir}.zip \x1b[0m`);
126
- })
127
- .catch((err) => console.error(err));
122
+ console.log(`\x1b[32m 🎉 Block '${newName}' created successfully! \x1b[0m`);
128
123
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@total_onion/onion-library",
3
- "version": "3.0.33",
3
+ "version": "3.0.35",
4
4
  "description": "Component library",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "homepage": "https://github.com/TotalOnion/onion-library#readme",
20
20
  "dependencies": {
21
- "@total_onion/onion-modalcontroller": "^1.1.3",
21
+ "@total_onion/onion-modalcontroller": "^1.2.4",
22
22
  "@total_onion/onion-videocontroller": "^1.2.5",
23
23
  "lottie-web": "^5.13.0",
24
24
  "swiper": "^12.1.3"
@@ -1,37 +1 @@
1
1
  // This file is auto-generated.
2
- @use '../components/block-video-content-v3/video-content-v3.scss';
3
- @use '../components/block-sub-group-container-v3/sub-group-container-v3.scss';
4
- @use '../components/block-sticky-buy-cta-v3/sticky-buy-cta-v3.scss';
5
- @use '../components/block-standard-content-v3/standard-content-v3.scss';
6
- @use '../components/block-spotify-embed-v3/spotify-embed-v3.scss';
7
- @use '../components/block-spacer-v3/spacer-v3.scss';
8
- @use '../components/block-social-networks-v3/social-networks-v3.scss';
9
- @use '../components/block-smash-balloon-social-media-v3/smash-balloon-social-media-v3.scss';
10
- @use '../components/block-site-title-and-tagline-v3/site-title-and-tagline-v3.scss';
11
- @use '../components/block-site-logo-container-v3/site-logo-container-v3.scss';
12
- @use '../components/block-site-copyright-notice-v3/site-copyright-notice-v3.scss';
13
- @use '../components/block-single-responsive-image-v3/single-responsive-image-v3.scss';
14
- @use '../components/block-single-column-container-v3/single-column-container-v3.scss';
15
- @use '../components/block-section-separator-v3/section-separator-v3.scss';
16
- @use '../components/block-scrolling-banner-v3/scrolling-banner-v3.scss';
17
- @use '../components/block-responsive-table-v3/responsive-table-v3.scss';
18
- @use '../components/block-raw-html-v3/raw-html-v3.scss';
19
- @use '../components/block-product-info-v3/product-info-v3.scss';
20
- @use '../components/block-post-info-v3/post-info-v3.scss';
21
- @use '../components/block-nav-menu-container-v3/nav-menu-container-v3.scss';
22
- @use '../components/block-modal-form-v3/modal-form-v3.scss';
23
- @use '../components/block-market-selector-v3/market-selector-v3.scss';
24
- @use '../components/block-lottie-content-v3/lottie-content-v3.scss';
25
- @use '../components/block-group-container-v3/group-container-v3.scss';
26
- @use '../components/block-gradient-layer-v3/gradient-layer-v3.scss';
27
- @use '../components/block-form-selection-v3/form-selection-v3.scss';
28
- @use '../components/block-featured-image-gallery-v3/featured-image-gallery-v3.scss';
29
- @use '../components/block-divider-v3/divider-v3.scss';
30
- @use '../components/block-cover-link-v3/cover-link-v3.scss';
31
- @use '../components/block-cocktail-recipe-v3/cocktail-recipe-v3.scss';
32
- @use '../components/block-carousel-multi-layout-v3/carousel-multi-layout-v3.scss';
33
- @use '../components/block-block-interactions-v3/block-interactions-v3.scss';
34
- @use '../components/block-betterreviews-display-v3/betterreviews-display-v3.scss';
35
- @use '../components/block-back-to-top-button-v3/back-to-top-button-v3.scss';
36
- @use '../components/block-accordion-v3/accordion-v3.scss';
37
- @use '../components/block-accent-image-v3/accent-image-v3.scss';