11import applicationinsights = require( "applicationinsights" ) ;
2- import search = require( "libnpmsearch" ) ;
3- import { graphql } from "@octokit/graphql" ;
42import * as yargs from "yargs" ;
53
64import { defaultLocalOptions } from "./lib/common" ;
@@ -54,10 +52,8 @@ if (!module.parent) {
5452 log
5553 ) ;
5654 } else {
57- const allPackages = await AllPackages . read ( dt ) ;
5855 await publishPackages (
59- allPackages ,
60- await readChangedPackages ( allPackages ) ,
56+ await readChangedPackages ( await AllPackages . read ( dt ) ) ,
6157 dry ,
6258 process . env . GH_API_TOKEN || "" ,
6359 new Fetcher ( )
@@ -67,7 +63,6 @@ if (!module.parent) {
6763}
6864
6965export default async function publishPackages (
70- allPackages : AllPackages ,
7166 changedPackages : ChangedPackages ,
7267 dry : boolean ,
7368 githubAccessToken : string ,
@@ -192,85 +187,6 @@ export default async function publishPackages(
192187 cacheDirPath
193188 ) ;
194189
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-
274190 await writeLog ( "publishing.md" , logResult ( ) ) ;
275191 console . log ( "Done!" ) ;
276192}
0 commit comments