diff --git a/src/publish-registry.ts b/src/publish-registry.ts index 2d972ef0..17ce6c7c 100644 --- a/src/publish-registry.ts +++ b/src/publish-registry.ts @@ -3,18 +3,18 @@ import { emptyDir } from "fs-extra"; import * as yargs from "yargs"; import { Options } from "./lib/common"; -import NpmClient from "./lib/npm-client"; +import NpmClient, { fetchNpmInfo } from "./lib/npm-client"; import { AllPackages, NotNeededPackage, readNotNeededPackages, TypingsData } from "./lib/packages"; import { outputPath, validateOutputPath } from "./lib/settings"; import { fetchAndProcessNpmInfo } from "./lib/versions"; import { assertDirectoriesEqual, npmInstallFlags, readJson, sleep, writeFile, writeJson } from "./util/io"; import { logger, writeLog } from "./util/logging"; -import { computeHash, done, execAndThrowErrors, joinPaths } from "./util/util"; +import { computeHash, done, execAndThrowErrors, joinPaths, nAtATime } from "./util/util"; const packageName = "types-registry"; const registryOutputPath = joinPaths(outputPath, packageName); const readme = -`This package contains a listing of all packages published to the @types scope on NPM. + `This package contains a listing of all packages published to the @types scope on NPM. Generated by [types-publisher](https://github.com/Microsoft/types-publisher).`; if (!module.parent) { @@ -32,7 +32,7 @@ export default async function main(options: Options, dry: boolean): Promise): Registry { - const entries: { [packageName: string]: 1 } = {}; - for (const { name } of typings) { - entries[name] = 1; - } +interface Registry { readonly entries: { readonly [packageName: string]: { readonly [distTags: string]: string } }; } +async function generateRegistry(typings: ReadonlyArray): Promise { + const entries: { [packageName: string]: { [distTags: string]: string } } = {}; + await nAtATime(25, typings, async typing => { + const info = await fetchNpmInfo(typing.fullEscapedNpmName); + entries[typing.name] = info["dist-tags"]; + }); return { entries }; }