Skip to content
This repository was archived by the owner on Jun 11, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/publish-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -32,7 +32,7 @@ export default async function main(options: Options, dry: boolean): Promise<void

// Don't include not-needed packages in the registry.
const typings = await AllPackages.readTypings();
const registry = JSON.stringify(generateRegistry(typings), undefined, 4);
const registry = JSON.stringify(await generateRegistry(typings), undefined, 4);
const newContentHash = computeHash(registry);

assert.equal(oldVersion.major, 0);
Expand Down Expand Up @@ -152,11 +152,12 @@ function generatePackageJson(version: string, typesPublisherContentHash: string)
};
}

interface Registry { readonly entries: { readonly [packageName: string]: 1 }; }
function generateRegistry(typings: ReadonlyArray<TypingsData>): 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<TypingsData>): Promise<Registry> {
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 };
}