-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3687a18
commit 4548f2c
Showing
3 changed files
with
114 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
interface Contact { | ||
email?: string; | ||
url?: string; | ||
name: string; | ||
email?: string | ||
url?: string | ||
name: string | ||
} | ||
|
||
interface Signature { | ||
keyid: string; | ||
sig: string; | ||
keyid: string | ||
sig: string | ||
} | ||
|
||
interface Repository { | ||
directory?: string; | ||
type?: string; | ||
url: string; | ||
directory?: string | ||
type?: string | ||
url: string | ||
} | ||
|
||
/** | ||
|
@@ -21,117 +21,117 @@ interface Repository { | |
*/ | ||
interface Dist { | ||
// Deprecated? (ref: found in [email protected]) | ||
bin?: Record<string, { shasum: string; tarball: string }>; | ||
bin?: Record<string, { shasum: string; tarball: string }> | ||
|
||
/** | ||
* the number of files in the tarball. this is on most packages published >= 2018 | ||
*/ | ||
fileCount?: number; | ||
fileCount?: number | ||
|
||
/** | ||
* subresource integrity string! `npm view ssri` | ||
* https://w3c.github.io/webappsec-subresource-integrity/ | ||
*/ | ||
integrity?: string; | ||
integrity?: string | ||
|
||
/** | ||
* PGP signature for the tarball | ||
*/ | ||
'npm-signature'?: string; | ||
'npm-signature'?: string | ||
|
||
/** | ||
* the sha1 sum of the tarball | ||
*/ | ||
shasum: string; | ||
shasum: string | ||
|
||
/** | ||
* Out-of-date blog post about this, below. (Says this is "npm-signature", but | ||
* that's not what the registry provides). | ||
* https://blog.npmjs.org/post/172999548390/new-pgp-machinery | ||
*/ | ||
signatures: Signature[]; | ||
signatures: Signature[] | ||
|
||
/** | ||
* the url to the tarball for the package version | ||
*/ | ||
tarball: string; | ||
tarball: string | ||
|
||
/** | ||
* the unpacked size of the files in the tarball. >= 2018 | ||
*/ | ||
unpackedSize?: number; | ||
unpackedSize?: number | ||
} | ||
|
||
// this is in the tarball or the project. it really could have anything in it. | ||
export interface PackageJSON { | ||
author?: Contact | string; | ||
bin?: Record<string, string>; | ||
browser?: Record<string, string> | string; | ||
bugs?: Omit<Contact, 'name'> | string; | ||
bundledDependencies?: string[] | boolean; | ||
bundleDependencies?: string[] | boolean; | ||
config?: Record<string, unknown>; | ||
contributors?: Contact[] | string[]; | ||
cpu?: string[]; | ||
dependencies?: Record<string, string>; | ||
description?: string; | ||
devDependencies?: Record<string, string>; | ||
directories?: Record<string, string>; | ||
engines?: Record<string, string>; | ||
files?: string[]; | ||
homepage?: string; | ||
keywords?: string[]; | ||
license?: string; | ||
main?: string; | ||
man?: string | string[]; | ||
name: string; | ||
optionalDependencies?: Record<string, string>; | ||
os?: string[]; | ||
peerDependencies?: Record<string, string>; | ||
private?: boolean; | ||
publishConfig?: Record<string, unknown>; | ||
repository?: Repository | string; | ||
scripts?: Record<string, string>; | ||
types?: string; | ||
version: string; | ||
|
||
[field: string]: unknown; | ||
author?: Contact | string | ||
bin?: Record<string, string> | ||
browser?: Record<string, string> | string | ||
bugs?: Omit<Contact, 'name'> | string | ||
bundledDependencies?: string[] | boolean | ||
bundleDependencies?: string[] | boolean | ||
config?: Record<string, unknown> | ||
contributors?: Contact[] | string[] | ||
cpu?: string[] | ||
dependencies?: Record<string, string> | ||
description?: string | ||
devDependencies?: Record<string, string> | ||
directories?: Record<string, string> | ||
engines?: Record<string, string> | ||
files?: string[] | ||
homepage?: string | ||
keywords?: string[] | ||
license?: string | ||
main?: string | ||
man?: string | string[] | ||
name: string | ||
optionalDependencies?: Record<string, string> | ||
os?: string[] | ||
peerDependencies?: Record<string, string> | ||
private?: boolean | ||
publishConfig?: Record<string, unknown> | ||
repository?: Repository | string | ||
scripts?: Record<string, string> | ||
types?: string | ||
version: string | ||
|
||
[field: string]: unknown | ||
} | ||
|
||
export interface PackumentVersion extends PackageJSON { | ||
// bugs, author, contributors, and repository can be simple strings in | ||
// package.json, but not in registry metadata. | ||
bugs?: Omit<Contact, 'name'>; | ||
author?: Contact; | ||
bugs?: Omit<Contact, 'name'> | ||
author?: Contact | ||
// ref: Record type found in [email protected] et al | ||
browser?: Record<string, string>; | ||
contributors?: Contact[]; | ||
repository?: Repository; | ||
gitHead?: string; | ||
_id: string; | ||
_npmVersion: string; | ||
browser?: Record<string, string> | ||
contributors?: Contact[] | ||
repository?: Repository | ||
gitHead?: string | ||
_id: string | ||
_npmVersion: string | ||
|
||
// Optional (ref: not defined in [email protected]) | ||
_nodeVersion?: string; | ||
|
||
_npmUser?: Contact; | ||
maintainers?: Contact[]; | ||
dist: Dist; | ||
readme?: string; | ||
readmeFilename?: string; | ||
_hasShrinkwrap?: boolean; | ||
deprecated?: string; | ||
_nodeVersion?: string | ||
|
||
_npmUser?: Contact | ||
maintainers?: Contact[] | ||
dist: Dist | ||
readme?: string | ||
readmeFilename?: string | ||
_hasShrinkwrap?: boolean | ||
deprecated?: string | ||
} | ||
|
||
// this is what you get from the npm api. | ||
export type Packument = { | ||
_cached?: boolean; | ||
_id: string; | ||
_rev: string; | ||
'dist-tags': { latest?: string } & Record<string, string>; | ||
time: { modified: string; created: string } & Record<string, string>; | ||
users?: Record<string, true>; | ||
versions: Record<string, PackumentVersion>; | ||
_cached?: boolean | ||
_id: string | ||
_rev: string | ||
'dist-tags': { latest?: string } & Record<string, string> | ||
time: { modified: string; created: string } & Record<string, string> | ||
users?: Record<string, true> | ||
versions: Record<string, PackumentVersion> | ||
|
||
// The following fields are hoisted to the top-level of the packument from the latest version published. | ||
} & Pick< | ||
|
@@ -148,7 +148,7 @@ export type Packument = { | |
| 'readme' | ||
| 'readmeFilename' | ||
| 'repository' | ||
>; | ||
> | ||
|
||
export type ManifestVersion = Pick< | ||
PackumentVersion, | ||
|
@@ -166,7 +166,7 @@ export type ManifestVersion = Pick< | |
| 'optionalDependencies' | ||
| 'peerDependencies' | ||
| 'version' | ||
>; | ||
> | ||
|
||
/** | ||
* abbreviated metadata format (aka corgi) | ||
|
@@ -176,6 +176,6 @@ export type ManifestVersion = Pick< | |
* `application/vnd.npm.install-v1+json` | ||
*/ | ||
export type Manifest = { | ||
modified: string; | ||
versions: Record<string, ManifestVersion>; | ||
} & Pick<Packument, '_cached' | 'name' | 'dist-tags'>; | ||
modified: string | ||
versions: Record<string, ManifestVersion> | ||
} & Pick<Packument, '_cached' | 'name' | 'dist-tags'> |