color-name-list 11.10.0 → 11.10.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "color-name-list",
3
- "version": "11.10.0",
3
+ "version": "11.10.1",
4
4
  "description": "long list of color names",
5
5
  "main": "dist/colornames.json",
6
6
  "browser": "dist/colornames.umd.js",
package/scripts/build.js CHANGED
@@ -410,24 +410,70 @@ function log(key, value, message, errorLevel = 1) {
410
410
  // gets SVG template
411
411
  const svgTpl = fs.readFileSync(path.normalize(__dirname + '/changes.svg.tpl'), 'utf8').toString();
412
412
 
413
- // generates an SVG image with the new color based on the diff ot the last commit to the current
413
+ // generates an SVG image with the new colors based on the diff between the last two commits that changed the file
414
414
  function diffSVG() {
415
+ // Get the last two commits that modified the CSV file
415
416
  exec(
416
- `git diff -U0 HEAD ${baseFolder}${folderDist}${fileNameSrc}.csv`,
417
+ `git log -n 2 --pretty=format:"%H" -- ${baseFolder}${folderSrc}${fileNameSrc}.csv`,
417
418
  function (err, stdout, stderr) {
418
- const diffTxt = stdout;
419
- if (!/(?<=^[+])[^+].*/gm.test(diffTxt)) return;
420
- const changes = diffTxt.match(/(?<=^[+])[^+].*/gm).filter((i) => i);
421
- const svgTxtStr = changes.reduce((str, change, i) => {
422
- const changeParts = change.split(',');
423
- return `${str}<text x="40" y="${20 + (i + 1) * 70}" fill="${
424
- changeParts[1]
425
- }">${changeParts[0].replace(/&/g, '&amp;')}</text>`;
426
- }, '');
427
-
428
- fs.writeFileSync(
429
- path.normalize(`${baseFolder}changes.svg`),
430
- svgTpl.replace(/{height}/g, changes.length * 70 + 80).replace(/{items}/g, svgTxtStr)
419
+ if (err) {
420
+ console.error('Error getting commit history:', err);
421
+ return;
422
+ }
423
+
424
+ const commits = stdout.trim().split('\n');
425
+ if (commits.length < 2) {
426
+ console.log('Not enough commit history to generate diff');
427
+ return;
428
+ }
429
+
430
+ const newerCommit = commits[0];
431
+ const olderCommit = commits[1];
432
+
433
+ // Compare the two commits
434
+ exec(
435
+ `git diff -w -U0 ${olderCommit} ${newerCommit} -- ${baseFolder}${folderSrc}${fileNameSrc}.csv`,
436
+ function (err, stdout, stderr) {
437
+ if (err) {
438
+ console.error('Error generating diff:', err);
439
+ return;
440
+ }
441
+
442
+ const diffTxt = stdout;
443
+ if (!/(?<=^[+])[^+].*/gm.test(diffTxt)) {
444
+ console.log('No changes detected in the color file');
445
+ return;
446
+ }
447
+
448
+ const changes = diffTxt.match(/(?<=^[+])[^+].*/gm).filter((i) => i);
449
+
450
+ // Filter out the header line if it was included in the diff
451
+ const filteredChanges = changes.filter((line) => !line.startsWith('name,hex'));
452
+
453
+ if (filteredChanges.length === 0) {
454
+ console.log('No color changes detected');
455
+ return;
456
+ }
457
+
458
+ const svgTxtStr = filteredChanges.reduce((str, change, i) => {
459
+ const changeParts = change.split(',');
460
+ // Make sure we have both the name and hex color
461
+ if (changeParts.length < 2) return str;
462
+
463
+ return `${str}<text x="40" y="${20 + (i + 1) * 70}" fill="${
464
+ changeParts[1]
465
+ }">${changeParts[0].replace(/&/g, '&amp;')}</text>`;
466
+ }, '');
467
+
468
+ fs.writeFileSync(
469
+ path.normalize(`${baseFolder}changes.svg`),
470
+ svgTpl
471
+ .replace(/{height}/g, filteredChanges.length * 70 + 80)
472
+ .replace(/{items}/g, svgTxtStr)
473
+ );
474
+
475
+ console.log(`Generated SVG showing ${filteredChanges.length} new color(s)`);
476
+ }
431
477
  );
432
478
  }
433
479
  );
@@ -20509,6 +20509,7 @@ Pinkish Orange,#ff724c,
20509
20509
  Pinkish Purple,#d648d7,
20510
20510
  Pinkish Red,#f10c45,
20511
20511
  Pinkish Tan,#d99b82,
20512
+ Pinkish White,#fff1fa,
20512
20513
  Pinkling,#eb84f5,x
20513
20514
  Pinkman,#dd11ff,x
20514
20515
  Pinktone,#f9ced1,
@@ -30288,5 +30289,4 @@ Zumthor,#cdd5d5,
30288
30289
  Zunda Green,#6bc026,x
30289
30290
  Zuni,#008996,
30290
30291
  Zürich Blue,#248bcc,
30291
- Zürich White,#e6e1d9,
30292
- Pinkish White,#fff1fa,
30292
+ Zürich White,#e6e1d9,