Skip to content

Commit

Permalink
feat: add Repository
Browse files Browse the repository at this point in the history
  • Loading branch information
velut committed Apr 9, 2024
1 parent 59a0340 commit 430583a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ export {
export { npmRegistryDownloadsApiUrl, npmRegistryUrl } from "./npm-registry";
export { packageManifestSchema, type PackageManifest } from "./package-manifest";
export { personSchema, type Person } from "./person";
export { repositorySchema, type Repository } from "./repository";
22 changes: 22 additions & 0 deletions src/repository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { z } from "zod";

/**
Zod schema for the repository for a package.
*/
export const repositorySchema = z.object({
/** Machine-readable repository URL (e.g., `https://github.com/user/repo.git`). */
url: z.string(),

/** Repository type (e.g., `git`). */
type: z.string().optional(),

/** Directory in a monorepo where the package's source code is located. */
directory: z.string().optional(),
});

/**
`Repository` describes the repository for a package.
@see {@link https://docs.npmjs.com/cli/v10/configuring-npm/package-json#repository}
*/
export type Repository = z.infer<typeof repositorySchema>;

0 comments on commit 430583a

Please sign in to comment.