@total_onion/onion-library 3.0.20 → 3.0.23
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.
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
{{block.anchor ? "id=" ~ block.anchor : ''}} class="{{blockClassName}} {{block.className}} {{classNameEntryPoint}} lazy-fade {{block.id}}" {{dataAttributeEntryPoint}} data-blockid="{{block.id}}" data-assetkey="{{blockClassName}}">
|
|
17
17
|
|
|
18
18
|
<!--pattern-replace-start:component/video-component-v3 -->
|
|
19
|
-
{{include('components/video-component-v3',{ fields, block, blockClassName }, with_context = false)}}
|
|
19
|
+
{{include('components/video-component-v3.twig',{ fields, block, blockClassName }, with_context = false)}}
|
|
20
20
|
<!--pattern-replace-end:component/video-component-v3 -->
|
|
21
21
|
|
|
22
22
|
{% if fields.animations.enable_animations %}
|
package/duplicateBlock.js
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const fs = require('fs');
|
|
3
|
-
const
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const {globSync} = require('glob');
|
|
4
5
|
const yargs = require('yargs');
|
|
5
6
|
const compressing = require('compressing');
|
|
6
|
-
const { log } = require('console');
|
|
7
7
|
const templateOptions = yargs.argv._;
|
|
8
8
|
const themePath =
|
|
9
9
|
process.env.THEME_PATH || 'web/wp-content/themes/global-theme';
|
|
10
10
|
const srcPathJs = `${themePath}/assets/js/blocks`;
|
|
11
11
|
const srcPathScss = `${themePath}/assets/scss/blocks`;
|
|
12
12
|
const srcPathTwig = `${themePath}/views/blocks`;
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const destPath =
|
|
13
|
+
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');
|
|
16
18
|
const newName = templateOptions[1];
|
|
17
19
|
|
|
18
|
-
const exisitingBlockNames =
|
|
19
|
-
.map((
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const exisitingBlockNames = [
|
|
21
|
+
...globSync(`${themePath}/assets/js/blocks/*.js`).map((p) =>
|
|
22
|
+
path.basename(p, '.js')
|
|
23
|
+
),
|
|
24
|
+
...globSync(`${themePath}/inc/acf-blocks/*/block.json`).map((p) =>
|
|
25
|
+
path.basename(path.dirname(p))
|
|
26
|
+
)
|
|
27
|
+
];
|
|
25
28
|
|
|
26
29
|
const blockName = templateOptions[0];
|
|
27
30
|
|
|
@@ -54,162 +57,72 @@ if (exisitingBlockNames.includes(blockName)) {
|
|
|
54
57
|
}
|
|
55
58
|
fs.mkdirSync(dir);
|
|
56
59
|
if (fs.existsSync(`${srcPathJs}/${blockName}.js`)) {
|
|
57
|
-
fs.
|
|
60
|
+
const contents = fs.readFileSync(
|
|
58
61
|
`${srcPathJs}/${blockName}.js`,
|
|
59
|
-
'utf-8'
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
'gi'
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const replaced = contents
|
|
68
|
-
.replaceAll(
|
|
69
|
-
regEx,
|
|
70
|
-
`${newName.toLowerCase().replaceAll(/( |-)/g, '')}`
|
|
71
|
-
)
|
|
72
|
-
.replaceAll(`blocks/${blockName}`, `blocks/${newName}`);
|
|
73
|
-
fs.writeFile(
|
|
74
|
-
`${dir}/${newName}.js`,
|
|
75
|
-
replaced,
|
|
76
|
-
'utf-8',
|
|
77
|
-
function (err) {
|
|
78
|
-
if (err) throw err;
|
|
79
|
-
console.log(
|
|
80
|
-
`👑👑\x1b[32m Successfully duplicated the js file! 👑👑`
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
}
|
|
62
|
+
'utf-8'
|
|
63
|
+
);
|
|
64
|
+
const regEx = RegExp(
|
|
65
|
+
String.raw`(${blockName.replaceAll(/( |-)/g, '')})`,
|
|
66
|
+
'gi'
|
|
85
67
|
);
|
|
68
|
+
const replaced = contents
|
|
69
|
+
.replaceAll(
|
|
70
|
+
regEx,
|
|
71
|
+
`${newName.toLowerCase().replaceAll(/( |-)/g, '')}`
|
|
72
|
+
)
|
|
73
|
+
.replaceAll(`blocks/${blockName}`, `blocks/${newName}`);
|
|
74
|
+
fs.writeFileSync(`${dir}/${newName}.js`, replaced, 'utf-8');
|
|
75
|
+
console.log(`👑👑\x1b[32m Successfully duplicated the js file! 👑👑`);
|
|
86
76
|
}
|
|
87
77
|
if (fs.existsSync(`${srcPathScss}/${blockName}.scss`)) {
|
|
88
|
-
fs.
|
|
78
|
+
const contents = fs.readFileSync(
|
|
89
79
|
`${srcPathScss}/${blockName}.scss`,
|
|
90
|
-
'utf-8'
|
|
91
|
-
(err, contents) => {
|
|
92
|
-
if (err) throw err;
|
|
93
|
-
const replaced = contents.replaceAll(
|
|
94
|
-
`${blockName}`,
|
|
95
|
-
`${newName}`
|
|
96
|
-
);
|
|
97
|
-
fs.writeFile(
|
|
98
|
-
`${dir}/${newName}.scss`,
|
|
99
|
-
replaced,
|
|
100
|
-
'utf-8',
|
|
101
|
-
function (err) {
|
|
102
|
-
if (err) throw err;
|
|
103
|
-
console.log(
|
|
104
|
-
`👑👑\x1b[32m Successfully duplicated the scss file! 👑👑`
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
);
|
|
108
|
-
}
|
|
80
|
+
'utf-8'
|
|
109
81
|
);
|
|
82
|
+
const replaced = contents.replaceAll(`${blockName}`, `${newName}`);
|
|
83
|
+
fs.writeFileSync(`${dir}/${newName}.scss`, replaced, 'utf-8');
|
|
84
|
+
console.log(`👑👑\x1b[32m Successfully duplicated the scss file! 👑👑`);
|
|
110
85
|
}
|
|
111
86
|
if (fs.existsSync(`${srcPathTwig}/${blockName}.twig`)) {
|
|
112
|
-
fs.
|
|
87
|
+
const contents = fs.readFileSync(
|
|
113
88
|
`${srcPathTwig}/${blockName}.twig`,
|
|
114
|
-
'utf-8'
|
|
115
|
-
(err, contents) => {
|
|
116
|
-
if (err) throw err;
|
|
117
|
-
const regEx = RegExp(String.raw`(\"${blockName}) `, 'gi');
|
|
118
|
-
const replaced = contents.replaceAll(regEx, `"${newName} `);
|
|
119
|
-
const regEx2 = RegExp(
|
|
120
|
-
String.raw`([\"|\']${blockName}[\"|\'])`,
|
|
121
|
-
'gi'
|
|
122
|
-
);
|
|
123
|
-
const replaced2 = replaced.replaceAll(regEx2, `"${newName}"`);
|
|
124
|
-
fs.writeFile(
|
|
125
|
-
`${dir}/${newName}.twig`,
|
|
126
|
-
replaced2,
|
|
127
|
-
'utf-8',
|
|
128
|
-
function (err) {
|
|
129
|
-
if (err) throw err;
|
|
130
|
-
console.log(
|
|
131
|
-
`👑👑\x1b[32m Successfully duplicated the twig file! 👑👑`
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
);
|
|
135
|
-
}
|
|
89
|
+
'utf-8'
|
|
136
90
|
);
|
|
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');
|
|
96
|
+
console.log(`👑👑\x1b[32m Successfully duplicated the twig file! 👑👑`);
|
|
137
97
|
}
|
|
138
|
-
if (fs.existsSync(`${
|
|
139
|
-
fs.
|
|
140
|
-
`${
|
|
141
|
-
'utf-8'
|
|
142
|
-
(err, contents) => {
|
|
143
|
-
if (err) throw err;
|
|
144
|
-
const replaced = contents.replaceAll(
|
|
145
|
-
`${blockName}`,
|
|
146
|
-
`${newName}`
|
|
147
|
-
);
|
|
148
|
-
const regEx = RegExp(
|
|
149
|
-
String.raw`${blockName.replaceAll('-', ' ')}`,
|
|
150
|
-
'gi'
|
|
151
|
-
);
|
|
152
|
-
const replaced2 = replaced.replaceAll(
|
|
153
|
-
regEx,
|
|
154
|
-
`${newName.slice(0, 1).toUpperCase()}${newName
|
|
155
|
-
.replaceAll('-', ' ')
|
|
156
|
-
.slice(1)}`
|
|
157
|
-
);
|
|
158
|
-
const regEx2 = RegExp(
|
|
159
|
-
String.raw`${blockName.replaceAll('-', '_')}`,
|
|
160
|
-
'gi'
|
|
161
|
-
);
|
|
162
|
-
const replaced3 = replaced2.replaceAll(
|
|
163
|
-
regEx2,
|
|
164
|
-
`${newName.replaceAll('-', '_')}`
|
|
165
|
-
);
|
|
166
|
-
fs.writeFile(
|
|
167
|
-
`${dir}/${newName}.php`,
|
|
168
|
-
replaced3,
|
|
169
|
-
'utf-8',
|
|
170
|
-
function (err) {
|
|
171
|
-
if (err) throw err;
|
|
172
|
-
console.log(
|
|
173
|
-
`👑👑\x1b[32m Successfully duplicated the php file! 👑👑`
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
);
|
|
177
|
-
}
|
|
98
|
+
if (fs.existsSync(`${srcPathBlockJson}/${blockName}/block.json`)) {
|
|
99
|
+
const contents = fs.readFileSync(
|
|
100
|
+
`${srcPathBlockJson}/${blockName}/block.json`,
|
|
101
|
+
'utf-8'
|
|
178
102
|
);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (err) throw err;
|
|
196
|
-
console.log(
|
|
197
|
-
`👑👑\x1b[32m Successfully duplicated the vue file! 👑👑`
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
);
|
|
201
|
-
}
|
|
103
|
+
const data = JSON.parse(contents);
|
|
104
|
+
data.name = `acf/${newName}`;
|
|
105
|
+
data.title = newName
|
|
106
|
+
.split('-')
|
|
107
|
+
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
|
108
|
+
.join(' ');
|
|
109
|
+
if (data.description) {
|
|
110
|
+
data.description = data.description.replaceAll(blockName, newName);
|
|
111
|
+
}
|
|
112
|
+
fs.writeFileSync(
|
|
113
|
+
`${dir}/block.json`,
|
|
114
|
+
JSON.stringify(data, null, '\t'),
|
|
115
|
+
'utf-8'
|
|
116
|
+
);
|
|
117
|
+
console.log(
|
|
118
|
+
`👑👑\x1b[32m Successfully duplicated the block.json file! 👑👑`
|
|
202
119
|
);
|
|
203
120
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
.compressDir(`${dir}`, `${dir}.zip`)
|
|
212
|
-
.then(compressDone)
|
|
213
|
-
.catch(handleError);
|
|
214
|
-
}, 100);
|
|
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));
|
|
215
128
|
}
|