color-name-list 11.9.1 → 11.10.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.
Files changed (37) hide show
  1. package/.github/workflows/build-and-release.yml +57 -0
  2. package/.github/workflows/build.yml +22 -7
  3. package/.husky/pre-commit +1 -1
  4. package/README.md +9 -4
  5. package/dist/colornames.bestof.csv +4532 -4532
  6. package/dist/colornames.bestof.esm.js +1 -4535
  7. package/dist/colornames.bestof.esm.mjs +1 -4535
  8. package/dist/colornames.bestof.json +1 -4535
  9. package/dist/colornames.bestof.scss +1 -4535
  10. package/dist/colornames.bestof.umd.js +1 -4543
  11. package/dist/colornames.bestof.yaml +9067 -4534
  12. package/dist/colornames.csv +30290 -30289
  13. package/dist/colornames.esm.js +1 -30292
  14. package/dist/colornames.esm.mjs +1 -30292
  15. package/dist/colornames.html +1 -1
  16. package/dist/colornames.json +1 -30292
  17. package/dist/colornames.min.json +1 -1
  18. package/dist/colornames.scss +1 -30292
  19. package/dist/colornames.short.csv +2885 -2885
  20. package/dist/colornames.short.esm.js +1 -2888
  21. package/dist/colornames.short.esm.mjs +1 -2888
  22. package/dist/colornames.short.json +1 -2888
  23. package/dist/colornames.short.scss +1 -2888
  24. package/dist/colornames.short.umd.js +1 -2896
  25. package/dist/colornames.short.yaml +5773 -2887
  26. package/dist/colornames.umd.js +1 -30300
  27. package/dist/colornames.xml +4 -0
  28. package/dist/colornames.yaml +60584 -30291
  29. package/dist/history.json +1 -61120
  30. package/package.json +7 -5
  31. package/scripts/build.js +6 -0
  32. package/scripts/tools/history.js +6 -1
  33. package/src/colornames.csv +2 -1
  34. package/tests/formats.test.js +46 -0
  35. package/tests/imports.test.js +119 -0
  36. package/vitest.config.js +8 -0
  37. package/.github/workflows/release.yml +0 -26
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "color-name-list",
3
- "version": "11.9.1",
3
+ "version": "11.10.0",
4
4
  "description": "long list of color names",
5
5
  "main": "dist/colornames.json",
6
6
  "browser": "dist/colornames.umd.js",
@@ -24,13 +24,14 @@
24
24
  "scripts": {
25
25
  "commit": "git-cz",
26
26
  "pull-colors": "curl -L 'https://docs.google.com/spreadsheets/d/e/2PACX-1vQube6Y0wHyEtJnjg0eU3N7VseoxVnD4L9uDqvWZdl_tzzrHDVN10IPP7cdFipX8j70atNMLfPCB0Q6/pub?gid=40578722&single=true&output=csv' -o src/colornames.csv",
27
- "test": "node scripts/build.js --testOnly",
28
- "clean-dist-folder": "rm -rf dist && mkdir dist",
29
- "build": "npm run clean-dist-folder && node scripts/build.js && npm run build-history && npm run prettier",
27
+ "test": "npm run build --testonly && npm run build && vitest run",
28
+ "test:watch": "vitest",
29
+ "build": "node scripts/build.js && npm run prettier",
30
30
  "prettier": "prettier --write ./dist/*",
31
31
  "lint": "eslint ./scripts",
32
32
  "semantic-release": "semantic-release",
33
33
  "build-history": "node scripts/tools/history.js > dist/history.json",
34
+ "history": "node scripts/tools/history.js > dist/history.json",
34
35
  "prepare": "husky"
35
36
  },
36
37
  "repository": {
@@ -65,7 +66,8 @@
65
66
  "husky": "^9.1.6",
66
67
  "prettier": "^3.5.3",
67
68
  "seedrandom": "^3.0.5",
68
- "semantic-release": "^24.2.0"
69
+ "semantic-release": "^24.2.0",
70
+ "vitest": "^3.1.2"
69
71
  },
