Skip to content

Commit

Permalink
feat: update package manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
velut committed Apr 12, 2024
1 parent 430583a commit 18cb6cd
Showing 1 changed file with 145 additions and 1 deletion.
146 changes: 145 additions & 1 deletion src/package-manifest.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { z } from "zod";
import { bugsSchema } from "./bugs";
import { distSchema } from "./dist";
import { fundingSchema } from "./funding";
import { personSchema } from "./person";
import { repositorySchema } from "./repository";

/**
Zod schema for the package manifest.
*/
export const packageManifestSchema = z.object({
// Required properties.

/** Package version ID in the format `<name>@<version>`. */
_id: z.string(),

/** Package name. */
name: z.string(),

Expand All @@ -13,14 +22,149 @@ export const packageManifestSchema = z.object({

/** Distribution metadata generated by the registry. */
dist: distSchema,

// Optional properties.

/** Deprecation message. */
deprecated: z.string().optional(),

/** Production dependencies. */
dependencies: z.record(z.string()).optional(),

/** Development dependencies. */
devDependencies: z.record(z.string()).optional(),

/** Peer dependencies. */
peerDependencies: z.record(z.string()).optional(),

/** Optional dependencies. */
optionalDependencies: z.record(z.string()).optional(),

/** Dependencies bundled with the package. */
bundleDependencies: z.array(z.string()).optional(),

/** Metadata about peer dependencies. */
peerDependenciesMeta: z.record(z.object({ optional: z.boolean() })).optional(),

/** Executable files. */
bin: z.union([z.string(), z.record(z.string())]).optional(),

/** Directories in the package. */
directories: z.record(z.string()).optional(),

/** Runtime systems supported by the package. */
engines: z.record(z.string()).optional(),

/** True if the package contains a shrinkwrap file. */
_hasShrinkwrap: z.boolean().optional(),

/** True if the package contains an `install` script. */
hasInstallScript: z.boolean().optional(),

/** CPU architectures supported by the package. */
cpu: z.array(z.string()).optional(),

/** Operating systems supported by the package. */
os: z.array(z.string()).optional(),

/** Description for the package. */
description: z.string().optional(),

/** Keyword for searching the package. */
keywords: z.array(z.string()).optional(),

/** Homepage for the package's project. */
homepage: z.string().optional(),

/** Issue tracker for the package. */
bugs: bugsSchema.optional(),

/** SPDX license identifier or a custom license. */
license: z.string().optional(),

/** Author of the package. */
author: personSchema.optional(),

/** Contributors to the package. */
contributors: z.array(personSchema).optional(),

/** Maintainers of the package. */
maintainers: z.array(personSchema).optional(),

/** Funding options for the package. */
funding: fundingSchema.optional(),

/** File patterns for files included when publishing the package. */
files: z.array(z.string()).optional(),

/** Main CommonJS entry point for the package. */
main: z.string().optional(),

/** Main ESM entry point for the package. */
module: z.string().optional(),

/** Main module for the package when used in a browser environment. */
browser: z.union([z.string(), z.record(z.string())]).optional(),

/** Documentation to be used with the `man` command. */
man: z.union([z.string(), z.array(z.string())]).optional(),

/** Repository for the package's source code. */
repository: repositorySchema.optional(),

/** Scripts used in the package. */
scripts: z.record(z.string()).optional(),

/** Configuration values for scripts. */
config: z.record(z.string()).optional(),

/** Overrides for dependencies resolution. */
overrides: z.record(z.unknown()).optional(),

/** True if the package should not be published. */
private: z.boolean().optional(),

/** Configuration values used at publishing time. */
publishConfig: z.record(z.string()).optional(),

/** File patterns locating local workspaces. */
workspaces: z.array(z.string()).optional(),

/** Text (partially) extracted from the README file. */
readme: z.string().optional(),

/** Name of the README file. */
readmeFilename: z.string().optional(),

/** Node.js version used to publish the package. */
_nodeVersion: z.string().optional(),

/** npm CLI version used to publish the package. */
_npmVersion: z.string().optional(),

/** npm user who published the specific version of the package. */
_npmUser: personSchema.optional(),

/** Internal npm registry data. */
_npmOperationalInternal: z
.object({
host: z.string(),
tmp: z.string(),
})
.partial()
.optional(),

/** Commit corresponding to the published package version. */
gitHead: z.string().optional(),
});

/**
`PackageManifest` describes the manifest for a specific version of a package (e.g., `foo@1.0.0`).
@remarks
The manifest contains data extracted from the `package.json` file as well as data generated by the registry.
The manifest contains data extracted from `package.json` as well as data generated by the registry.
@see {@link https://docs.npmjs.com/cli/v10/configuring-npm/package-json}
@see {@link https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#getpackageversion}
@see {@link https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-object}
@see {@link https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#full-metadata-format}
Expand Down

0 comments on commit 18cb6cd

Please sign in to comment.