Skip to content

Commit 5cbff11

Browse files
committed
chore: format packagejson.ts
1 parent ce3d808 commit 5cbff11

1 file changed

Lines changed: 87 additions & 47 deletions

File tree

src/types/packagejson.ts

Lines changed: 87 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,3 @@
1-
/**
2-
* A “person” is an object with a “name” field and optionally “url” and “email”. Or you can shorten that all into a single string, and npm will parse it for you.
3-
*/
4-
export type PackageJsonPerson =
5-
| string
6-
| {
7-
name: string;
8-
email?: string;
9-
url?: string;
10-
};
11-
12-
type PackageJsonExportKey =
13-
| "."
14-
| "import"
15-
| "require"
16-
| "types"
17-
| "node"
18-
| "browser"
19-
| "default"
20-
| (string & {});
21-
22-
type PackageJsonExportsObject = {
23-
[P in PackageJsonExportKey]?:
24-
| string
25-
| PackageJsonExportsObject
26-
| Array<string | PackageJsonExportsObject>;
27-
};
28-
29-
export type PackageJsonExports =
30-
| string
31-
| PackageJsonExportsObject
32-
| Array<string | PackageJsonExportsObject>;
33-
341
export interface PackageJson {
352
/**
363
* The name is what your thing is called.
@@ -41,18 +8,22 @@ export interface PackageJson {
418
* - The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can’t contain any non-URL-safe characters.
429
*/
4310
name?: string;
11+
4412
/**
4513
* Version must be parseable by `node-semver`, which is bundled with npm as a dependency. (`npm install semver` to use it yourself.)
4614
*/
4715
version?: string;
16+
4817
/**
4918
* Put a description in it. It’s a string. This helps people discover your package, as it’s listed in `npm search`.
5019
*/
5120
description?: string;
21+
5222
/**
5323
* Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in `npm search`.
5424
*/
5525
keywords?: string[];
26+
5627
/**
5728
* The url to the project homepage.
5829
*/
@@ -62,98 +33,121 @@ export interface PackageJson {
6233
* The url to your project’s issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package.
6334
*/
6435
bugs?:
65-
| string
66-
| {
67-
url?: string;
68-
email?: string;
69-
};
36+
| string
37+
| {
38+
url?: string;
39+
email?: string;
40+
};
41+
7042
/**
7143
* You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you’re placing on it.
7244
*/
7345
license?: string;
46+
7447
/**
7548
* Specify the place where your code lives. This is helpful for people who want to contribute. If the git repo is on GitHub, then the `npm docs` command will be able to find you.
7649
* For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same shortcut syntax you use for npm install:
7750
*/
7851
repository?:
79-
| string
80-
| {
81-
type: string;
82-
url: string;
83-
/**
84-
* If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:
85-
*/
86-
directory?: string;
87-
};
52+
| string
53+
| {
54+
type: string;
55+
url: string;
56+
/**
57+
* If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:
58+
*/
59+
directory?: string;
60+
};
61+
62+
/**
63+
* The `scripts` field is a dictionary containing script commands that are run at various times in the lifecycle of your package.
64+
*/
8865
scripts?: Record<string, string>;
66+
8967
/**
9068
* If you set `"private": true` in your package.json, then npm will refuse to publish it.
9169
*/
9270
private?: boolean;
71+
9372
/**
9473
* The “author” is one person.
9574
*/
9675
author?: PackageJsonPerson;
76+
9777
/**
9878
* “contributors” is an array of people.
9979
*/
10080
contributors?: PackageJsonPerson[];
81+
10182
/**
10283
* The optional `files` field is an array of file patterns that describes the entries to be included when your package is installed as a dependency. File patterns follow a similar syntax to `.gitignore`, but reversed: including a file, directory, or glob pattern (`*`, `**\/*`, and such) will make it so that file is included in the tarball when it’s packed. Omitting the field will make it default to `["*"]`, which means it will include all files.
10384
*/
10485
files?: string[];
86+
10587
/**
10688
* The main field is a module ID that is the primary entry point to your program. That is, if your package is named `foo`, and a user installs it, and then does `require("foo")`, then your main module’s exports object will be returned.
10789
* This should be a module ID relative to the root of your package folder.
10890
* For most modules, it makes the most sense to have a main script and often not much else.
10991
*/
11092
main?: string;
93+
11194
/**
11295
* If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren’t available in Node.js modules. (e.g. window)
11396
*/
11497
browser?: string | Record<string, string | false>;
98+
11599
/**
116100
* The `unpkg` field is used to specify the URL to a UMD module for your package. This is used by default in the unpkg.com CDN service.
117101
*/
118102
unpkg?: string;
103+
119104
/**
120105
* A map of command name to local file name. On install, npm will symlink that file into `prefix/bin` for global installs, or `./node_modules/.bin/` for local installs.
121106
*/
122107
bin?: string | Record<string, string>;
108+
123109
/**
124110
* Specify either a single file or an array of filenames to put in place for the `man` program to find.
125111
*/
126112
man?: string | string[];
113+
127114
/**
128115
* Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.
129116
*/
130117
dependencies?: Record<string, string>;
118+
131119
/**
132120
* If someone is planning on downloading and using your module in their program, then they probably don’t want or need to download and build the external test or documentation framework that you use.
133121
* In this case, it’s best to map these additional items in a `devDependencies` object.
134122
*/
135123
devDependencies?: Record<string, string>;
124+
136125
/**
137126
* If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the `optionalDependencies` object. This is a map of package name to version or url, just like the `dependencies` object. The difference is that build failures do not cause installation to fail.
138127
*/
139128
optionalDependencies?: Record<string, string>;
129+
140130
/**
141131
* In some cases, you want to express the compatibility of your package with a host tool or library, while not necessarily doing a `require` of this host. This is usually referred to as a plugin. Notably, your module may be exposing a specific interface, expected and specified by the host documentation.
142132
*/
143133
peerDependencies?: Record<string, string>;
134+
144135
/**
145136
* TypeScript typings, typically ending by `.d.ts`.
146137
*/
147138
types?: string;
139+
148140
/**
149141
* This field is synonymous with `types`.
150142
*/
151143
typings?: string;
144+
152145
/**
153146
* Non-Standard Node.js alternate entry-point to main.
154147
* An initial implementation for supporting CJS packages (from main), and use module for ESM modules.
155148
*/
156149
module?: string;
150+
157151
/**
158152
* Make main entry-point be loaded as an ESM module, support "export" syntax instead of "require"
159153
*
@@ -164,6 +158,7 @@ export interface PackageJson {
164158
* @since Node.js v14
165159
*/
166160
type?: "module" | "commonjs";
161+
167162
/**
168163
* Alternate and extensible alternative to "main" entry point.
169164
*
@@ -175,23 +170,27 @@ export interface PackageJson {
175170
* @since Node.js v12.7
176171
*/
177172
exports?: PackageJsonExports;
173+
178174
/**
179175
* Docs:
180176
* - https://nodejs.org/api/packages.html#imports
181177
*/
182178
imports?: Record<string, string | Record<string, string>>;
179+
183180
/**
184181
* The field is used to define a set of sub-packages (or workspaces) within a monorepo.
185182
*
186183
* This field is an array of glob patterns or an object with specific configurations for managing
187184
* multiple packages in a single repository.
188185
*/
189186
workspaces?: string[];
187+
190188
/**
191189
* The field is is used to specify different TypeScript declaration files for
192190
* different versions of TypeScript, allowing for version-specific type definitions.
193191
*/
194192
typesVersions?: Record<string, Record<string, string[]>>;
193+
195194
/**
196195
* You can specify which operating systems your module will run on:
197196
* ```json
@@ -209,6 +208,7 @@ export interface PackageJson {
209208
* It is allowed to both block and allow an item, although there isn't any good reason to do this.
210209
*/
211210
os?: string[];
211+
212212
/**
213213
* If your code only runs on certain cpu architectures, you can specify which ones.
214214
* ```json
@@ -225,6 +225,7 @@ export interface PackageJson {
225225
* The host architecture is determined by `process.arch`
226226
*/
227227
cpu?: string[];
228+
228229
/**
229230
* This is a set of config values that will be used at publish-time.
230231
*/
@@ -233,14 +234,17 @@ export interface PackageJson {
233234
* The registry that will be used if the package is published.
234235
*/
235236
registry?: string;
237+
236238
/**
237239
* The tag that will be used if the package is published.
238240
*/
239241
tag?: string;
242+
240243
/**
241244
* The access level that will be used if the package is published.
242245
*/
243246
access?: "public" | "restricted";
247+
244248
/**
245249
* **pnpm-only**
246250
*
@@ -251,6 +255,7 @@ export interface PackageJson {
251255
* they aren't directly accessible through the bin field.
252256
*/
253257
executableFiles?: string[];
258+
254259
/**
255260
* **pnpm-only**
256261
*
@@ -261,6 +266,7 @@ export interface PackageJson {
261266
* the specified directory (usually using third party build tools).
262267
*/
263268
directory?: string;
269+
264270
/**
265271
* **pnpm-only**
266272
*
@@ -283,5 +289,39 @@ export interface PackageJson {
283289
| "os"
284290
| "cpu"
285291
>;
292+
286293
[key: string]: any;
287294
}
295+
296+
/**
297+
* A “person” is an object with a “name” field and optionally “url” and “email”. Or you can shorten that all into a single string, and npm will parse it for you.
298+
*/
299+
export type PackageJsonPerson =
300+
| string
301+
| {
302+
name: string;
303+
email?: string;
304+
url?: string;
305+
};
306+
307+
type PackageJsonExportKey =
308+
| "."
309+
| "import"
310+
| "require"
311+
| "types"
312+
| "node"
313+
| "browser"
314+
| "default"
315+
| (string & {});
316+
317+
type PackageJsonExportsObject = {
318+
[P in PackageJsonExportKey]?:
319+
| string
320+
| PackageJsonExportsObject
321+
| Array<string | PackageJsonExportsObject>;
322+
};
323+
324+
export type PackageJsonExports =
325+
| string
326+
| PackageJsonExportsObject
327+
| Array<string | PackageJsonExportsObject>;

0 commit comments

Comments
 (0)