70
72
  "engines": {
71
73
  "node": ">=20.11.0",
package/scripts/build.js CHANGED
@@ -135,6 +135,12 @@ const JSONExportStringShort = JSON.stringify(
135
135
  )
136
136
  );
137
137
 
138
+ // make sure dist folder exists
139
+ const distFolder = path.normalize(`${baseFolder}${folderDist}`);
140
+ if (!fs.existsSync(distFolder)) {
141
+ fs.mkdirSync(distFolder);
142
+ }
143
+
138
144
  fs.writeFileSync(path.normalize(`${baseFolder}${folderDist}${fileNameSrc}.json`), JSONExportString);
139
145
 
140
146
  fs.writeFileSync(
@@ -19,7 +19,7 @@ async function main() {
19
19
 
20
20
  for (const commit of allCommits) {
21
21
  // Figure out what changed in that particular commit
22
- const diff = cmd(`git show --ignore-cr-at-eol ${commit} -- ./src/colornames.csv`)
22
+ const diff = cmd(`git show -w --ignore-cr-at-eol ${commit} -- ./src/colornames.csv`)
23
23
  .split('\n')
24
24
  .filter(Boolean);
25
25
 
@@ -30,6 +30,11 @@ async function main() {
30
30
  const modified = {};
31
31
 
32
32
  for (const line of diff) {
33
+ // Ignore the header row
34
+ if (line.match(/^(\+|-)?name,hex/)) {
35
+ continue;
36
+ }
37
+
33
38
  const res = line.match(/^((?<op>(\+|-)))(?<name>[^,]+),(?<hex>[^,]+)/);
34
39
  if (!res) {
35
40
  continue;
@@ -30288,4 +30288,5 @@ Zumthor,#cdd5d5,
30288
30288
  Zunda Green,#6bc026,x
30289
30289
  Zuni,#008996,
30290
30290
  Zürich Blue,#248bcc,
30291
- Zürich White,#e6e1d9,
30291
+ Zürich White,#e6e1d9,
30292
+ Pinkish White,#fff1fa,
@@ -0,0 +1,46 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { parseCSVString } from '../scripts/lib.js';
5
+
6
+ describe('Other Format Tests', () => {
7
+ // Load CSV data for comparison
8
+ const csvSource = fs.readFileSync(path.resolve('./src/colornames.csv'), 'utf8').toString();
9
+ const csvData = parseCSVString(csvSource);
10
+ const csvColors = csvData.entries.map(entry => ({
11
+ name: entry.name,
12
+ hex: entry.hex
13
+ }));
14
+
15
+ describe('CSV Output', () => {
16
+ it('should correctly generate CSV files', () => {
17
+ const mainCsv = fs.readFileSync(path.resolve('./dist/colornames.csv'), 'utf8');
18
+ const bestofCsv = fs.readFileSync(path.resolve('./dist/colornames.bestof.csv'), 'utf8');
19
+ const shortCsv = fs.readFileSync(path.resolve('./dist/colornames.short.csv'), 'utf8');
20
+
21
+ // Check that the files are not empty
22
+ expect(mainCsv.length).toBeGreaterThan(0);
23
+ expect(bestofCsv.length).toBeGreaterThan(0);
24
+ expect(shortCsv.length).toBeGreaterThan(0);
25
+
26
+ // Verify headers
27
+ expect(mainCsv).toMatch(/^name,hex/);
28
+ expect(bestofCsv).toMatch(/^name,hex/);
29
+ expect(shortCsv).toMatch(/^name,hex/);
30
+
31
+ // Parse the CSV files
32
+ const mainData = parseCSVString(mainCsv);
33
+ const bestofData = parseCSVString(bestofCsv);
34
+ const shortData = parseCSVString(shortCsv);
35
+
36
+ // Verify data integrity
37
+ expect(mainData.entries.length).toBe(csvColors.length);
38
+ expect(bestofData.entries.length).toBeLessThan(csvColors.length);
39
+ expect(shortData.entries.length).toBeLessThan(bestofData.entries.length);
40
+
41
+ // Verify structure
42
+ expect(mainData.entries[0]).toHaveProperty('name');
43
+ expect(mainData.entries[0]).toHaveProperty('hex');
44
+ });
45
+ });
46
+ });
@@ -0,0 +1,119 @@
1
+ import { describe, it, expect } from 'vitest';
2
+
3
+ import * as esmColors from '../dist/colornames.esm.js';
4
+ import * as esmBestOfColors from '../dist/colornames.bestof.esm.js';
5
+ import * as esmShortColors from '../dist/colornames.short.esm.js';
6
+
7
+ // Import JSON files directly
8
+ import jsonColors from '../dist/colornames.json' assert { type: 'json' };
9
+ import jsonBestOfColors from '../dist/colornames.bestof.json' assert { type: 'json' };
10
+ import jsonShortColors from '../dist/colornames.short.json' assert { type: 'json' };
11
+
12
+ // Import minified JSON files
13
+ import jsonMinColors from '../dist/colornames.min.json' assert { type: 'json' };
14
+ import jsonMinBestOfColors from '../dist/colornames.bestof.min.json' assert { type: 'json' };
15
+ import jsonMinShortColors from '../dist/colornames.short.min.json' assert { type: 'json' };
16
+
17
+ // Also import the source CSV file for verification
18
+ import fs from 'fs';
19
+ import path from 'path';
20
+ import { parseCSVString } from '../scripts/lib.js';
21
+
22
+ describe('Color Names Import Tests', () => {
23
+ // Load CSV data for comparison
24
+ const csvSource = fs.readFileSync(path.resolve('./src/colornames.csv'), 'utf8').toString();
25
+ const csvData = parseCSVString(csvSource);
26
+ const csvColors = csvData.entries.map(entry => ({
27
+ name: entry.name,
28
+ hex: entry.hex
29
+ }));
30
+
31
+ describe('JSON Files', () => {
32
+ it('should import main JSON file correctly', () => {
33
+ expect(jsonColors).toBeDefined();
34
+ expect(Array.isArray(jsonColors)).toBe(true);
35
+ expect(jsonColors.length).toBeGreaterThan(0);
36
+ expect(jsonColors[0]).toHaveProperty('name');
37
+ expect(jsonColors[0]).toHaveProperty('hex');
38
+ expect(jsonColors.length).toBe(csvColors.length);
39
+ });
40
+
41
+ it('should import bestof JSON file correctly', () => {
42
+ expect(jsonBestOfColors).toBeDefined();
43
+ expect(Array.isArray(jsonBestOfColors)).toBe(true);
44
+ expect(jsonBestOfColors.length).toBeGreaterThan(0);
45
+ expect(jsonBestOfColors[0]).toHaveProperty('name');
46
+ expect(jsonBestOfColors[0]).toHaveProperty('hex');
47
+ expect(jsonBestOfColors.length).toBeLessThan(csvColors.length);
48
+ });
49
+
50
+ it('should import short JSON file correctly', () => {
51
+ expect(jsonShortColors).toBeDefined();
52
+ expect(Array.isArray(jsonShortColors)).toBe(true);
53
+ expect(jsonShortColors.length).toBeGreaterThan(0);
54
+ expect(jsonShortColors[0]).toHaveProperty('name');
55
+ expect(jsonShortColors[0]).toHaveProperty('hex');
56
+ expect(jsonShortColors.length).toBeLessThan(csvColors.length);
57
+ });
58
+
59
+ it('should import minified JSON files correctly', () => {
60
+ expect(jsonMinColors).toBeDefined();
61
+ expect(typeof jsonMinColors).toBe('object');
62
+ expect(Object.keys(jsonMinColors).length).toBeGreaterThan(0);
63
+ expect(Object.values(jsonMinColors).length).toBe(csvColors.length);
64
+
65
+ expect(jsonMinBestOfColors).toBeDefined();
66
+ expect(typeof jsonMinBestOfColors).toBe('object');
67
+ expect(Object.keys(jsonMinBestOfColors).length).toBeGreaterThan(0);
68
+
69
+ expect(jsonMinShortColors).toBeDefined();
70
+ expect(typeof jsonMinShortColors).toBe('object');
71
+ expect(Object.keys(jsonMinShortColors).length).toBeGreaterThan(0);
72
+ });
73
+ });
74
+
75
+ describe('ESM Files', () => {
76
+ it('should import main ESM file correctly', () => {
77
+ expect(esmColors).toBeDefined();
78
+ expect(esmColors.colornames).toBeDefined();
79
+ expect(Array.isArray(esmColors.colornames)).toBe(true);
80
+ expect(esmColors.colornames.length).toBeGreaterThan(0);
81
+ expect(esmColors.colornames[0]).toHaveProperty('name');
82
+ expect(esmColors.colornames[0]).toHaveProperty('hex');
83
+ expect(esmColors.colornames.length).toBe(csvColors.length);
84
+ });
85
+
86
+ it('should import bestof ESM file correctly', () => {
87
+ expect(esmBestOfColors).toBeDefined();
88
+ expect(esmBestOfColors.colornames).toBeDefined();
89
+ expect(Array.isArray(esmBestOfColors.colornames)).toBe(true);
90
+ expect(esmBestOfColors.colornames.length).toBeGreaterThan(0);
91
+ expect(esmBestOfColors.colornames[0]).toHaveProperty('name');
92
+ expect(esmBestOfColors.colornames[0]).toHaveProperty('hex');
93
+ });
94
+
95
+ it('should import short ESM file correctly', () => {
96
+ expect(esmShortColors).toBeDefined();
97
+ expect(esmShortColors.colornames).toBeDefined();
98
+ expect(Array.isArray(esmShortColors.colornames)).toBe(true);
99
+ expect(esmShortColors.colornames.length).toBeGreaterThan(0);
100
+ expect(esmShortColors.colornames[0]).toHaveProperty('name');
101
+ expect(esmShortColors.colornames[0]).toHaveProperty('hex');
102
+ });
103
+ });
104
+
105
+ describe('Content Verification', () => {
106
+ it('should contain expected color names', () => {
107
+ // Check for some common color names
108
+ const commonColors = ['black', 'white', 'red', 'blue', 'green', 'yellow', 'purple', 'pink'];
109
+
110
+ // Convert to lowercase for easier comparison
111
+ const allNames = jsonColors.map(color => color.name.toLowerCase());
112
+
113
+ commonColors.forEach(color => {
114
+ // Check if at least one entry contains this common color name
115
+ expect(allNames.some(name => name.includes(color))).toBe(true);
116
+ });
117
+ });
118
+ });
119
+ });
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ include: ['tests/**/*.test.js'],
6
+ environment: 'node',
7
+ },
8
+ });
@@ -1,26 +0,0 @@
1
- name: Semantic Release
2
-
3
- on:
4
- push:
5
- branches: [main]
6
-
7
- jobs:
8
- release:
9
- name: Release
10
- runs-on: ubuntu-latest
11
- steps:
12
- - name: Checkout
13
- uses: actions/checkout@v1
14
- - name: Setup Node.js
15
- uses: actions/setup-node@v1
16
- with:
17
- node-version: 20
18
- - name: Install dependencies
19
- run: npm ci
20
- - name: Test
21
- run: npm test
22
- - name: Release
23
- env:
24
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
26
- run: npx semantic-release