@adonisjs/content 1.4.0 → 1.5.0
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/build/src/loaders/main.js +18 -10
- package/build/src/types.d.ts +7 -4
- package/package.json +1 -1
|
@@ -100,21 +100,29 @@ var OssStatsLoader = class {
|
|
|
100
100
|
* ```
|
|
101
101
|
*/
|
|
102
102
|
async #fetchStats() {
|
|
103
|
-
|
|
104
|
-
let totalInstalls = 0;
|
|
103
|
+
const aggregates = [];
|
|
105
104
|
for (const source of this.#options.sources) {
|
|
106
|
-
if (source
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
if (typeof source === "function") {
|
|
106
|
+
aggregates.push(await source());
|
|
107
|
+
} else if (source.type === "github") {
|
|
108
|
+
aggregates.push({
|
|
109
|
+
key: "stars",
|
|
110
|
+
count: await aggregateStars({
|
|
111
|
+
org: source.org,
|
|
112
|
+
ghToken: source.ghToken
|
|
113
|
+
})
|
|
110
114
|
});
|
|
111
|
-
totalStars += stars;
|
|
112
115
|
} else if (source.type === "npm") {
|
|
113
|
-
|
|
114
|
-
|
|
116
|
+
aggregates.push({
|
|
117
|
+
key: "installs",
|
|
118
|
+
count: await aggregateInstalls(source.packages)
|
|
119
|
+
});
|
|
115
120
|
}
|
|
116
121
|
}
|
|
117
|
-
return {
|
|
122
|
+
return aggregates.reduce((result, { key, count }) => {
|
|
123
|
+
result[key] = count;
|
|
124
|
+
return result;
|
|
125
|
+
}, {});
|
|
118
126
|
}
|
|
119
127
|
/**
|
|
120
128
|
* Loads and validates OSS statistics data.
|
package/build/src/types.d.ts
CHANGED
|
@@ -294,11 +294,14 @@ export type OssStatsOptions = {
|
|
|
294
294
|
/** Source type: npm package download statistics */
|
|
295
295
|
type: 'npm';
|
|
296
296
|
/** Array of npm packages with their tracking start dates */
|
|
297
|
-
packages:
|
|
297
|
+
packages: {
|
|
298
298
|
name: string;
|
|
299
299
|
startDate: string;
|
|
300
|
-
}];
|
|
301
|
-
})
|
|
300
|
+
}[];
|
|
301
|
+
} | (() => Promise<{
|
|
302
|
+
key: string;
|
|
303
|
+
count: number;
|
|
304
|
+
}>))[];
|
|
302
305
|
};
|
|
303
306
|
/**
|
|
304
307
|
* Type representing the aggregated open source statistics
|
|
@@ -308,7 +311,7 @@ export type OssStats = {
|
|
|
308
311
|
stars: number;
|
|
309
312
|
/** Total npm package downloads across all sources */
|
|
310
313
|
installs: number;
|
|
311
|
-
}
|
|
314
|
+
} & Record<string, number>;
|
|
312
315
|
/**
|
|
313
316
|
* Represents a GitHub contributor with their profile information and contribution count.
|
|
314
317
|
* This matches the shape returned by GitHub REST API /contributors endpoint.
|