diff --git a/packages/publisher/README.md b/packages/publisher/README.md index a85bb09eb2..e0b1c2184a 100644 --- a/packages/publisher/README.md +++ b/packages/publisher/README.md @@ -36,7 +36,6 @@ npm run clean npm run parse npm run calculate-versions npm run generate -npm run index npm run publish-packages npm run upload-blobs ``` @@ -61,7 +60,6 @@ To update the types packages, the following steps must be performed: * Parse the definitions * Calculate versions * Generate packages on disk - * Create a search index * Publish packages on disk Importantly, each of these steps is *idempotent*. @@ -189,48 +187,6 @@ This generates `versions.json` based on the last uploaded `versions.json` and by The `--forceUpdate` argument will cause a build version bump even if the `contentHash` of the originating types folder has not changed. This argument may be needed during development, but should not be used during routine usage. -# Create a search index - -> `npm run index` - -This script creates `data/search-index-min.json`, which (in the upload step) will be uploaded to Azure and used by [TypeSearch](https://github.com/microsoft/typesearch). -This step is not necessary for other steps in the process. - -### Arguments to `create-search-index` - -You can generate a prettier output in `data/search-index-full.json`. -This version is for human review only and is not compatible with TypeSearch. - -By default, `create-search-index` fetches download counts from NPM for use in search result ranking. -The argument `--skipDownloads` disables this behavior. - -### Search Entries - -Each `search-*.json` file consists of an array. -An example unminified entry is: -```js -{ - "projectName": "http://backgridjs.com/", - "libraryName": "Backgrid", - "globals": [ - "Backgrid" - ], - "typePackageName": "backgrid", - "declaredExternalModules": [ - "backgrid" - ], - "downloads": 532234 -}, -``` -These fields should hopefully be self-explanatory. -`downloads` refers to the number in the past month. -If `--skipDownloads` was specified, `downloads` will be -1. -In the case where the type package name is different from the NPM package name, or no NPM package name exists, `downloads` will be 0. - -In the minified files, the properties are simply renamed. See `src/lib/search-index-generator.ts` for documentation. - -Empty arrays may be elided in future versions of the minified files. - # Generate packages on disk > `npm run generate` diff --git a/packages/publisher/package.json b/packages/publisher/package.json index 2773856b39..f93c8ba28c 100644 --- a/packages/publisher/package.json +++ b/packages/publisher/package.json @@ -44,7 +44,6 @@ "calculate-versions": "node -r source-map-support/register dist/calculate-versions.js", "generate": "node -r source-map-support/register dist/generate-packages.js", "validate": "node -r source-map-support/register dist/validate.js", - "index": "node -r source-map-support/register dist/create-search-index.js", "publish-packages": "node -r source-map-support/register dist/publish-packages.js", "publish-packages-dry": "node -r source-map-support/register dist/publish-packages.js --dry", "publish-registry": "node -r source-map-support/register dist/publish-registry.js", diff --git a/packages/publisher/src/create-search-index.ts b/packages/publisher/src/create-search-index.ts deleted file mode 100644 index 60ffb49986..0000000000 --- a/packages/publisher/src/create-search-index.ts +++ /dev/null @@ -1,70 +0,0 @@ -import * as yargs from "yargs"; - -import { getDefinitelyTyped, AllPackages, writeDataFile, TypingsData } from "@definitelytyped/definitions-parser"; -import { loggerWithErrors, logUncaughtErrors, UncachedNpmInfoClient } from "@definitelytyped/utils"; -import { defaultLocalOptions } from "./lib/common"; - -if (!module.parent) { - const log = loggerWithErrors()[0]; - const single = yargs.argv.single as string | undefined; - if (single) { - logUncaughtErrors(doSingle(single, new UncachedNpmInfoClient())); - } else { - logUncaughtErrors(async () => - createSearchIndex( - await AllPackages.read(await getDefinitelyTyped(defaultLocalOptions, log)), - new UncachedNpmInfoClient() - ) - ); - } -} - -export interface SearchRecord { - // types package name - readonly t: string; - // globals - readonly g: readonly string[]; - // modules - readonly m: readonly string[]; - // project name - readonly p: string; - // library name - readonly l: string; - // downloads in the last month from NPM - readonly d: number; -} - -export default async function createSearchIndex(packages: AllPackages, client: UncachedNpmInfoClient): Promise { - console.log("Generating search index..."); - const records = await createSearchRecords(packages.allLatestTypings(), client); - console.log("Done generating search index. Writing out data files..."); - await writeDataFile("search-index-min.json", records, false); -} - -async function doSingle(name: string, client: UncachedNpmInfoClient): Promise { - const pkg = await AllPackages.readSingle(name); - const record = (await createSearchRecords([pkg], client))[0]; - console.log(record); -} - -async function createSearchRecords( - packages: readonly TypingsData[], - client: UncachedNpmInfoClient -): Promise { - // Can't search for pkg.unescapedName because npm doesn't search scoped packages. - const dl = await client.getDownloads( - packages.map((pkg, i) => (pkg.name === pkg.unescapedName ? pkg.name : `dummy${i}`)) - ); - return packages - .map( - (pkg, i): SearchRecord => ({ - p: pkg.projectName, - l: pkg.libraryName, - g: pkg.globals, - t: pkg.name, - m: pkg.declaredModules, - d: dl[i], - }) - ) - .sort((a, b) => b.d - a.d); -} diff --git a/packages/publisher/src/full.ts b/packages/publisher/src/full.ts index bb968e5ee9..abef60779b 100644 --- a/packages/publisher/src/full.ts +++ b/packages/publisher/src/full.ts @@ -3,7 +3,6 @@ import * as yargs from "yargs"; import calculateVersions from "./calculate-versions"; import { clean } from "./clean"; -import createSearchIndex from "./create-search-index"; import generatePackages from "./generate-packages"; import publishPackages from "./publish-packages"; import publishRegistry from "./publish-registry"; @@ -49,7 +48,6 @@ export default async function full( ); const changedPackages = await calculateVersions(dt, infoClient, log); await generatePackages(dt, allPackages, changedPackages); - await createSearchIndex(allPackages, infoClient); await publishPackages(changedPackages, dry, githubAccessToken, fetcher); await publishRegistry(dt, allPackages, dry, infoClient); }