Skip to content

Commit

Permalink
chore: update old code
Browse files Browse the repository at this point in the history
  • Loading branch information
velut committed Apr 9, 2024
1 parent 2ad90e7 commit 36fa792
Show file tree
Hide file tree
Showing 17 changed files with 146 additions and 43 deletions.
28 changes: 0 additions & 28 deletions src/data/registries.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/endpoints/get-abbreviated-packument.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AbbreviatedPackument } from "../types/abbreviated-packument";
import type { AbbreviatedPackument } from "../types/abbreviated-packument";
import { normalizeRawAbbreviatedPackument } from "../utils/normalize-raw-abbreviated-packument";
import { getRawAbbreviatedPackument } from "./get-raw-abbreviated-packument";

Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/get-registry-metadata.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RegistryMetadata } from "../types/registry-metadata";
import type { RegistryMetadata } from "../types/registry-metadata";
import { fetchFromRegistry } from "../utils/fetch-from-registry";

/**
Expand Down
127 changes: 127 additions & 0 deletions src/index.old.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/**
* This package exports several functions to query
* the {@link https://www.npmjs.com | npm registry}
* (or one of its mirrors) through one of its
* {@link https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md | endpoints}.
*
* @example
* Get the metadata for the npm registry:
*
* ```typescript
* import { getRegistryMetadata } from 'query-registry';
*
* (async () => {
* const metadata = await getRegistryMetadata();
*
* // Output: 'registry'
* console.log(metadata.db_name);
* })();
* ```
*
* @example
* Get the latest manifest for package `query-registry` from the npm registry:
*
* ```typescript
* import { getPackageManifest } from 'query-registry';
*
* (async () => {
* const manifest = await getPackageManifest({ name: 'query-registry' });
*
* // Output: 'query-registry'
* console.log(manifest.name);
* })();
* ```
*
* @example
* Get the abbreviated packument for package `query-registry` from the npm registry:
*
* ```typescript
* import { getAbbreviatedPackument } from 'query-registry';
*
* (async () => {
* const packument = await getAbbreviatedPackument({ name: 'query-registry' });
*
* // Output: 'query-registry'
* console.log(manifest.name);
* })();
* ```
*
* @example
* Get the weekly downloads for package `query-registry` from the npm registry:
*
* ```typescript
* import { getPackageDownloads } from 'query-registry';
*
* (async () => {
* const downloads = await getPackageDownloads({ name: 'query-registry' });
*
* // Output: 'query-registry'
* console.log(downloads.package);
*
* // Output: 'number'
* console.log(typeof downloads.downloads);
* })();
* ```
*
* @example
* Get the search results for text query `query-registry` from the npm registry:
*
* ```typescript
* import { searchPackages } from 'query-registry';
*
* (async () => {
* const results = await searchPackages({ query: { text: 'query-registry' } });
*
* // Output: 'query-registry'
* console.log(results.objects[0].package.name);
* })();
* ```
*
* @example
* Enable {@link https://www.npmjs.com/package/debug | debug messages}
* by setting the `DEBUG` environment variable to `query-registry`
* (available only in non production environments):
*
* ```bash
* $ DEBUG="query-registry"
* ```
*
* @packageDocumentation
*/

// export * from "./data/registries";
// export * from "./endpoints/get-abbreviated-packument";
// export * from "./endpoints/get-daily-package-downloads";
// export * from "./endpoints/get-daily-registry-downloads";
// export * from "./endpoints/get-package-downloads";
// export * from "./endpoints/get-package-manifest";
// export * from "./endpoints/get-packument";
// export * from "./endpoints/get-raw-abbreviated-packument";
// export * from "./endpoints/get-raw-package-manifest";
// export * from "./endpoints/get-raw-packument";
// export * from "./endpoints/get-registry-downloads";
// export * from "./endpoints/get-registry-metadata";
// export * from "./endpoints/search-packages";
// export * from "./types/abbreviated-packument";
// export * from "./types/bug-tracker";
// export * from "./types/dist-info";
// export * from "./types/dist-tags";
// export * from "./types/download-period";
// export * from "./types/downloads";
// export * from "./types/git-repository";
// export * from "./types/npm-operational-internal";
// export * from "./types/package-json";
// export * from "./types/package-manifest";
// export * from "./types/packument";
// export * from "./types/person";
// export * from "./types/raw-abbreviated-packument";
// export * from "./types/raw-package-manifest";
// export * from "./types/raw-packument";
// export * from "./types/registry-metadata";
// export * from "./types/repository";
// export * from "./types/search-criteria";
// export * from "./types/search-results";
// export * from "./types/versions-to-timestamps";
// export * from "./utils/errors";

export {};
2 changes: 1 addition & 1 deletion test/endpoints/get-abbreviated-packument.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getAbbreviatedPackument,
getPackument,
InvalidPackageNameError,
} from "../../src";
} from "../../src/index.old";

