@tixyel/cli 2.6.0 → 2.6.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/dist/widget.js +15 -6
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -15,7 +15,7 @@ import postcss from 'postcss';
|
|
|
15
15
|
import cssnano from 'cssnano';
|
|
16
16
|
import JSZip from 'jszip';
|
|
17
17
|
import { transformSync } from 'esbuild';
|
|
18
|
-
import { watermark } from './utils/watermark';
|
|
18
|
+
import { watermark } from './utils/watermark.js';
|
|
19
19
|
export async function createWidget(path, metadata, config, root) {
|
|
20
20
|
try {
|
|
21
21
|
console.log(`📁 Creating ${metadata?.name} at: ${path}`);
|
|
@@ -294,8 +294,17 @@ export async function processBuild(widget, workspaceConfig, verbose = false) {
|
|
|
294
294
|
const list = normalizeList(patterns);
|
|
295
295
|
if (!list.length)
|
|
296
296
|
return [key, ''];
|
|
297
|
+
const check = (keys, formats) => {
|
|
298
|
+
!Array.isArray(keys) && (keys = [keys]);
|
|
299
|
+
!Array.isArray(formats) && (formats = [formats]);
|
|
300
|
+
return (
|
|
301
|
+
// check keys
|
|
302
|
+
keys.some((k) => key.toLowerCase() === k.toLowerCase()) ||
|
|
303
|
+
// check formats
|
|
304
|
+
list.some((p) => formats.some((f) => p.toLowerCase().endsWith(f.toLowerCase()))));
|
|
305
|
+
};
|
|
297
306
|
// Process HTML
|
|
298
|
-
if (
|
|
307
|
+
if (check('html', '.html')) {
|
|
299
308
|
if (!usedWatermarks.has('html'))
|
|
300
309
|
result += watermark.html(widget) + '\n';
|
|
301
310
|
usedWatermarks.add('html');
|
|
@@ -325,7 +334,7 @@ export async function processBuild(widget, workspaceConfig, verbose = false) {
|
|
|
325
334
|
const minified = await minifyHTML(mergedHTML, workspaceConfig.build?.obfuscation?.html);
|
|
326
335
|
result += minified.trim();
|
|
327
336
|
}
|
|
328
|
-
else if (['css', 'style', 'styles']
|
|
337
|
+
else if (check(['css', 'style', 'styles'], '.css')) {
|
|
329
338
|
if (!usedWatermarks.has('css'))
|
|
330
339
|
result += watermark.css(widget) + '\n';
|
|
331
340
|
usedWatermarks.add('css');
|
|
@@ -349,7 +358,7 @@ export async function processBuild(widget, workspaceConfig, verbose = false) {
|
|
|
349
358
|
}
|
|
350
359
|
result += mergedCSS.trim();
|
|
351
360
|
}
|
|
352
|
-
else if (['script', 'js', 'javascript']
|
|
361
|
+
else if (check(['script', 'js', 'javascript'], '.js')) {
|
|
353
362
|
if (!usedWatermarks.has('script'))
|
|
354
363
|
result += watermark.script(widget) + '\n';
|
|
355
364
|
usedWatermarks.add('script');
|
|
@@ -363,7 +372,7 @@ export async function processBuild(widget, workspaceConfig, verbose = false) {
|
|
|
363
372
|
}
|
|
364
373
|
result += mergedJS.trim();
|
|
365
374
|
}
|
|
366
|
-
else if (['typescript', 'ts']
|
|
375
|
+
else if (check(['typescript', 'ts'], '.ts')) {
|
|
367
376
|
if (!usedWatermarks.has('script'))
|
|
368
377
|
result += watermark.script(widget) + '\n';
|
|
369
378
|
usedWatermarks.add('script');
|
|
@@ -389,7 +398,7 @@ export async function processBuild(widget, workspaceConfig, verbose = false) {
|
|
|
389
398
|
const obfuscated = JavaScriptObfuscator.obfuscate(mergedTS.trim(), workspaceConfig.build?.obfuscation?.javascript);
|
|
390
399
|
result += obfuscated.getObfuscatedCode();
|
|
391
400
|
}
|
|
392
|
-
else if (['fields', '
|
|
401
|
+
else if (check(['fields', 'fielddata', 'fieldData', 'cf', 'customfields'], '.json')) {
|
|
393
402
|
if (verbose)
|
|
394
403
|
console.log(` - Processing Json...`);
|
|
395
404
|
const files = findAndRead(entryDir, list);
|