1
1
import applicationinsights = require( "applicationinsights" ) ;
2
- import search = require( "libnpmsearch" ) ;
3
- import { graphql } from "@octokit/graphql" ;
4
2
import * as yargs from "yargs" ;
5
3
6
4
import { defaultLocalOptions } from "./lib/common" ;
@@ -54,10 +52,8 @@ if (!module.parent) {
54
52
log
55
53
) ;
56
54
} else {
57
- const allPackages = await AllPackages . read ( dt ) ;
58
55
await publishPackages (
59
- allPackages ,
60
- await readChangedPackages ( allPackages ) ,
56
+ await readChangedPackages ( await AllPackages . read ( dt ) ) ,
61
57
dry ,
62
58
process . env . GH_API_TOKEN || "" ,
63
59
new Fetcher ( )
@@ -67,7 +63,6 @@ if (!module.parent) {
67
63
}
68
64
69
65
export default async function publishPackages (
70
- allPackages : AllPackages ,
71
66
changedPackages : ChangedPackages ,
72
67
dry : boolean ,
73
68
githubAccessToken : string ,
@@ -192,85 +187,6 @@ export default async function publishPackages(
192
187
cacheDirPath
193
188
) ;
194
189
195
- // Loop over the @types packages in npm and mark any that no longer
196
- // exist in HEAD as deprecated.
197
- let from = 0 ;
198
- let objects ;
199
- do {
200
- const opts = {
201
- limit : 250 ,
202
- from
203
- } ;
204
- objects = await search ( "@types" , opts ) ;
205
- for ( const { name : fullNpmName } of objects ) {
206
- const name = fullNpmName . slice ( "@types/" . length ) ;
207
- // If they don't exist in the types directory or in
208
- // notNeededPackages.json then mark them deprecated. Reference the
209
- // commit/pull request that removed them.
210
- if ( ! allPackages . tryGetLatestVersion ( name ) && ! allPackages . getNotNeededPackage ( name ) ) {
211
- log ( `Deprecating ${ name } ` ) ;
212
- const {
213
- repository : {
214
- ref : {
215
- target : {
216
- history : {
217
- nodes : [ commit ]
218
- }
219
- }
220
- }
221
- }
222
- } = await graphql (
223
- `
224
- query($path: String!) {
225
- repository(name: "DefinitelyTyped", owner: "DefinitelyTyped") {
226
- ref(qualifiedName: "master") {
227
- target {
228
- ... on Commit {
229
- history(first: 1, path: $path) {
230
- nodes {
231
- associatedPullRequests(first: 1) {
232
- nodes {
233
- url
234
- }
235
- }
236
- messageHeadline
237
- }
238
- }
239
- }
240
- }
241
- }
242
- }
243
- }
244
- ` ,
245
- {
246
- headers : { authorization : `token ${ githubAccessToken } ` } ,
247
- path : `types/${ name } `
248
- }
249
- ) ;
250
- let deprecatedMessage ;
251
- if ( commit ) {
252
- const {
253
- associatedPullRequests : {
254
- nodes : [ pullRequest ]
255
- } ,
256
- messageHeadline
257
- } = commit ;
258
- deprecatedMessage = messageHeadline ;
259
- if ( pullRequest ) {
260
- deprecatedMessage += ` (${ pullRequest . url } )` ;
261
- }
262
- }
263
- if ( dry ) {
264
- log ( `(dry) Skip deprecate removed package ${ fullNpmName } ` ) ;
265
- } else {
266
- log ( `Deprecating ${ fullNpmName } with message: ${ deprecatedMessage } ` ) ;
267
- await client . deprecate ( fullNpmName , "" , deprecatedMessage ) ;
268
- }
269
- }
270
- }
271
- from += objects . length ;
272
- } while ( objects . length >= 250 && from <= 5000 ) ;
273
-
274
190
await writeLog ( "publishing.md" , logResult ( ) ) ;
275
191
console . log ( "Done!" ) ;
276
192
}
0 commit comments