1
- import assert from "assert" ;
2
1
import { sourceBranch } from "./lib/settings" ;
3
2
import {
4
3
PackageId ,
@@ -20,7 +19,6 @@ import {
20
19
cacheDir ,
21
20
} from "@definitelytyped/utils" ;
22
21
import * as pacote from "pacote" ;
23
- import * as semver from "semver" ;
24
22
import { getAffectedPackages } from "./get-affected-packages" ;
25
23
26
24
export interface GitDiff {
@@ -127,10 +125,14 @@ export async function getAffectedPackagesFromDiff(
127
125
128
126
/**
129
127
* 1. libraryName must exist on npm (SKIPPED and preferably/optionally have been the libraryName in just-deleted header)
130
- * 2. asOfVersion must be newer than `@types/name@latest` on npm
131
- * 3. `name@asOfVersion` must exist on npm
128
+ * 2. `name@asOfVersion` must exist on npm
132
129
*/
133
130
export async function checkNotNeededPackage ( unneeded : NotNeededPackage ) {
131
+ await pacote . manifest ( unneeded . fullNpmName , { cache : cacheDir } ) . catch ( ( reason ) => {
132
+ throw reason . code === "E404"
133
+ ? new Error ( `Unexpected error: @types package not found for ${ unneeded . fullNpmName } ` , { cause : reason } )
134
+ : reason ;
135
+ } ) ; // eg @types /babel__parser
134
136
await pacote . manifest ( `${ unneeded . libraryName } @${ unneeded . version } ` , { cache : cacheDir } ) . catch ( ( reason ) => {
135
137
throw reason . code === "E404"
136
138
? new Error (
@@ -145,16 +147,6 @@ Unneeded packages have to be replaced with a package on npm.`,
145
147
} )
146
148
: reason ;
147
149
} ) ; // eg @babel /parser
148
- const typings = await pacote . manifest ( unneeded . fullNpmName , { cache : cacheDir } ) . catch ( ( reason ) => {
149
- throw reason . code === "E404"
150
- ? new Error ( `Unexpected error: @types package not found for ${ unneeded . fullNpmName } ` , { cause : reason } )
151
- : reason ;
152
- } ) ; // eg @types /babel__parser
153
- assert (
154
- semver . gt ( unneeded . version , typings . version ) ,
155
- `The specified version ${ unneeded . version } of ${ unneeded . libraryName } must be newer than the version
156
- it is supposed to replace, ${ typings . version } of ${ unneeded . fullNpmName } .`
157
- ) ;
158
150
}
159
151
160
152
/**
0 commit comments