Lines 72-112javascript
72 manufacturer: opts.manufacturer,
73 version: opts.version ?? "0.1.0"
75 console.log(JSON.stringify(data, null, 2));
78* Loose shape check used to pick profile exports out of a module — full
79* validation happens in `buildRepo`, so a broken profile is reported as a
80* validation error instead of silently skipped here.
82function isProfileLike(value) {
83 return typeof value === "object" && value !== null && value.schemaVersion === 1 && typeof value.id === "string" && Array.isArray(value.metrics);
86* Collect profiles from one entry file: a `.json` file is a single serialized
87* profile; anything else is imported as a module and every export (including
88* array elements and `{ profile, description }` wrappers) that looks like a
91async function loadEntry(path) {
92 if (path.endsWith(".json")) return [{ profile: await readJson(path) }];
93 const mod = await import(pathToFileURL(resolve(path)).href);
94 const found = [];
MediumDynamic Require
Package source references dynamic require/import behavior.
dist/cli.mjsView on unpkg · L92 95 const taken = /* @__PURE__ */ new Set();
96 const visit = (value) => {
97 if (Array.isArray(value)) {
98 for (const item of value) visit(item);
101 if (typeof value !== "object" || value === null || taken.has(value)) return;
102 if (isProfileLike(value)) {
104 found.push({ profile: value });
107 const wrapper = value;
108 if (isProfileLike(wrapper.profile) && !taken.has(wrapper.profile)) {
109 taken.add(wrapper.profile);
111 profile: wrapper.profile,
112 description: wrapper.description