synthesisui 0.16.37 → 0.16.38
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/commands/import.js +23 -7
- package/package.json +1 -1
package/dist/commands/import.js
CHANGED
|
@@ -99,17 +99,27 @@ async function detectStack(root) {
|
|
|
99
99
|
stack.push("plain css");
|
|
100
100
|
return stack;
|
|
101
101
|
}
|
|
102
|
-
/**
|
|
103
|
-
*
|
|
104
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Their own vocabulary, read from stylesheets - the same harvest the doctor runs
|
|
104
|
+
* when nothing of ours is installed.
|
|
105
|
+
*
|
|
106
|
+
* Returns the TABLE, not just the names, because the scan needs it. The first
|
|
107
|
+
* version harvested the names for the payload and then scanned with an EMPTY
|
|
108
|
+
* table, which made the census blind in a way a real app exposed (dono, 30/07):
|
|
109
|
+
* a project with 2416 uses of its own `var(--dashboard-*)` reported
|
|
110
|
+
* `tokenUses: 0`, `coverage: 0`, and `token: null` on every single value. The
|
|
111
|
+
* sharpest sentence the doctor knows - "your own system already has a name for
|
|
112
|
+
* this" - could not be said, and we ended up rediscovering by colour distance
|
|
113
|
+
* what their stylesheet had spelled out all along.
|
|
114
|
+
*/
|
|
115
|
+
async function harvestOwnTable(root) {
|
|
105
116
|
let css = "";
|
|
106
117
|
for await (const file of walkAll([root])) {
|
|
107
118
|
if (!/\.(css|scss|sass|less)$/i.test(file))
|
|
108
119
|
continue;
|
|
109
120
|
css += `\n${await readFile(file, "utf8").catch(() => "")}`;
|
|
110
121
|
}
|
|
111
|
-
|
|
112
|
-
return Object.fromEntries(table.byName);
|
|
122
|
+
return buildTable({ css, source: "yours" });
|
|
113
123
|
}
|
|
114
124
|
/**
|
|
115
125
|
* EVERY distinct design value, commonest first - not just the repeated ones.
|
|
@@ -202,7 +212,7 @@ function distinctValues(d) {
|
|
|
202
212
|
return kept.sort((a, b) => b.count - a.count || a.value.localeCompare(b.value));
|
|
203
213
|
}
|
|
204
214
|
export async function takeCensus(root) {
|
|
205
|
-
const table =
|
|
215
|
+
const table = await harvestOwnTable(root);
|
|
206
216
|
const reports = [];
|
|
207
217
|
for await (const file of walk(root)) {
|
|
208
218
|
const src = await readFile(file, "utf8").catch(() => "");
|
|
@@ -224,7 +234,7 @@ export async function takeCensus(root) {
|
|
|
224
234
|
return {
|
|
225
235
|
census: 1,
|
|
226
236
|
project: { name, stack: await detectStack(root) },
|
|
227
|
-
declared:
|
|
237
|
+
declared: Object.fromEntries(table.byName),
|
|
228
238
|
observed: distinctValues(d),
|
|
229
239
|
totals: {
|
|
230
240
|
scanned: d.scanned,
|
|
@@ -251,6 +261,12 @@ function summarize(c) {
|
|
|
251
261
|
if (Object.keys(c.declared).length > 0) {
|
|
252
262
|
console.log(body(`${Object.keys(c.declared).length} tokens you already declare - your names travel unchanged`));
|
|
253
263
|
}
|
|
264
|
+
// The sharpest number in the report, and it only became sayable once the scan
|
|
265
|
+
// started using their own token table: not "you have drift" but "you have
|
|
266
|
+
// drift your own system already solved".
|
|
267
|
+
if (c.totals.named > 0) {
|
|
268
|
+
console.log(body(`${paint.strong(String(c.totals.named))} of those values ALREADY have a name in your system - ${c.totals.coverage}% of your design values come from it today`));
|
|
269
|
+
}
|
|
254
270
|
const top = c.observed.slice(0, 5);
|
|
255
271
|
if (top.length > 0) {
|
|
256
272
|
console.log("");
|
package/package.json
CHANGED