@vellira-ui/tokens 2.123.3 → 2.123.5
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,16 @@
|
|
|
1
|
+
/** Validate historical, generated, maintained and filesystem evidence together. */
|
|
2
|
+
export type ComponentFactoryInventoryEntry = {
|
|
3
|
+
name: string;
|
|
4
|
+
source: string;
|
|
5
|
+
};
|
|
6
|
+
export type ComponentFactoryInventoryInput = {
|
|
7
|
+
historicalNames: readonly string[];
|
|
8
|
+
generated: readonly ComponentFactoryInventoryEntry[];
|
|
9
|
+
maintained: readonly ComponentFactoryInventoryEntry[];
|
|
10
|
+
files: readonly {
|
|
11
|
+
name: string;
|
|
12
|
+
regularFile: boolean;
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
15
|
+
export declare function validateComponentFactoryInventory({ historicalNames, generated, maintained, files, }: ComponentFactoryInventoryInput): readonly string[];
|
|
16
|
+
//# sourceMappingURL=component-token-factory-inventory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-token-factory-inventory.d.ts","sourceRoot":"","sources":["../src/component-token-factory-inventory.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,SAAS,EAAE,SAAS,8BAA8B,EAAE,CAAC;IACrD,UAAU,EAAE,SAAS,8BAA8B,EAAE,CAAC;IACtD,KAAK,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CAC1D,CAAC;AAIF,wBAAgB,iCAAiC,CAAC,EAChD,eAAe,EACf,SAAS,EACT,UAAU,EACV,KAAK,GACN,EAAE,8BAA8B,GAAG,SAAS,MAAM,EAAE,CA2DpD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const sourceDirectory = 'packages/tokens/src/factories/components';
|
|
2
|
+
export function validateComponentFactoryInventory({ historicalNames, generated, maintained, files, }) {
|
|
3
|
+
const findings = [];
|
|
4
|
+
const expected = [
|
|
5
|
+
...historicalNames.map((name) => ({
|
|
6
|
+
name,
|
|
7
|
+
source: `${sourceDirectory}/${name}.ts`,
|
|
8
|
+
})),
|
|
9
|
+
...generated,
|
|
10
|
+
];
|
|
11
|
+
for (const [label, entries] of [
|
|
12
|
+
['authority', expected],
|
|
13
|
+
['maintained', maintained],
|
|
14
|
+
]) {
|
|
15
|
+
const names = new Set();
|
|
16
|
+
const sources = new Set();
|
|
17
|
+
for (const { name, source } of entries) {
|
|
18
|
+
if (!/^create[A-Z][A-Za-z0-9]*Tokens$/.test(name) ||
|
|
19
|
+
name.includes('Palette')) {
|
|
20
|
+
findings.push(`${label}: invalid factory name ${name}`);
|
|
21
|
+
}
|
|
22
|
+
if (source !== `${sourceDirectory}/${name}.ts`) {
|
|
23
|
+
findings.push(`${label}: noncanonical source for ${name}`);
|
|
24
|
+
}
|
|
25
|
+
if (names.has(name))
|
|
26
|
+
findings.push(`${label}: duplicate name ${name}`);
|
|
27
|
+
if (sources.has(source)) {
|
|
28
|
+
findings.push(`${label}: duplicate source ${source}`);
|
|
29
|
+
}
|
|
30
|
+
names.add(name);
|
|
31
|
+
sources.add(source);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const signatures = (entries) => entries.map(({ name, source }) => JSON.stringify([name, source])).sort();
|
|
35
|
+
if (JSON.stringify(signatures(expected)) !==
|
|
36
|
+
JSON.stringify(signatures(maintained))) {
|
|
37
|
+
findings.push('maintained inventory differs from authority');
|
|
38
|
+
}
|
|
39
|
+
for (const file of files) {
|
|
40
|
+
if (!file.regularFile) {
|
|
41
|
+
findings.push(`factory entry is not a regular file: ${file.name}`);
|
|
42
|
+
}
|
|
43
|
+
if (!file.name.endsWith('.ts')) {
|
|
44
|
+
findings.push(`unexpected factory entry: ${file.name}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const expectedFiles = expected.map(({ name }) => `${name}.ts`).sort();
|
|
48
|
+
const observedFiles = files.map(({ name }) => name).sort();
|
|
49
|
+
if (JSON.stringify(expectedFiles) !== JSON.stringify(observedFiles)) {
|
|
50
|
+
findings.push('factory files differ from authority');
|
|
51
|
+
}
|
|
52
|
+
return findings;
|
|
53
|
+
}
|