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