Lines 106-146javascript
106 manufacturer: opts.manufacturer,
107 version: opts.version ?? "0.1.0"
109 console.log(JSON.stringify(data, null, 2));
112* Loose shape check used to pick profile exports out of a module — full
113* validation happens in `buildRepo`, so a broken profile is reported as a
114* validation error instead of silently skipped here.
116function isProfileLike(value) {
117 return typeof value === "object" && value !== null && value.schemaVersion === 1 && typeof value.id === "string" && Array.isArray(value.metrics);
120* Collect profiles from one entry file: a `.json` file is a single serialized
121* profile; anything else is imported as a module and every export (including
122* array elements and `{ profile, description }` wrappers) that looks like a
125async function loadEntry(path) {
126 if (path.endsWith(".json")) return [{ profile: await readJson(path) }];
127 const mod = await import(pathToFileURL(resolve(path)).href);
128 const found = [];
MediumDynamic Require
Package source references dynamic require/import behavior.
dist/cli.mjsView on unpkg · L126 129 const taken = /* @__PURE__ */ new Set();
130 const visit = (value) => {
131 if (Array.isArray(value)) {
132 for (const item of value) visit(item);
135 if (typeof value !== "object" || value === null || taken.has(value)) return;
136 if (isProfileLike(value)) {
138 found.push({ profile: value });
141 const wrapper = value;
142 if (isProfileLike(wrapper.profile) && !taken.has(wrapper.profile)) {
143 taken.add(wrapper.profile);
145 profile: wrapper.profile,
146 description: wrapper.description