PackageJsonBuilder
class
PackageJsonBuilder
sourceexport class PackageJsonBuilder export class PackageJsonBuilderconstructor(data?: Partial<PackageJson>) constructor(data?: Partial<PackageJson>)| Param | Description | Type | Required |
|---|---|---|---|
| The initial package.json data | | No |
toJSON(): PackageJson toJSON(): PackageJsonReturns:
PackageJson PackageJsonwrite(filepath: string, overwrite?: boolean): Promise<void> write(filepath: string, overwrite?: boolean): Promise<void>| Param | Description | Type | Required |
|---|---|---|---|
| The filepath to write the package.json data to | | Yes |
| Whether to overwrite the file if it already exists | | No |
Returns:
Promise<void> Promise<void>read(filepath: string): Promise<this> read(filepath: string): Promise<this>| Param | Description | Type | Required |
|---|---|---|---|
| The filepath to read the package.json data from | | Yes |
Returns:
Promise<this> Promise<this>merge(data: Partial<PackageJson>): this merge(data: Partial<PackageJson>): this| Param | Description | Type | Required |
|---|---|---|---|
| The package.json data to merge | | Yes |
Returns:
this thisremove(key: keyof PackageJson): this remove(key: keyof PackageJson): this| Param | Description | Type | Required |
|---|---|---|---|
| The key to remove | | Yes |
Returns:
this thispublic source
.setScripts(...)
setScripts(scripts: Record<string, string>): this setScripts(scripts: Record<string, string>): this| Param | Description | Type | Required |
|---|---|---|---|
| The scripts to set | | Yes |
Returns:
this thisaddScript(name: string, script: string): this addScript(name: string, script: string): this| Param | Description | Type | Required |
|---|---|---|---|
| The name of the script | | Yes |
| The script that will be executed | | Yes |
Returns:
this thispublic source
.removeScript(...)
removeScript(name: string): this removeScript(name: string): this| Param | Description | Type | Required |
|---|---|---|---|
| The name of the script | | Yes |
Returns:
this thispublic source
.setDependencies(...)
setDependencies(dependencies: Record<string, string>): this setDependencies(dependencies: Record<string, string>): this| Param | Description | Type | Required |
|---|---|---|---|
| The dependencies to set | | Yes |
Returns:
this thispublic source
.addDependency(...)
addDependency(name: string, version: string, dev: boolean = false): this addDependency(name: string, version: string, dev: boolean = false): this| Param | Description | Type | Required |
|---|---|---|---|
| The name of the dependency | | Yes |
| The version of the dependency | | Yes |
| Whether the dependency is a dev dependency | | No |
Returns:
this thispublic source
.removeDependency(...)
removeDependency(name: string, dev: boolean = false): this removeDependency(name: string, dev: boolean = false): this| Param | Description | Type | Required |
|---|---|---|---|
| The name of the dependency | | Yes |
| Whether the dependency is a dev dependency | | No |
Returns:
this this