@total_onion/onion-library 2.0.4 → 2.0.6

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.
@@ -6,7 +6,7 @@
6
6
  @use '../../breakpoints';
7
7
 
8
8
  @mixin coreGroupContainerStylesV3() {
9
- .cmpl-core-group-container {
9
+ .cmpl-core-group-container-styles {
10
10
  display: grid;
11
11
  grid-template: 'main' / 1fr;
12
12
  place-items: center;
@@ -3,6 +3,8 @@ const fs = require('fs');
3
3
  const {globSync} = require('glob');
4
4
  const {exec} = require('child_process');
5
5
  const acfTemplate = require('./new-block-templates/template-acf-pattern');
6
+ const acfTemplateScss = require('@total_onion/onion-library/new-block-templates/template-scss-blank');
7
+ const acfTemplateJs = require('@total_onion/onion-library/new-block-templates/template-js-blank');
6
8
  const yaml = require('js-yaml');
7
9
  const axios = require('axios');
8
10
 
@@ -67,9 +69,9 @@ fs.writeFileSync(
67
69
 
68
70
  const blockName = 'group-container-v3';
69
71
 
70
- console.log(`${srcPathJs}/block-${blockName}/${blockName}.js`);
71
- console.log('__dirname:', __dirname);
72
- console.log('process.cwd():', process.cwd());
72
+ // console.log(`${srcPathJs}/block-${blockName}/${blockName}.js`);
73
+ // console.log('__dirname:', __dirname);
74
+ // console.log('process.cwd():', process.cwd());
73
75
 
74
76
  const fullPath = `${srcPathJs}/block-${blockName}/${blockName}.js`;
75
77
 
@@ -82,65 +84,20 @@ const scssdir = `Assets/scss/blocks/`;
82
84
  // fs.mkdirSync(scssdir, 0o744);
83
85
  // }
84
86
 
85
- if (fs.existsSync(`${srcPathJs}/block-${blockName}/${blockName}.js`)) {
86
- console.log('found it');
87
-
88
- fs.readFile(
89
- `${srcPathJs}/block-${blockName}/${blockName}.js`,
90
- 'utf-8',
91
- (err, contents) => {
92
- if (err) throw err;
93
- const regEx = RegExp(
94
- String.raw`(${blockName.replaceAll(/( |-)/g, '')})`,
95
- 'gi'
96
- );
97
-
98
- const replaced = contents
99
- .replaceAll(
100
- regEx,
101
- `${newBlockName.toLowerCase().replaceAll(/( |-)/g, '')}`
102
- )
103
- .replaceAll(
104
- `blocks/${blockName}/${blockName}-extra`,
105
- `blocks/${newBlockName}/${newBlockName}-extra`
106
- );
107
- fs.writeFile(
108
- `${jsdir}/${newBlockName}.js`,
109
- replaced,
110
- 'utf-8',
111
- function (err) {
112
- if (err) throw err;
113
- console.log(
114
- `👑👑\x1b[32m Successfully duplicated the js file! 👑👑`
115
- );
116
- }
117
- );
118
- }
87
+ if (!fs.existsSync(`${jsdir}/${newBlockName}.js`)) {
88
+ fs.writeFileSync(
89
+ `${jsdir}/${newBlockName}.js`,
90
+ acfTemplateJs(newBlockName)
119
91
  );
92
+ console.log(`👑👑\x1b[32m Successfully created the js file! 👑👑`);
120
93
  }
121
- if (fs.existsSync(`${srcPathJs}/block-${blockName}/${blockName}.scss`)) {
122
- fs.readFile(
123
- `${srcPathJs}/block-${blockName}/${blockName}.scss`,
124
- 'utf-8',
125
- (err, contents) => {
126
- if (err) throw err;
127
- const replaced = contents.replaceAll(
128
- `${blockName}`,
129
- `${newBlockName}`
130
- );
131
- fs.writeFile(
132
- `${scssdir}/${newBlockName}.scss`,
133
- replaced,
134
- 'utf-8',
135
- function (err) {
136
- if (err) throw err;
137
- console.log(
138
- `👑👑\x1b[32m Successfully duplicated the scss file! 👑👑`
139
- );
140
- }
141
- );
142
- }
94
+
95
+ if (!fs.existsSync(`${scssdir}/${newBlockName}.scss`)) {
96
+ fs.writeFileSync(
97
+ `${scssdir}/${newBlockName}.scss`,
98
+ acfTemplateScss(newBlockName)
143
99
  );
100
+ console.log(`👑👑\x1b[32m Successfully created the scss file! 👑👑`);
144
101
  }
145
102
 
146
103
  let data = new FormData();
@@ -182,14 +139,13 @@ axios.post(parentURL, data, headers).then(function (response) {
182
139
  function (err) {
183
140
  if (err) throw err;
184
141
  console.log(
185
- `👑👑\x1b[32m Successfully duplicated the js file! 👑👑`
142
+ `👑👑\x1b[32m Successfully did searcha and replace on the twig file! 👑👑`
143
+ );
144
+ console.log(
145
+ `👑 👑 👑 Hurrah! You made a new child block called ${newBlockName} 👑 👑 👑`
186
146
  );
187
147
  }
188
148
  );
189
149
  }
190
150
  );
191
151
  });
192
-
193
- console.log(
194
- `👑 👑 👑 Hurrah! You made a new child block called ${newBlockName} 👑 👑 👑`
195
- );
@@ -0,0 +1,12 @@
1
+ module.exports = function (newBlockName, projectName) {
2
+ return `export default function ${newBlockName.replaceAll(
3
+ '-',
4
+ ''
5
+ )}(options = {}) {
6
+ try {
7
+ const {block} = options;
8
+ } catch (error) {
9
+ console.error(error);
10
+ }
11
+ }`;
12
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (newBlockName, projectName) {
2
+ return `.${newBlockName} {}`;
3
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@total_onion/onion-library",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "Component library",
5
5
  "main": "index.js",
6
6
  "scripts": {