@d1vij/jassm 0.1.18 → 0.1.19-beta.1
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/index.d.ts +11 -1
- package/dist/index.js +46 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ type GlobResult<T> = Record<string, T>;
|
|
|
56
56
|
* Removes `.mdx` extension from a path
|
|
57
57
|
*/
|
|
58
58
|
type StripExtension<T extends string> = T extends `${infer Rest}.mdx` ? Rest : T;
|
|
59
|
+
type ResolveEmptyVirtual<Virtual extends string> = Virtual extends "/" ? "" : Virtual;
|
|
59
60
|
/**
|
|
60
61
|
* Derives the route keys produced by the registry and
|
|
61
62
|
* replace filesystem root with a virtual route prefix
|
|
@@ -72,7 +73,7 @@ type RouteKey<
|
|
|
72
73
|
Modules extends Record<string, unknown>,
|
|
73
74
|
Root extends string,
|
|
74
75
|
Virtual extends string
|
|
75
|
-
> = keyof { [K in keyof Modules as K extends `${string}${Root}/${infer Rest}.mdx` ? `${Virtual}/${Rest}` : never] : true } & string;
|
|
76
|
+
> = keyof { [K in keyof Modules as K extends `${string}${Root}/${infer Rest}.mdx` ? `${ResolveEmptyVirtual<Virtual>}/${Rest}` : never] : true } & string;
|
|
76
77
|
/**
|
|
77
78
|
* Options passed to {@link generateRegistry}
|
|
78
79
|
*/
|
|
@@ -131,6 +132,7 @@ declare function generateRegistry<
|
|
|
131
132
|
*/
|
|
132
133
|
exports: Record<RouteKey<Modules, Root, Virtual>, Promise<Record<string, unknown>>>;
|
|
133
134
|
};
|
|
135
|
+
type Diffs = { [K in `inComponentsButNotIn${"Exports" | "Metadata"}` | `in${"Metadata" | "Exports"}ButNotInComponents`] : string[] | undefined };
|
|
134
136
|
/**
|
|
135
137
|
* Base class for all registry implementations.
|
|
136
138
|
*
|
|
@@ -161,6 +163,14 @@ declare abstract class AbstractRegistry<
|
|
|
161
163
|
* Metadata registry
|
|
162
164
|
*/
|
|
163
165
|
abstract readonly metadata: Metadata;
|
|
166
|
+
/**
|
|
167
|
+
* Compare keys of all registries in to check consistency.
|
|
168
|
+
* @returns `null` if all keys are consistent.
|
|
169
|
+
*/
|
|
170
|
+
diffKeys(): null | {
|
|
171
|
+
error: Error;
|
|
172
|
+
diffs: Diffs;
|
|
173
|
+
};
|
|
164
174
|
private get;
|
|
165
175
|
/**
|
|
166
176
|
* Retrieve a React component by route key
|
package/dist/index.js
CHANGED
|
@@ -516,7 +516,6 @@ function generateRegistry({
|
|
|
516
516
|
const _components = [];
|
|
517
517
|
const _exports = [];
|
|
518
518
|
const _metadata = [];
|
|
519
|
-
console.log(metadataGlob);
|
|
520
519
|
for (const path of paths) {
|
|
521
520
|
const route = path.replace(root, virtual).replace(".mdx", "");
|
|
522
521
|
const loader = modulesGlob[path];
|
|
@@ -536,6 +535,52 @@ function generateRegistry({
|
|
|
536
535
|
}
|
|
537
536
|
|
|
538
537
|
class AbstractRegistry {
|
|
538
|
+
diffKeys() {
|
|
539
|
+
const keySet = new Set(this.keys);
|
|
540
|
+
const exportsSet = new Set(Object.keys(this.exports));
|
|
541
|
+
const metadataSet = new Set(Object.keys(this.metadata));
|
|
542
|
+
const exportsDiff = keySet.symmetricDifference(exportsSet);
|
|
543
|
+
const metadataDiff = keySet.symmetricDifference(metadataSet);
|
|
544
|
+
const errMsg = [];
|
|
545
|
+
const diffs = {
|
|
546
|
+
inComponentsButNotInExports: undefined,
|
|
547
|
+
inComponentsButNotInMetadata: undefined,
|
|
548
|
+
inExportsButNotInComponents: undefined,
|
|
549
|
+
inMetadataButNotInComponents: undefined
|
|
550
|
+
};
|
|
551
|
+
if (exportsDiff.size !== 0) {
|
|
552
|
+
diffs.inComponentsButNotInExports = Array.from(keySet.difference(exportsSet));
|
|
553
|
+
diffs.inExportsButNotInComponents = Array.from(exportsSet.difference(keySet));
|
|
554
|
+
errMsg.push(`Exports Registry and Component Registry have ${exportsDiff.size} key mismatches.
|
|
555
|
+
Keys which are present in Component map but not in Exports
|
|
556
|
+
${diffs.inComponentsButNotInExports.join(`
|
|
557
|
+
`)}
|
|
558
|
+
and the keys present in Exports but not in component map are
|
|
559
|
+
${diffs.inExportsButNotInComponents.join(`
|
|
560
|
+
`)}
|
|
561
|
+
`);
|
|
562
|
+
}
|
|
563
|
+
if (metadataDiff.size !== 0) {
|
|
564
|
+
diffs.inComponentsButNotInMetadata = Array.from(keySet.difference(metadataSet));
|
|
565
|
+
diffs.inMetadataButNotInComponents = Array.from(metadataDiff.difference(keySet));
|
|
566
|
+
errMsg.push(`Metadata Registry and Component Registry have ${metadataDiff.size} key mismatches.
|
|
567
|
+
Keys which are present in Component map but not in Metadata
|
|
568
|
+
${diffs.inComponentsButNotInMetadata.join(`
|
|
569
|
+
`)}
|
|
570
|
+
and the keys present in Metadata but not in Component map are
|
|
571
|
+
${diffs.inMetadataButNotInComponents.join(`
|
|
572
|
+
`)}
|
|
573
|
+
`);
|
|
574
|
+
}
|
|
575
|
+
if (errMsg.length === 0)
|
|
576
|
+
return null;
|
|
577
|
+
return {
|
|
578
|
+
diffs,
|
|
579
|
+
error: new Error(errMsg.join(`
|
|
580
|
+
|
|
581
|
+
`))
|
|
582
|
+
};
|
|
583
|
+
}
|
|
539
584
|
get(_from, key) {
|
|
540
585
|
const value = _from[key];
|
|
541
586
|
if (!value) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d1vij/jassm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19-beta.1",
|
|
4
4
|
"description": "Just another static site maker. Create simple content driven sites using MDX and React along with Typescript safety.",
|
|
5
5
|
"homepage": "https://github.com/d1vij/jassm",
|
|
6
6
|
"license": "MIT",
|