color-name-list 11.10.0 → 11.11.0

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.11.0",
4
4
  "description": "long list of color names",
5
5
  "main": "dist/colornames.json",
6
6
  "browser": "dist/colornames.umd.js",
@@ -28,11 +28,14 @@
28
28
  "test:watch": "vitest",
29
29
  "build": "node scripts/build.js && npm run prettier",
30
30
  "prettier": "prettier --write ./dist/*",
31
- "lint": "eslint ./scripts",
31
+ "lint": "npm run lint:scripts && npm run lint:markdown",
32
+ "lint:scripts": "eslint ./scripts",
33
+ "lint:markdown": "markdownlint-cli2 '**/*.md' '#node_modules'",
32
34
  "semantic-release": "semantic-release",
33
35
  "build-history": "node scripts/tools/history.js > dist/history.json",
34
36
  "history": "node scripts/tools/history.js > dist/history.json",
35
- "prepare": "husky"
37
+ "prepare": "husky",
38
+ "sort-colors": "node scripts/sortSrc.js"
36
39
  },
37
40
  "repository": {
38
41
  "type": "git",
@@ -64,6 +67,7 @@
64
67
  "eslint-plugin-prettier": "^5.2.6",
65
68
  "globals": "^16.0.0",
66
69
  "husky": "^9.1.6",
70
+ "markdownlint-cli2": "^0.17.2",
67
71
  "prettier": "^3.5.3",
68
72
  "seedrandom": "^3.0.5",
69
73
  "semantic-release": "^24.2.0",
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
  );
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Script to sort the colornames.csv file alphabetically by name
5
+ * This helps maintain order when new colors are added to the list
6
+ */
7
+
8
+ import fs from 'fs';
9
+ import path from 'path';
10
+ import { fileURLToPath } from 'url';
11
+
12
+ // Get the directory name using ES modules approach
13
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
14
+
15
+ // Path to the CSV file
16
+ const csvPath = path.join(__dirname, '..', 'src', 'colornames.csv');
17
+
18
+ // Read the CSV file
19
+ const readAndSortCSV = () => {
20
+ try {
21
+ // Read the file
22
+ const data = fs.readFileSync(csvPath, 'utf8');
23
+
24
+ // Split the data into lines
25
+ const lines = data.trim().split('\n');
26
+
27
+ // The header should be kept as the first line
28
+ const header = lines[0];
29
+
30
+ // Remove the header from the array of lines
31
+ const colorLines = lines.slice(1);
32
+
33
+ // Sort the color lines alphabetically by name (case-insensitive)
34
+ const sortedColorLines = colorLines.sort((a, b) => {
35
+ // Extract the name from each line (first column before the comma)
36
+ const nameA = a.split(',')[0].toLowerCase();
37
+ const nameB = b.split(',')[0].toLowerCase();
38
+ return nameA.localeCompare(nameB);
39
+ });
40
+
41
+ // Combine the header and sorted lines
42
+ const sortedData = [header, ...sortedColorLines].join('\n');
43
+
44
+ // Write the sorted data back to the file
45
+ fs.writeFileSync(csvPath, sortedData, 'utf8');
46
+
47
+ console.log(`✅ Successfully sorted ${sortedColorLines.length} colors alphabetically by name`);
48
+ console.log(`📝 File saved: ${csvPath}`);
49
+
50
+ } catch (error) {
51
+ console.error('❌ Error sorting the CSV file:', error);
52
+ process.exit(1);
53
+ }
54
+ };
55
+
56
+ // Execute the function
57
+ readAndSortCSV();
@@ -17445,6 +17445,7 @@ Morro Bay,#546b78,
17445
17445
  Morrow White,#fcfccf,
17446
17446
  Mortar,#565051,
17447
17447
  Mortar Grey,#9e9f9e,
17448
+ MoS₂ Cyan,#00e6d3,
17448
17449
  Mosaic Blue,#007c94,
17449
17450
  Mosaic Green,#599f68,
17450
17451
  Mosaic Tile,#1c6b69,
@@ -20509,6 +20510,7 @@ Pinkish Orange,#ff724c,
20509
20510
  Pinkish Purple,#d648d7,
20510
20511
  Pinkish Red,#f10c45,
20511
20512
  Pinkish Tan,#d99b82,
20513
+ Pinkish White,#fff1fa,
20512
20514
  Pinkling,#eb84f5,x
20513
20515
  Pinkman,#dd11ff,x
20514
20516
  Pinktone,#f9ced1,
@@ -30288,5 +30290,4 @@ Zumthor,#cdd5d5,
30288
30290
  Zunda Green,#6bc026,x
30289
30291
  Zuni,#008996,
30290
30292
  Zürich Blue,#248bcc,
30291
- Zürich White,#e6e1d9,
30292
- Pinkish White,#fff1fa,
30293
+ Zürich White,#e6e1d9,