|
1 | 1 | import { defaultLocalOptions } from "./lib/common";
|
2 | 2 | import { ChangedPackages, ChangedPackagesJson, ChangedTypingJson, versionsFilename } from "./lib/versions";
|
3 | 3 | import { getDefinitelyTyped, AllPackages, NotNeededPackage, writeDataFile } from "@definitelytyped/definitions-parser";
|
4 |
| -import { |
5 |
| - mapDefinedAsync, |
6 |
| - logUncaughtErrors, |
7 |
| - loggerWithErrors, |
8 |
| - FS, |
9 |
| - LoggerWithErrors, |
10 |
| - defaultCacheDir, |
11 |
| -} from "@definitelytyped/utils"; |
| 4 | +import { logUncaughtErrors, loggerWithErrors, FS, LoggerWithErrors, defaultCacheDir } from "@definitelytyped/utils"; |
12 | 5 | import { fetchTypesPackageVersionInfo } from "@definitelytyped/retag";
|
13 | 6 | import * as pacote from "pacote";
|
14 | 7 |
|
@@ -41,40 +34,48 @@ async function computeAndSaveChangedPackages(
|
41 | 34 |
|
42 | 35 | async function computeChangedPackages(allPackages: AllPackages, log: LoggerWithErrors): Promise<ChangedPackages> {
|
43 | 36 | log.info("# Computing changed packages...");
|
44 |
| - const changedTypings = await mapDefinedAsync(allPackages.allTypings(), async (pkg) => { |
45 |
| - const { version, needsPublish } = await fetchTypesPackageVersionInfo(pkg, /*publish*/ true, log); |
46 |
| - if (needsPublish) { |
47 |
| - log.info(`Need to publish: ${pkg.desc}@${version}`); |
48 |
| - for (const { name } of pkg.packageJsonDependencies) { |
49 |
| - await pacote.manifest(name, { cache: defaultCacheDir }).catch((cause) => { |
50 |
| - throw cause.code === "E404" |
51 |
| - ? new Error( |
52 |
| - `'${pkg.name}' depends on '${name}' which does not exist on npm. All dependencies must exist.`, |
53 |
| - { cause } |
54 |
| - ) |
55 |
| - : cause; |
56 |
| - }); |
57 |
| - } |
58 |
| - const latestVersion = pkg.isLatest |
59 |
| - ? undefined |
60 |
| - : (await fetchTypesPackageVersionInfo(allPackages.getLatest(pkg), /*publish*/ true)).version; |
61 |
| - return { pkg, version, latestVersion }; |
62 |
| - } |
63 |
| - return undefined; |
64 |
| - }); |
| 37 | + const changedTypings = ( |
| 38 | + await Promise.all( |
| 39 | + allPackages.allTypings().map(async (pkg) => { |
| 40 | + const { version, needsPublish } = await fetchTypesPackageVersionInfo(pkg, /*publish*/ true, log); |
| 41 | + if (needsPublish) { |
| 42 | + log.info(`Need to publish: ${pkg.desc}@${version}`); |
| 43 | + for (const { name } of pkg.packageJsonDependencies) { |
| 44 | + await pacote.manifest(name, { cache: defaultCacheDir }).catch((cause) => { |
| 45 | + throw cause.code === "E404" |
| 46 | + ? new Error( |
| 47 | + `'${pkg.name}' depends on '${name}' which does not exist on npm. All dependencies must exist.`, |
| 48 | + { cause } |
| 49 | + ) |
| 50 | + : cause; |
| 51 | + }); |
| 52 | + } |
| 53 | + const latestVersion = pkg.isLatest |
| 54 | + ? undefined |
| 55 | + : (await fetchTypesPackageVersionInfo(allPackages.getLatest(pkg), /*publish*/ true)).version; |
| 56 | + return { pkg, version, latestVersion }; |
| 57 | + } |
| 58 | + return undefined; |
| 59 | + }) |
| 60 | + ) |
| 61 | + ).filter((value): value is NonNullable<typeof value> => value as never); |
65 | 62 | log.info("# Computing deprecated packages...");
|
66 |
| - const changedNotNeededPackages = await mapDefinedAsync(allPackages.allNotNeeded(), async (pkg) => { |
67 |
| - if (!(await isAlreadyDeprecated(pkg, log))) { |
68 |
| - await pacote.manifest(pkg.libraryName, { cache: defaultCacheDir }).catch((cause) => { |
69 |
| - throw cause.code === "E404" |
70 |
| - ? new Error(`To deprecate '@types/${pkg.name}', '${pkg.libraryName}' must exist on npm.`, { cause }) |
71 |
| - : cause; |
72 |
| - }); |
73 |
| - log.info(`To be deprecated: ${pkg.name}`); |
74 |
| - return pkg; |
75 |
| - } |
76 |
| - return undefined; |
77 |
| - }); |
| 63 | + const changedNotNeededPackages = ( |
| 64 | + await Promise.all( |
| 65 | + allPackages.allNotNeeded().map(async (pkg) => { |
| 66 | + if (!(await isAlreadyDeprecated(pkg, log))) { |
| 67 | + await pacote.manifest(pkg.libraryName, { cache: defaultCacheDir }).catch((cause) => { |
| 68 | + throw cause.code === "E404" |
| 69 | + ? new Error(`To deprecate '@types/${pkg.name}', '${pkg.libraryName}' must exist on npm.`, { cause }) |
| 70 | + : cause; |
| 71 | + }); |
| 72 | + log.info(`To be deprecated: ${pkg.name}`); |
| 73 | + return pkg; |
| 74 | + } |
| 75 | + return undefined; |
| 76 | + }) |
| 77 | + ) |
| 78 | + ).filter((value): value is NonNullable<typeof value> => value as never); |
78 | 79 | return { changedTypings, changedNotNeededPackages };
|
79 | 80 | }
|
80 | 81 |
|
|
0 commit comments