diff --git a/packages/publisher/src/calculate-versions.ts b/packages/publisher/src/calculate-versions.ts index cae44b0f19..2f250a85b1 100644 --- a/packages/publisher/src/calculate-versions.ts +++ b/packages/publisher/src/calculate-versions.ts @@ -4,7 +4,6 @@ import { ChangedPackages, ChangedPackagesJson, ChangedTypingJson, versionsFilena import { getDefinitelyTyped, AllPackages, NotNeededPackage, writeDataFile } from "@definitelytyped/definitions-parser"; import { assertDefined, - mapDefinedAsync, logUncaughtErrors, loggerWithErrors, FS, @@ -12,6 +11,7 @@ import { UncachedNpmInfoClient, withNpmCache, CachedNpmInfoClient, + nAtATime, } from "@definitelytyped/utils"; import { fetchTypesPackageVersionInfo } from "@definitelytyped/retag"; import { cacheDirPath } from "./lib/settings"; @@ -66,35 +66,39 @@ async function computeChangedPackages( client: CachedNpmInfoClient ): Promise { log.info("# Computing changed packages..."); - const changedTypings = await mapDefinedAsync(allPackages.allTypings(), async (pkg) => { - const { version, needsPublish } = await fetchTypesPackageVersionInfo(pkg, client, /*publish*/ true, log); - if (needsPublish) { - log.info(`Need to publish: ${pkg.desc}@${version}`); - for (const { name } of pkg.packageJsonDependencies) { + const changedTypings = ( + await nAtATime(10, allPackages.allTypings(), async (pkg) => { + const { version, needsPublish } = await fetchTypesPackageVersionInfo(pkg, client, /*publish*/ true, log); + if (needsPublish) { + log.info(`Need to publish: ${pkg.desc}@${version}`); + for (const { name } of pkg.packageJsonDependencies) { + assertDefined( + await client.fetchAndCacheNpmInfo(name), + `'${pkg.name}' depends on '${name}' which does not exist on npm. All dependencies must exist.` + ); + } + const latestVersion = pkg.isLatest + ? undefined + : (await fetchTypesPackageVersionInfo(allPackages.getLatest(pkg), client, /*publish*/ true)).version; + return { pkg, version, latestVersion }; + } + return undefined; + }) + ).filter((value): value is NonNullable => value as never); + log.info("# Computing deprecated packages..."); + const changedNotNeededPackages = ( + await nAtATime(10, allPackages.allNotNeeded(), async (pkg) => { + if (!(await isAlreadyDeprecated(pkg, client, log))) { assertDefined( - await client.fetchAndCacheNpmInfo(name), - `'${pkg.name}' depends on '${name}' which does not exist on npm. All dependencies must exist.` + await client.fetchAndCacheNpmInfo(pkg.libraryName), + `To deprecate '@types/${pkg.name}', '${pkg.libraryName}' must exist on npm.` ); + log.info(`To be deprecated: ${pkg.name}`); + return pkg; } - const latestVersion = pkg.isLatest - ? undefined - : (await fetchTypesPackageVersionInfo(allPackages.getLatest(pkg), client, /*publish*/ true)).version; - return { pkg, version, latestVersion }; - } - return undefined; - }); - log.info("# Computing deprecated packages..."); - const changedNotNeededPackages = await mapDefinedAsync(allPackages.allNotNeeded(), async (pkg) => { - if (!(await isAlreadyDeprecated(pkg, client, log))) { - assertDefined( - await client.fetchAndCacheNpmInfo(pkg.libraryName), - `To deprecate '@types/${pkg.name}', '${pkg.libraryName}' must exist on npm.` - ); - log.info(`To be deprecated: ${pkg.name}`); - return pkg; - } - return undefined; - }); + return undefined; + }) + ).filter((value): value is NonNullable => value as never); return { changedTypings, changedNotNeededPackages }; }