@dialpad/dialtone 6.36.2 → 6.37.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.
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/* Will search the files in the provided directory for any properties that are not set to dialtone values.
|
|
4
|
+
It does this by simply checking whether the property is set to a less @variable or CSS var such as var(--val).
|
|
5
|
+
It does not compare to an actual list of dialtone token values so it is not perfect, and sometimes gives false
|
|
6
|
+
positives. This will however give a pretty good idea of where dialtone values aren't being used that should.
|
|
7
|
+
|
|
8
|
+
Searches some key properties by default as shown in the defaultSearch array below. You are however not limited to
|
|
9
|
+
this, you can make this application search any css property you wish. See the below options or run this application
|
|
10
|
+
with the -h switch for more details. */
|
|
11
|
+
|
|
12
|
+
const path = require('path');
|
|
13
|
+
const fs = require('fs');
|
|
14
|
+
const { docopt } = require('docopt');
|
|
15
|
+
const { exit } = require('process');
|
|
16
|
+
|
|
17
|
+
const doc = `
|
|
18
|
+
Usage:
|
|
19
|
+
./dialtone_health_check <path> [options]
|
|
20
|
+
|
|
21
|
+
Options:
|
|
22
|
+
<path> The directory to recursively search all files in.
|
|
23
|
+
-h --help Show this screen.
|
|
24
|
+
-p --property=<property> CSS Property to search. Default properties if this is not set:
|
|
25
|
+
color,background-color,border-color,font-family
|
|
26
|
+
--ext=<ext> Filter by file extension. comma separate to filter multiple. ex: js,vue
|
|
27
|
+
--no-line-numbers Only output files and their total count, do not output individual instances and their line
|
|
28
|
+
number.
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
const options = docopt(doc);
|
|
32
|
+
|
|
33
|
+
const defaultSearch = [
|
|
34
|
+
'color',
|
|
35
|
+
'background-color',
|
|
36
|
+
'border-color',
|
|
37
|
+
'font-family',
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const extensionFilters = options['--ext']?.split(',') ?? [''];
|
|
41
|
+
let properties = options['--property']?.split(',');
|
|
42
|
+
if (!properties) properties = defaultSearch;
|
|
43
|
+
|
|
44
|
+
function fromDir (startPath, fileExtension) {
|
|
45
|
+
if (!fs.existsSync(startPath)) {
|
|
46
|
+
console.error('Directory not found');
|
|
47
|
+
exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const results = [];
|
|
51
|
+
const files = fs.readdirSync(startPath);
|
|
52
|
+
for (let i = 0; i < files.length; i++) {
|
|
53
|
+
const filename = path.join(startPath, files[i]);
|
|
54
|
+
const stat = fs.lstatSync(filename);
|
|
55
|
+
if (stat.isDirectory()) {
|
|
56
|
+
results.push(...fromDir(filename, fileExtension)); // recurse
|
|
57
|
+
} else if (filename.endsWith(fileExtension)) {
|
|
58
|
+
results.push(filename);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return results;
|
|
62
|
+
}
|
|
63
|
+
const files = [];
|
|
64
|
+
extensionFilters.forEach(extension => {
|
|
65
|
+
files.push(...fromDir(options['<path>'], extension));
|
|
66
|
+
});
|
|
67
|
+
if (files.length <= 0) { console.error('No files found in directory'); exit(1); }
|
|
68
|
+
|
|
69
|
+
const regex = properties.map(property => {
|
|
70
|
+
return new RegExp(`^\\s*${property}:\\s(?:(?!var\\(--))(?:(?!@)).*`, 'gm');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
let totalCount = 0;
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
for (const file of files) {
|
|
77
|
+
const data = fs.readFileSync(file, 'utf8');
|
|
78
|
+
const lines = data.split('\n');
|
|
79
|
+
let match;
|
|
80
|
+
let matchCount = 0;
|
|
81
|
+
for (const [lineNumber, line] of lines.entries()) {
|
|
82
|
+
regex.forEach(re => {
|
|
83
|
+
// eslint-disable-next-line no-cond-assign
|
|
84
|
+
while (match = re.exec(line)) {
|
|
85
|
+
if (!options['--no-line-numbers']) {
|
|
86
|
+
console.log(`\tnon-dialtone property found on line ${lineNumber}: ${match}`);
|
|
87
|
+
}
|
|
88
|
+
matchCount++;
|
|
89
|
+
totalCount++;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (matchCount > 0) {
|
|
94
|
+
console.log(`${file}: ${matchCount}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
console.log(`Found ${totalCount} total ${properties.join(', ')} \
|
|
98
|
+
CSS properties that are not dialtone in this directory.`);
|
|
99
|
+
} catch (err) {
|
|
100
|
+
console.error(err);
|
|
101
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/* Will search the files in the provided directory for any properties that are not set to dialtone values.
|
|
4
|
+
It does this by simply checking whether the property is set to a less @variable or CSS var such as var(--val).
|
|
5
|
+
It does not compare to an actual list of dialtone token values so it is not perfect, and sometimes gives false
|
|
6
|
+
positives. This will however give a pretty good idea of where dialtone values aren't being used that should.
|
|
7
|
+
|
|
8
|
+
Searches some key properties by default as shown in the defaultSearch array below. You are however not limited to
|
|
9
|
+
this, you can make this application search any css property you wish. See the below options or run this application
|
|
10
|
+
with the -h switch for more details. */
|
|
11
|
+
|
|
12
|
+
const path = require('path');
|
|
13
|
+
const fs = require('fs');
|
|
14
|
+
const { docopt } = require('docopt');
|
|
15
|
+
const { exit } = require('process');
|
|
16
|
+
|
|
17
|
+
const doc = `
|
|
18
|
+
Usage:
|
|
19
|
+
./dialtone_health_check <path> [options]
|
|
20
|
+
|
|
21
|
+
Options:
|
|
22
|
+
<path> The directory to recursively search all files in.
|
|
23
|
+
-h --help Show this screen.
|
|
24
|
+
-p --property=<property> CSS Property to search. Default properties if this is not set:
|
|
25
|
+
color,background-color,border-color,font-family
|
|
26
|
+
--ext=<ext> Filter by file extension. comma separate to filter multiple. ex: js,vue
|
|
27
|
+
--no-line-numbers Only output files and their total count, do not output individual instances and their line
|
|
28
|
+
number.
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
const options = docopt(doc);
|
|
32
|
+
|
|
33
|
+
const defaultSearch = [
|
|
34
|
+
'color',
|
|
35
|
+
'background-color',
|
|
36
|
+
'border-color',
|
|
37
|
+
'font-family',
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const extensionFilters = options['--ext']?.split(',') ?? [''];
|
|
41
|
+
let properties = options['--property']?.split(',');
|
|
42
|
+
if (!properties) properties = defaultSearch;
|
|
43
|
+
|
|
44
|
+
function fromDir (startPath, fileExtension) {
|
|
45
|
+
if (!fs.existsSync(startPath)) {
|
|
46
|
+
console.error('Directory not found');
|
|
47
|
+
exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const results = [];
|
|
51
|
+
const files = fs.readdirSync(startPath);
|
|
52
|
+
for (let i = 0; i < files.length; i++) {
|
|
53
|
+
const filename = path.join(startPath, files[i]);
|
|
54
|
+
const stat = fs.lstatSync(filename);
|
|
55
|
+
if (stat.isDirectory()) {
|
|
56
|
+
results.push(...fromDir(filename, fileExtension)); // recurse
|
|
57
|
+
} else if (filename.endsWith(fileExtension)) {
|
|
58
|
+
results.push(filename);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return results;
|
|
62
|
+
}
|
|
63
|
+
const files = [];
|
|
64
|
+
extensionFilters.forEach(extension => {
|
|
65
|
+
files.push(...fromDir(options['<path>'], extension));
|
|
66
|
+
});
|
|
67
|
+
if (files.length <= 0) { console.error('No files found in directory'); exit(1); }
|
|
68
|
+
|
|
69
|
+
const regex = properties.map(property => {
|
|
70
|
+
return new RegExp(`^\\s*${property}:\\s(?:(?!var\\(--))(?:(?!@)).*`, 'gm');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
let totalCount = 0;
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
for (const file of files) {
|
|
77
|
+
const data = fs.readFileSync(file, 'utf8');
|
|
78
|
+
const lines = data.split('\n');
|
|
79
|
+
let match;
|
|
80
|
+
let matchCount = 0;
|
|
81
|
+
for (const [lineNumber, line] of lines.entries()) {
|
|
82
|
+
regex.forEach(re => {
|
|
83
|
+
// eslint-disable-next-line no-cond-assign
|
|
84
|
+
while (match = re.exec(line)) {
|
|
85
|
+
if (!options['--no-line-numbers']) {
|
|
86
|
+
console.log(`\tnon-dialtone property found on line ${lineNumber}: ${match}`);
|
|
87
|
+
}
|
|
88
|
+
matchCount++;
|
|
89
|
+
totalCount++;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (matchCount > 0) {
|
|
94
|
+
console.log(`${file}: ${matchCount}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
console.log(`Found ${totalCount} total ${properties.join(', ')} \
|
|
98
|
+
CSS properties that are not dialtone in this directory.`);
|
|
99
|
+
} catch (err) {
|
|
100
|
+
console.error(err);
|
|
101
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dialpad/dialtone",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.37.0",
|
|
4
4
|
"description": "The design system for Dialpad and UberConference",
|
|
5
5
|
"author": "Joshua Hynes",
|
|
6
6
|
"scripts": {
|
|
@@ -21,13 +21,17 @@
|
|
|
21
21
|
"start": "gulp watch",
|
|
22
22
|
"stylelint": "npx stylelint 'lib/build/less/**/*.{less,css}'"
|
|
23
23
|
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"dialtone-health-check": "dist/js/dialtone_health_check.js"
|
|
26
|
+
},
|
|
24
27
|
"unpkg": "dist/css/dialtone.min.css",
|
|
25
28
|
"files": [
|
|
26
29
|
"lib",
|
|
27
30
|
"dist"
|
|
28
31
|
],
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"@docsearch/js": "^3.0.0"
|
|
33
|
+
"@docsearch/js": "^3.0.0",
|
|
34
|
+
"docopt": "^0.6.2"
|
|
31
35
|
},
|
|
32
36
|
"devDependencies": {
|
|
33
37
|
"@commitlint/cli": "^15.0.0",
|