describe("getAbbreviatedPackument", () => {
setupPolly({
Expand Down
2 changes: 1 addition & 1 deletion test/endpoints/get-daily-package-downloads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import NodeHttpAdapter from "@pollyjs/adapter-node-http";
import FSPersister from "@pollyjs/persister-fs";
import * as path from "path";
import { setupPolly } from "setup-polly-jest";
import { FetchError, getDailyPackageDownloads, InvalidPackageNameError } from "../../src";
import { FetchError, getDailyPackageDownloads, InvalidPackageNameError } from "../../src/index.old";

describe("getDailyPackageDownloads", () => {
setupPolly({
Expand Down
2 changes: 1 addition & 1 deletion test/endpoints/get-daily-registry-downloads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import NodeHttpAdapter from "@pollyjs/adapter-node-http";
import FSPersister from "@pollyjs/persister-fs";
import * as path from "path";
import { setupPolly } from "setup-polly-jest";
import { getDailyRegistryDownloads } from "../../src";
import { getDailyRegistryDownloads } from "../../src/index.old";

describe("getDailyRegistryDownloads", () => {
setupPolly({
Expand Down
2 changes: 1 addition & 1 deletion test/endpoints/get-package-downloads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import NodeHttpAdapter from "@pollyjs/adapter-node-http";
import FSPersister from "@pollyjs/persister-fs";
import * as path from "path";
import { setupPolly } from "setup-polly-jest";
import { FetchError, getPackageDownloads, InvalidPackageNameError } from "../../src";
import { FetchError, getPackageDownloads, InvalidPackageNameError } from "../../src/index.old";

describe("getPackageDownloads", () => {
setupPolly({
Expand Down
2 changes: 1 addition & 1 deletion test/endpoints/get-package-manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getPackageManifest,
InvalidPackageNameError,
InvalidPackageVersionError,
} from "../../src";
} from "../../src/index.old";

describe("getPackageManifest", () => {
setupPolly({
Expand Down
2 changes: 1 addition & 1 deletion test/endpoints/get-packument.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import NodeHttpAdapter from "@pollyjs/adapter-node-http";
import FSPersister from "@pollyjs/persister-fs";
import * as path from "path";
import { setupPolly } from "setup-polly-jest";
import { FetchError, getPackument, InvalidPackageNameError } from "../../src";
import { FetchError, getPackument, InvalidPackageNameError } from "../../src/index.old";

describe("getPackument", () => {
setupPolly({
Expand Down
6 changes: 5 additions & 1 deletion test/endpoints/get-raw-abbreviated-packument.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import NodeHttpAdapter from "@pollyjs/adapter-node-http";
import FSPersister from "@pollyjs/persister-fs";
import * as path from "path";
import { setupPolly } from "setup-polly-jest";
import { FetchError, getRawAbbreviatedPackument, InvalidPackageNameError } from "../../src";
import {
FetchError,
getRawAbbreviatedPackument,
InvalidPackageNameError,
} from "../../src/index.old";

describe("getRawAbbreviatedPackument", () => {
setupPolly({
Expand Down
2 changes: 1 addition & 1 deletion test/endpoints/get-raw-package-manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getRawPackageManifest,
InvalidPackageNameError,
InvalidPackageVersionError,
} from "../../src";
} from "../../src/index.old";

describe("getRawPackageManifest", () => {
setupPolly({
Expand Down
2 changes: 1 addition & 1 deletion test/endpoints/get-raw-packument.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import NodeHttpAdapter from "@pollyjs/adapter-node-http";
import FSPersister from "@pollyjs/persister-fs";
import * as path from "path";
import { setupPolly } from "setup-polly-jest";
import { FetchError, getRawPackument, InvalidPackageNameError } from "../../src";
import { FetchError, getRawPackument, InvalidPackageNameError } from "../../src/index.old";

describe("getRawPackument", () => {
setupPolly({
Expand Down
2 changes: 1 addition & 1 deletion test/endpoints/get-registry-downloads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import NodeHttpAdapter from "@pollyjs/adapter-node-http";
import FSPersister from "@pollyjs/persister-fs";
import * as path from "path";
import { setupPolly } from "setup-polly-jest";
import { getRegistryDownloads } from "../../src";
import { getRegistryDownloads } from "../../src/index.old";

describe("getRegistryDownloads", () => {
setupPolly({
Expand Down
2 changes: 1 addition & 1 deletion test/endpoints/get-registry-metadata.disable-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import NodeHttpAdapter from "@pollyjs/adapter-node-http";
import FSPersister from "@pollyjs/persister-fs";
import * as path from "path";
import { setupPolly } from "setup-polly-jest";
import { getRegistryMetadata, yarnRegistry } from "../../src";
import { getRegistryMetadata, yarnRegistry } from "../../src/index.old";

describe("getRegistryMetadata", () => {
setupPolly({
Expand Down
2 changes: 1 addition & 1 deletion test/endpoints/search-packages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import NodeHttpAdapter from "@pollyjs/adapter-node-http";
import FSPersister from "@pollyjs/persister-fs";
import * as path from "path";
import { setupPolly } from "setup-polly-jest";
import { searchPackages } from "../../src";
import { searchPackages } from "../../src/index.old";

describe("searchPackages", () => {
setupPolly({
Expand Down
2 changes: 1 addition & 1 deletion test/utils/normalize-raw-repository.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GitRepository } from "../../src";
import { GitRepository } from "../../src/index.old";
import { normalizeRawRepository } from "../../src/utils/normalize-raw-repository";

describe("normalizeRawRepository", () => {

Check failure on line 4 in test/utils/normalize-raw-repository.test.ts

View workflow job for this annotation

GitHub Actions / build

test/utils/normalize-raw-repository.test.ts

ReferenceError: describe is not defined ❯ test/utils/normalize-raw-repository.test.ts:4:1
Expand Down

0 comments on commit 36fa792

Please sign in to comment.