Skip to main content

API Reference

Submodules

The following submodules are available:

Constructs

Component

Represents a project component.

Initializers

import { Component } from 'projen'

new Component(scope: IConstruct, id?: string)
NameTypeDescription
scope
constructs.IConstructNo description.
id
stringNo description.

scopeRequired
  • Type: constructs.IConstruct

idOptional
  • Type: string

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { Component } from 'projen'

Component.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { Component } from 'projen'

Component.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

Dependencies

The Dependencies component is responsible to track the list of dependencies a project has, and then used by project types as the model for rendering project-specific dependency manifests such as the dependencies section package.json files.

To add a dependency you can use a project-type specific API such as nodeProject.addDeps() or use the generic API of project.deps:

Initializers

import { Dependencies } from 'projen'

new Dependencies(project: Project)
NameTypeDescription
project
Project
The parent project.

projectRequired

The parent project.


Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
addDependency
Adds a dependency to this project.
getDependency
Returns a dependency by name.
removeDependency
Removes a dependency.
tryGetDependency
Returns a dependency by name.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

addDependency
public addDependency(spec: string, type: DependencyType, metadata?: {[ key: string ]: any}): Dependency

Adds a dependency to this project.

specRequired
  • Type: string

The dependency spec in the format MODULE[@VERSION] where MODULE is the package-manager-specific module name and VERSION is an optional semantic version requirement (e.g. ^3.4.0).


typeRequired

The type of the dependency.


metadataOptional
  • Type: {[ key: string ]: any}

getDependency
public getDependency(name: string, type?: DependencyType): Dependency

Returns a dependency by name.

Fails if there is no dependency defined by that name or if type is not provided and there is more then one dependency type for this dependency.

nameRequired
  • Type: string

The name of the dependency.


typeOptional

The dependency type.

If this dependency is defined only for a single type, this argument can be omitted.


removeDependency
public removeDependency(name: string, type?: DependencyType): void

Removes a dependency.

nameRequired
  • Type: string

The name of the module to remove (without the version).


typeOptional

The dependency type.

This is only required if there the dependency is defined for multiple types.


tryGetDependency
public tryGetDependency(name: string, type?: DependencyType): Dependency

Returns a dependency by name.

Returns undefined if there is no dependency defined by that name or if type is not provided and there is more then one dependency type for this dependency.

nameRequired
  • Type: string

The name of the dependency.


typeOptional

The dependency type.

If this dependency is defined only for a single type, this argument can be omitted.


Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.
parseDependency
Returns the coordinates of a dependency spec.

isConstruct
import { Dependencies } from 'projen'

Dependencies.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { Dependencies } from 'projen'

Dependencies.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

parseDependency
import { Dependencies } from 'projen'

Dependencies.parseDependency(spec: string)

Returns the coordinates of a dependency spec.

Given foo@^3.4.0 returns { name: "foo", version: "^3.4.0" }. Given bar@npm:@bar/legacy returns { name: "bar", version: "npm:@bar/legacy" }.

specRequired
  • Type: string

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
all
Dependency[]
A copy of all dependencies recorded for this project.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

allRequired
public readonly all: Dependency[];

A copy of all dependencies recorded for this project.

The list is sorted by type->name->version


Constants

NameTypeDescription
MANIFEST_FILE
stringThe project-relative path of the deps manifest file.

MANIFEST_FILERequired
public readonly MANIFEST_FILE: string;
  • Type: string

The project-relative path of the deps manifest file.


DockerCompose

Create a docker-compose YAML file.

Initializers

import { DockerCompose } from 'projen'

new DockerCompose(project: Project, props?: DockerComposeProps)
NameTypeDescription
project
Project
No description.
props
DockerComposeProps
No description.

projectRequired

propsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
addService
Add a service to the docker-compose file.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

addService
public addService(serviceName: string, description: DockerComposeServiceDescription): DockerComposeService

Add a service to the docker-compose file.

serviceNameRequired
  • Type: string

name of the service.


descriptionRequired

a service description.


Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.
bindVolume
Create a bind volume that binds a host path to the target path in the container.
namedVolume
Create a named volume and mount it to the target path.
network
Create a named network and mount it to the target path.
portMapping
Create a port mapping.
serviceName
Depends on a service name.

isConstruct
import { DockerCompose } from 'projen'

DockerCompose.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { DockerCompose } from 'projen'

DockerCompose.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

bindVolume
import { DockerCompose } from 'projen'

DockerCompose.bindVolume(sourcePath: string, targetPath: string)

Create a bind volume that binds a host path to the target path in the container.

sourcePathRequired
  • Type: string

Host path name.


targetPathRequired
  • Type: string

Target path name.


namedVolume
import { DockerCompose } from 'projen'

DockerCompose.namedVolume(volumeName: string, targetPath: string, options?: DockerComposeVolumeConfig)

Create a named volume and mount it to the target path.

If you use this named volume in several services, the volume will be shared. In this case, the volume configuration of the first-provided options are used.

volumeNameRequired
  • Type: string

Name of the volume.


targetPathRequired
  • Type: string

Target path.


optionsOptional

volume configuration (default: docker compose defaults).


network
import { DockerCompose } from 'projen'

DockerCompose.network(networkName: string, options?: DockerComposeNetworkConfig)

Create a named network and mount it to the target path.

If you use this named network in several services, the network will be shared. In this case, the network configuration of the first-provided options are used.

networkNameRequired
  • Type: string

Name of the network.


optionsOptional

network configuration.


portMapping
import { DockerCompose } from 'projen'

DockerCompose.portMapping(publishedPort: number, targetPort: number, options?: DockerComposePortMappingOptions)

Create a port mapping.

publishedPortRequired
  • Type: number

Published port number.


targetPortRequired
  • Type: number

Container's port number.


optionsOptional

Port mapping options.


serviceName
import { DockerCompose } from 'projen'

DockerCompose.serviceName(serviceName: string)

Depends on a service name.

serviceNameRequired
  • Type: string

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
file
YamlFile
The Docker Compose file.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

fileRequired
public readonly file: YamlFile;

The Docker Compose file.


FileBase

Initializers

import { FileBase } from 'projen'

new FileBase(scope: IConstruct, filePath: string, options?: FileBaseOptions)
NameTypeDescription
scope
constructs.IConstructNo description.
filePath
stringNo description.
options
FileBaseOptions
No description.

scopeRequired
  • Type: constructs.IConstruct

filePathRequired
  • Type: string

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Writes the file to the project's output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Writes the file to the project's output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { FileBase } from 'projen'

FileBase.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { FileBase } from 'projen'

FileBase.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
absolutePath
stringThe absolute path of this file.
path
stringThe file path, relative to the project's outdir.
changed
booleanIndicates if the file has been changed during synthesis.
marker
stringThe projen marker, used to identify files as projen-generated.
executable
booleanIndicates if the file should be marked as executable.
readonly
booleanIndicates if the file should be read-only or read-write.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

absolutePathRequired
public readonly absolutePath: string;
  • Type: string

The absolute path of this file.


pathRequired
public readonly path: string;
  • Type: string

The file path, relative to the project's outdir.


changedOptional
public readonly changed: boolean;
  • Type: boolean

Indicates if the file has been changed during synthesis.

This property is only available in postSynthesize() hooks. If this is undefined, the file has not been synthesized yet.


markerOptional
public readonly marker: string;
  • Type: string

The projen marker, used to identify files as projen-generated.

Value is undefined if the project is being ejected.


executableRequired
public readonly executable: boolean;
  • Type: boolean

Indicates if the file should be marked as executable.


readonlyRequired
public readonly readonly: boolean;
  • Type: boolean

Indicates if the file should be read-only or read-write.


GitAttributesFile

Assign attributes to file names in a git repository.

https://git-scm.com/docs/gitattributes

Initializers

import { GitAttributesFile } from 'projen'

new GitAttributesFile(scope: IConstruct)
NameTypeDescription
scope
constructs.IConstructNo description.

scopeRequired
  • Type: constructs.IConstruct

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Writes the file to the project's output directory.
addAttributes
Maps a set of attributes to a set of files.
addLfsPattern
Add attributes necessary to mark these files as stored in LFS.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Writes the file to the project's output directory.

addAttributes
public addAttributes(glob: string, attributes: string): void

Maps a set of attributes to a set of files.

globRequired
  • Type: string

Glob pattern to match files in the repo.


attributesRequired
  • Type: string

Attributes to assign to these files.


addLfsPattern
public addLfsPattern(glob: string): void

Add attributes necessary to mark these files as stored in LFS.

globRequired
  • Type: string

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { GitAttributesFile } from 'projen'

GitAttributesFile.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { GitAttributesFile } from 'projen'

GitAttributesFile.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
absolutePath
stringThe absolute path of this file.
path
stringThe file path, relative to the project's outdir.
changed
booleanIndicates if the file has been changed during synthesis.
marker
stringThe projen marker, used to identify files as projen-generated.
executable
booleanIndicates if the file should be marked as executable.
readonly
booleanIndicates if the file should be read-only or read-write.
hasLfsPatterns
booleanWhether the current gitattributes file has any LFS patterns.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

absolutePathRequired
public readonly absolutePath: string;
  • Type: string

The absolute path of this file.


pathRequired
public readonly path: string;
  • Type: string

The file path, relative to the project's outdir.


changedOptional
public readonly changed: boolean;
  • Type: boolean

Indicates if the file has been changed during synthesis.

This property is only available in postSynthesize() hooks. If this is undefined, the file has not been synthesized yet.


markerOptional
public readonly marker: string;
  • Type: string

The projen marker, used to identify files as projen-generated.

Value is undefined if the project is being ejected.


executableRequired
public readonly executable: boolean;
  • Type: boolean

Indicates if the file should be marked as executable.


readonlyRequired
public readonly readonly: boolean;
  • Type: boolean

Indicates if the file should be read-only or read-write.


hasLfsPatternsRequired
public readonly hasLfsPatterns: boolean;
  • Type: boolean

Whether the current gitattributes file has any LFS patterns.


Gitpod

The Gitpod component which emits .gitpod.yml.

Initializers

import { Gitpod } from 'projen'

new Gitpod(project: Project, options?: GitpodOptions)
NameTypeDescription
project
Project
No description.
options
GitpodOptions
No description.

projectRequired

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
addCustomTask
Add a task with more granular options.
addDockerImage
Add a custom Docker image or Dockerfile for the container.
addPorts
Add ports that should be exposed (forwarded) from the container.
addPrebuilds
Add a prebuilds configuration for the Gitpod App.
addTasks
Add tasks to run when gitpod starts.
addVscodeExtensions
Add a list of VSCode extensions that should be automatically installed in the container.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

addCustomTask
public addCustomTask(options: GitpodTask): void

Add a task with more granular options.

By default, all tasks will be run in parallel. To run tasks in sequence, create a new Task and set the other tasks as subtasks.

optionsRequired

The task parameters.


addDockerImage
public addDockerImage(image: DevEnvironmentDockerImage): void

Add a custom Docker image or Dockerfile for the container.

imageRequired

The Docker image.


addPorts
public addPorts(ports: string): void

Add ports that should be exposed (forwarded) from the container.

portsRequired
  • Type: string

The new ports.


addPrebuilds
public addPrebuilds(config: GitpodPrebuilds): void

Add a prebuilds configuration for the Gitpod App.

configRequired

The configuration.


addTasks
public addTasks(tasks: Task): void

Add tasks to run when gitpod starts.

By default, all tasks will be run in parallel. To run tasks in sequence, create a new Task and specify the other tasks as subtasks.

tasksRequired

The new tasks.


addVscodeExtensions
public addVscodeExtensions(extensions: string): void

Add a list of VSCode extensions that should be automatically installed in the container.

These must be in the format defined in the Open VSX registry.

https://www.gitpod.io/docs/vscode-extensions/

Example

'scala-lang.scala@0.3.9:O5XmjwY5Gz+0oDZAmqneJw=='
extensionsRequired
  • Type: string

The extension IDs.


Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { Gitpod } from 'projen'

Gitpod.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { Gitpod } from 'projen'

Gitpod.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
config
anyDirect access to the gitpod configuration (escape hatch).

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

configRequired
public readonly config: any;
  • Type: any

Direct access to the gitpod configuration (escape hatch).


IgnoreFile

Initializers

import { IgnoreFile } from 'projen'

new IgnoreFile(project: Project, filePath: string, options?: IgnoreFileOptions)
NameTypeDescription
project
Project
The project to tie this file to.
filePath
string- the relative path in the project to put the file.
options
IgnoreFileOptions
No description.

projectRequired

The project to tie this file to.


filePathRequired
  • Type: string

the relative path in the project to put the file.


optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Writes the file to the project's output directory.
addPatterns
Add ignore patterns.
exclude
Ignore the files that match these patterns.
include
Always include the specified file patterns.
removePatterns
Removes patterns previously added from the ignore file.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Writes the file to the project's output directory.

addPatterns
public addPatterns(patterns: string): void

Add ignore patterns.

Files that match this pattern will be ignored. If the pattern starts with a negation mark !, files that match will not be ignored.

Comment lines (start with #) and blank lines ("") are filtered by default but can be included using options specified when instantiating the component.

patternsRequired
  • Type: string

Ignore patterns.


exclude
public exclude(patterns: string): void

Ignore the files that match these patterns.

patternsRequired
  • Type: string

The patterns to match.


include
public include(patterns: string): void

Always include the specified file patterns.

patternsRequired
  • Type: string

Patterns to include in git commits.


removePatterns
public removePatterns(patterns: string): void

Removes patterns previously added from the ignore file.

If addPattern() is called after this, the pattern will be added again.

patternsRequired
  • Type: string

patters to remove.


Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { IgnoreFile } from 'projen'

IgnoreFile.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { IgnoreFile } from 'projen'

IgnoreFile.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
absolutePath
stringThe absolute path of this file.
path
stringThe file path, relative to the project's outdir.
changed
booleanIndicates if the file has been changed during synthesis.
marker
stringThe projen marker, used to identify files as projen-generated.
executable
booleanIndicates if the file should be marked as executable.
readonly
booleanIndicates if the file should be read-only or read-write.
filterCommentLines
booleanNo description.
filterEmptyLines
booleanNo description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

absolutePathRequired
public readonly absolutePath: string;
  • Type: string

The absolute path of this file.


pathRequired
public readonly path: string;
  • Type: string

The file path, relative to the project's outdir.


changedOptional
public readonly changed: boolean;
  • Type: boolean

Indicates if the file has been changed during synthesis.

This property is only available in postSynthesize() hooks. If this is undefined, the file has not been synthesized yet.


markerOptional
public readonly marker: string;
  • Type: string

The projen marker, used to identify files as projen-generated.

Value is undefined if the project is being ejected.


executableRequired
public readonly executable: boolean;
  • Type: boolean

Indicates if the file should be marked as executable.


readonlyRequired
public readonly readonly: boolean;
  • Type: boolean

Indicates if the file should be read-only or read-write.


filterCommentLinesRequired
public readonly filterCommentLines: boolean;
  • Type: boolean

filterEmptyLinesRequired
public readonly filterEmptyLines: boolean;
  • Type: boolean

IniFile

Represents an INI file.

Initializers

import { IniFile } from 'projen'

new IniFile(project: Project, filePath: string, options: IniFileOptions)
NameTypeDescription
project
Project
No description.
filePath
stringNo description.
options
IniFileOptions
No description.

projectRequired

filePathRequired
  • Type: string

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Writes the file to the project's output directory.
addDeletionOverride
Syntactic sugar for addOverride(path, undefined).
addOverride
Adds an override to the synthesized object file.
addToArray
Adds to an array in the synthesized object file.
patch
Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Writes the file to the project's output directory.

addDeletionOverride
public addDeletionOverride(path: string): void

Syntactic sugar for addOverride(path, undefined).

pathRequired
  • Type: string

The path of the value to delete.


addOverride
public addOverride(path: string, value: any): void

Adds an override to the synthesized object file.

If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example,

project.tsconfig.file.addOverride('compilerOptions.alwaysStrict', true);
project.tsconfig.file.addOverride('compilerOptions.lib', ['dom', 'dom.iterable', 'esnext']);

would add the overrides

"compilerOptions": {
"alwaysStrict": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
]
...
}
...
pathRequired
  • Type: string

The path of the property, you can use dot notation to override values in complex types.

Any intermediate keys will be created as needed.


valueRequired
  • Type: any

The value.

Could be primitive or complex.


addToArray
public addToArray(path: string, values: any): void

Adds to an array in the synthesized object file.

If the array is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example, with the following object file

"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["es2019"]
...
}
...
project.tsconfig.file.addToArray('compilerOptions.exclude', 'coverage');
project.tsconfig.file.addToArray('compilerOptions.lib', 'dom', 'dom.iterable', 'esnext');

would result in the following object file

"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["es2019", "dom", "dom.iterable", "esnext"]
...
}
...
pathRequired
  • Type: string

The path of the property, you can use dot notation to att to arrays in complex types.

Any intermediate keys will be created as needed.


valuesRequired
  • Type: any

The values to add.

Could be primitive or complex.


patch
public patch(patches: JsonPatch): void

Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information.

For example, with the following object file

"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["es2019"]
...
}
...
project.tsconfig.file.patch(JsonPatch.add("/compilerOptions/exclude/-", "coverage"));
project.tsconfig.file.patch(JsonPatch.replace("/compilerOptions/lib", ["dom", "dom.iterable", "esnext"]));

would result in the following object file

"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["dom", "dom.iterable", "esnext"]
...
}
...
patchesRequired

The patch operations to apply.


Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { IniFile } from 'projen'

IniFile.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { IniFile } from 'projen'

IniFile.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
absolutePath
stringThe absolute path of this file.
path
stringThe file path, relative to the project's outdir.
changed
booleanIndicates if the file has been changed during synthesis.
marker
stringThe projen marker, used to identify files as projen-generated.
executable
booleanIndicates if the file should be marked as executable.
readonly
booleanIndicates if the file should be read-only or read-write.
omitEmpty
booleanIndicates if empty objects and arrays are omitted from the output object.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

absolutePathRequired
public readonly absolutePath: string;
  • Type: string

The absolute path of this file.


pathRequired
public readonly path: string;
  • Type: string

The file path, relative to the project's outdir.


changedOptional
public readonly changed: boolean;
  • Type: boolean

Indicates if the file has been changed during synthesis.

This property is only available in postSynthesize() hooks. If this is undefined, the file has not been synthesized yet.


markerOptional
public readonly marker: string;
  • Type: string

The projen marker, used to identify files as projen-generated.

Value is undefined if the project is being ejected.


executableRequired
public readonly executable: boolean;
  • Type: boolean

Indicates if the file should be marked as executable.


readonlyRequired
public readonly readonly: boolean;
  • Type: boolean

Indicates if the file should be read-only or read-write.


omitEmptyRequired
public readonly omitEmpty: boolean;
  • Type: boolean

Indicates if empty objects and arrays are omitted from the output object.


JsonFile

Represents a JSON file.

Initializers

import { JsonFile } from 'projen'

new JsonFile(scope: IConstruct, filePath: string, options: JsonFileOptions)
NameTypeDescription
scope
constructs.IConstructNo description.
filePath
stringNo description.
options
JsonFileOptions
No description.

scopeRequired
  • Type: constructs.IConstruct

filePathRequired
  • Type: string

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Writes the file to the project's output directory.
addDeletionOverride
Syntactic sugar for addOverride(path, undefined).
addOverride
Adds an override to the synthesized object file.
addToArray
Adds to an array in the synthesized object file.
patch
Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Writes the file to the project's output directory.

addDeletionOverride
public addDeletionOverride(path: string): void

Syntactic sugar for addOverride(path, undefined).

pathRequired
  • Type: string

The path of the value to delete.


addOverride
public addOverride(path: string, value: any): void

Adds an override to the synthesized object file.

If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example,

project.tsconfig.file.addOverride('compilerOptions.alwaysStrict', true);
project.tsconfig.file.addOverride('compilerOptions.lib', ['dom', 'dom.iterable', 'esnext']);

would add the overrides

"compilerOptions": {
"alwaysStrict": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
]
...
}
...
pathRequired
  • Type: string

The path of the property, you can use dot notation to override values in complex types.

Any intermediate keys will be created as needed.


valueRequired
  • Type: any

The value.

Could be primitive or complex.


addToArray
public addToArray(path: string, values: any): void

Adds to an array in the synthesized object file.

If the array is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example, with the following object file

"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["es2019"]
...
}
...
project.tsconfig.file.addToArray('compilerOptions.exclude', 'coverage');
project.tsconfig.file.addToArray('compilerOptions.lib', 'dom', 'dom.iterable', 'esnext');

would result in the following object file

"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["es2019", "dom", "dom.iterable", "esnext"]
...
}
...
pathRequired
  • Type: string

The path of the property, you can use dot notation to att to arrays in complex types.

Any intermediate keys will be created as needed.


valuesRequired
  • Type: any

The values to add.

Could be primitive or complex.


patch
public patch(patches: JsonPatch): void

Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information.

For example, with the following object file

"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["es2019"]
...
}
...
project.tsconfig.file.patch(JsonPatch.add("/compilerOptions/exclude/-", "coverage"));
project.tsconfig.file.patch(JsonPatch.replace("/compilerOptions/lib", ["dom", "dom.iterable", "esnext"]));

would result in the following object file

"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["dom", "dom.iterable", "esnext"]
...
}
...
patchesRequired

The patch operations to apply.


Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { JsonFile } from 'projen'

JsonFile.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { JsonFile } from 'projen'

JsonFile.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
absolutePath
stringThe absolute path of this file.
path
stringThe file path, relative to the project's outdir.
changed
booleanIndicates if the file has been changed during synthesis.
marker
stringThe projen marker, used to identify files as projen-generated.
executable
booleanIndicates if the file should be marked as executable.
readonly
booleanIndicates if the file should be read-only or read-write.
omitEmpty
booleanIndicates if empty objects and arrays are omitted from the output object.
supportsComments
booleanNo description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

absolutePathRequired
public readonly absolutePath: string;
  • Type: string

The absolute path of this file.


pathRequired
public readonly path: string;
  • Type: string

The file path, relative to the project's outdir.


changedOptional
public readonly changed: boolean;
  • Type: boolean

Indicates if the file has been changed during synthesis.

This property is only available in postSynthesize() hooks. If this is undefined, the file has not been synthesized yet.


markerOptional
public readonly marker: string;
  • Type: string

The projen marker, used to identify files as projen-generated.

Value is undefined if the project is being ejected.


executableRequired
public readonly executable: boolean;
  • Type: boolean

Indicates if the file should be marked as executable.


readonlyRequired
public readonly readonly: boolean;
  • Type: boolean

Indicates if the file should be read-only or read-write.


omitEmptyRequired
public readonly omitEmpty: boolean;
  • Type: boolean

Indicates if empty objects and arrays are omitted from the output object.


supportsCommentsRequired
public readonly supportsComments: boolean;
  • Type: boolean

License

Initializers

import { License } from 'projen'

new License(project: Project, options: LicenseOptions)
NameTypeDescription
project
Project
No description.
options
LicenseOptions
No description.

projectRequired

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Writes the file to the project's output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Writes the file to the project's output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { License } from 'projen'

License.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { License } from 'projen'

License.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
absolutePath
stringThe absolute path of this file.
path
stringThe file path, relative to the project's outdir.
changed
booleanIndicates if the file has been changed during synthesis.
marker
stringThe projen marker, used to identify files as projen-generated.
executable
booleanIndicates if the file should be marked as executable.
readonly
booleanIndicates if the file should be read-only or read-write.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

absolutePathRequired
public readonly absolutePath: string;
  • Type: string

The absolute path of this file.


pathRequired
public readonly path: string;
  • Type: string

The file path, relative to the project's outdir.


changedOptional
public readonly changed: boolean;
  • Type: boolean

Indicates if the file has been changed during synthesis.

This property is only available in postSynthesize() hooks. If this is undefined, the file has not been synthesized yet.


markerOptional
public readonly marker: string;
  • Type: string

The projen marker, used to identify files as projen-generated.

Value is undefined if the project is being ejected.


executableRequired
public readonly executable: boolean;
  • Type: boolean

Indicates if the file should be marked as executable.


readonlyRequired
public readonly readonly: boolean;
  • Type: boolean

Indicates if the file should be read-only or read-write.


Logger

Project-level logging utilities.

Initializers

import { Logger } from 'projen'

new Logger(scope: IConstruct, options?: LoggerOptions)
NameTypeDescription
scope
constructs.IConstructNo description.
options
LoggerOptions
No description.

scopeRequired
  • Type: constructs.IConstruct

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
debug
Log a message to stderr with DEBUG severity.
error
Log a message to stderr with ERROR severity.
info
Log a message to stderr with INFO severity.
log
Log a message to stderr with a given logging level.
verbose
Log a message to stderr with VERBOSE severity.
warn
Log a message to stderr with WARN severity.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

debug
public debug(text: any): void

Log a message to stderr with DEBUG severity.

textRequired
  • Type: any

strings or objects to print.


error
public error(text: any): void

Log a message to stderr with ERROR severity.

textRequired
  • Type: any

strings or objects to print.


info
public info(text: any): void

Log a message to stderr with INFO severity.

textRequired
  • Type: any

strings or objects to print.


log
public log(level: LogLevel, text: any): void

Log a message to stderr with a given logging level.

The message will be printed as long as logger.level is set to the message's severity or higher.

levelRequired

Logging verbosity.


textRequired
  • Type: any

strings or objects to print.


verbose
public verbose(text: any): void

Log a message to stderr with VERBOSE severity.

textRequired
  • Type: any

strings or objects to print.


warn
public warn(text: any): void

Log a message to stderr with WARN severity.

textRequired
  • Type: any

strings or objects to print.


Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { Logger } from 'projen'

Logger.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { Logger } from 'projen'

Logger.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

Makefile

Minimal Makefile.

Initializers

import { Makefile } from 'projen'

new Makefile(project: Project, filePath: string, options?: MakefileOptions)
NameTypeDescription
project
Project
No description.
filePath
stringNo description.
options
MakefileOptions
No description.

projectRequired

filePathRequired
  • Type: string

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Writes the file to the project's output directory.
addAll
Add a target to all.
addAlls
Add multiple targets to all.
addRule
Add a rule to the Makefile.
addRules
Add multiple rules to the Makefile.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Writes the file to the project's output directory.

addAll
public addAll(target: string): Makefile

Add a target to all.

targetRequired
  • Type: string

addAlls
public addAlls(targets: string): Makefile

Add multiple targets to all.

targetsRequired
  • Type: string

addRule
public addRule(rule: Rule): Makefile

Add a rule to the Makefile.

ruleRequired

addRules
public addRules(rules: Rule): Makefile

Add multiple rules to the Makefile.

rulesRequired

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { Makefile } from 'projen'

Makefile.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { Makefile } from 'projen'

Makefile.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
absolutePath
stringThe absolute path of this file.
path
stringThe file path, relative to the project's outdir.
changed
booleanIndicates if the file has been changed during synthesis.
marker
stringThe projen marker, used to identify files as projen-generated.
executable
booleanIndicates if the file should be marked as executable.
readonly
booleanIndicates if the file should be read-only or read-write.
rules
Rule[]
List of rule definitions.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

absolutePathRequired
public readonly absolutePath: string;
  • Type: string

The absolute path of this file.


pathRequired
public readonly path: string;
  • Type: string

The file path, relative to the project's outdir.


changedOptional
public readonly changed: boolean;
  • Type: boolean

Indicates if the file has been changed during synthesis.

This property is only available in postSynthesize() hooks. If this is undefined, the file has not been synthesized yet.


markerOptional
public readonly marker: string;
  • Type: string

The projen marker, used to identify files as projen-generated.

Value is undefined if the project is being ejected.


executableRequired
public readonly executable: boolean;
  • Type: boolean

Indicates if the file should be marked as executable.


readonlyRequired
public readonly readonly: boolean;
  • Type: boolean

Indicates if the file should be read-only or read-write.


rulesRequired
public readonly rules: Rule[];

List of rule definitions.


ObjectFile

Represents an Object file.

Initializers

import { ObjectFile } from 'projen'

new ObjectFile(scope: IConstruct, filePath: string, options: ObjectFileOptions)
NameTypeDescription
scope
constructs.IConstructNo description.
filePath
stringNo description.
options
ObjectFileOptions
No description.

scopeRequired
  • Type: constructs.IConstruct

filePathRequired
  • Type: string

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Writes the file to the project's output directory.
addDeletionOverride
Syntactic sugar for addOverride(path, undefined).
addOverride
Adds an override to the synthesized object file.
addToArray
Adds to an array in the synthesized object file.
patch
Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Writes the file to the project's output directory.

addDeletionOverride
public addDeletionOverride(path: string): void

Syntactic sugar for addOverride(path, undefined).

pathRequired
  • Type: string

The path of the value to delete.


addOverride
public addOverride(path: string, value: any): void

Adds an override to the synthesized object file.

If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example,

project.tsconfig.file.addOverride('compilerOptions.alwaysStrict', true);
project.tsconfig.file.addOverride('compilerOptions.lib', ['dom', 'dom.iterable', 'esnext']);

would add the overrides

"compilerOptions": {
"alwaysStrict": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
]
...
}
...
pathRequired
  • Type: string

The path of the property, you can use dot notation to override values in complex types.

Any intermediate keys will be created as needed.


valueRequired
  • Type: any

The value.

Could be primitive or complex.


addToArray
public addToArray(path: string, values: any): void

Adds to an array in the synthesized object file.

If the array is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example, with the following object file

"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["es2019"]
...
}
...
project.tsconfig.file.addToArray('compilerOptions.exclude', 'coverage');
project.tsconfig.file.addToArray('compilerOptions.lib', 'dom', 'dom.iterable', 'esnext');

would result in the following object file

"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["es2019", "dom", "dom.iterable", "esnext"]
...
}
...
pathRequired
  • Type: string

The path of the property, you can use dot notation to att to arrays in complex types.

Any intermediate keys will be created as needed.


valuesRequired
  • Type: any

The values to add.

Could be primitive or complex.


patch
public patch(patches: JsonPatch): void

Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information.

For example, with the following object file

"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["es2019"]
...
}
...
project.tsconfig.file.patch(JsonPatch.add("/compilerOptions/exclude/-", "coverage"));
project.tsconfig.file.patch(JsonPatch.replace("/compilerOptions/lib", ["dom", "dom.iterable", "esnext"]));

would result in the following object file

"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["dom", "dom.iterable", "esnext"]
...
}
...
patchesRequired

The patch operations to apply.


Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { ObjectFile } from 'projen'

ObjectFile.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { ObjectFile } from 'projen'

ObjectFile.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
absolutePath
stringThe absolute path of this file.
path
stringThe file path, relative to the project's outdir.
changed
booleanIndicates if the file has been changed during synthesis.
marker
stringThe projen marker, used to identify files as projen-generated.
executable
booleanIndicates if the file should be marked as executable.
readonly
booleanIndicates if the file should be read-only or read-write.
omitEmpty
booleanIndicates if empty objects and arrays are omitted from the output object.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

absolutePathRequired
public readonly absolutePath: string;
  • Type: string

The absolute path of this file.


pathRequired
public readonly path: string;
  • Type: string

The file path, relative to the project's outdir.


changedOptional
public readonly changed: boolean;
  • Type: boolean

Indicates if the file has been changed during synthesis.

This property is only available in postSynthesize() hooks. If this is undefined, the file has not been synthesized yet.


markerOptional
public readonly marker: string;
  • Type: string

The projen marker, used to identify files as projen-generated.

Value is undefined if the project is being ejected.


executableRequired
public readonly executable: boolean;
  • Type: boolean

Indicates if the file should be marked as executable.


readonlyRequired
public readonly readonly: boolean;
  • Type: boolean

Indicates if the file should be read-only or read-write.


omitEmptyRequired
public readonly omitEmpty: boolean;
  • Type: boolean

Indicates if empty objects and arrays are omitted from the output object.


Project

Base project.

Initializers

import { Project } from 'projen'

new Project(options: ProjectOptions)
NameTypeDescription
options
ProjectOptions
No description.

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
addExcludeFromCleanup
Exclude the matching files from pre-synth cleanup.
addGitIgnore
Adds a .gitignore pattern.
addPackageIgnore
Exclude these files from the bundled package.
addTask
Adds a new task to this project.
addTip
Prints a "tip" message during synthesis.
annotateGenerated
Consider a set of files as "generated".
postSynthesize
Called after all components are synthesized.
preSynthesize
Called before all components are synthesized.
removeTask
Removes a task from a project.
runTaskCommand
Returns the shell command to execute in order to run a task.
synth
Synthesize all project files into outdir.
tryFindFile
Finds a file at the specified relative path within this project and all its subprojects.
tryFindJsonFile
Finds a json file by name.
tryFindObjectFile
Finds an object file (like JsonFile, YamlFile, etc.) by name.
tryRemoveFile
Finds a file at the specified relative path within this project and removes it.

toString
public toString(): string

Returns a string representation of this construct.

addExcludeFromCleanup
public addExcludeFromCleanup(globs: string): void

Exclude the matching files from pre-synth cleanup.

Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.

globsRequired
  • Type: string

The glob patterns to match.


addGitIgnore
public addGitIgnore(pattern: string): void

Adds a .gitignore pattern.

patternRequired
  • Type: string

The glob pattern to ignore.


addPackageIgnore
public addPackageIgnore(_pattern: string): void

Exclude these files from the bundled package.

Implemented by project types based on the packaging mechanism. For example, NodeProject delegates this to .npmignore.

_patternRequired
  • Type: string

The glob pattern to exclude.


addTask
public addTask(name: string, props?: TaskOptions): Task

Adds a new task to this project.

This will fail if the project already has a task with this name.

nameRequired
  • Type: string

The task name to add.


propsOptional

Task properties.


addTip
public addTip(message: string): void

Prints a "tip" message during synthesis.

messageRequired
  • Type: string

The message.


annotateGenerated
public annotateGenerated(_glob: string): void

Consider a set of files as "generated".

This method is implemented by derived classes and used for example, to add git attributes to tell GitHub that certain files are generated.

_globRequired
  • Type: string

the glob pattern to match (could be a file path).


postSynthesize
public postSynthesize(): void

Called after all components are synthesized.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before all components are synthesized.

removeTask
public removeTask(name: string): Task

Removes a task from a project.

nameRequired
  • Type: string

The name of the task to remove.


runTaskCommand
public runTaskCommand(task: Task): string

Returns the shell command to execute in order to run a task.

By default, this is npx projen@<version> <task>

taskRequired

The task for which the command is required.


synth
public synth(): void

Synthesize all project files into outdir.

  1. Call "this.preSynthesize()"
  2. Delete all generated files
  3. Synthesize all subprojects
  4. Synthesize all components of this project
  5. Call "postSynthesize()" for all components of this project
  6. Call "this.postSynthesize()"
tryFindFile
public tryFindFile(filePath: string): FileBase

Finds a file at the specified relative path within this project and all its subprojects.

filePathRequired
  • Type: string

The file path.

If this path is relative, it will be resolved from the root of this project.


tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile

Finds a json file by name.

filePathRequired
  • Type: string

The file path.


tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile

Finds an object file (like JsonFile, YamlFile, etc.) by name.

filePathRequired
  • Type: string

The file path.


tryRemoveFile
public tryRemoveFile(filePath: string): FileBase

Finds a file at the specified relative path within this project and removes it.

filePathRequired
  • Type: string

The file path.

If this path is relative, it will be resolved from the root of this project.


Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isProject
Test whether the given construct is a project.
of
Find the closest ancestor project for given construct.

isConstruct
import { Project } from 'projen'

Project.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isProject
import { Project } from 'projen'

Project.isProject(x: any)

Test whether the given construct is a project.

xRequired
  • Type: any

of
import { Project } from 'projen'

Project.of(construct: IConstruct)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired
  • Type: constructs.IConstruct

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
buildTask
Task
No description.
commitGenerated
booleanWhether to commit the managed files by default.
compileTask
Task
No description.
components
Component[]
Returns all the components within this project.
deps
Dependencies
Project dependencies.
ejected
booleanWhether or not the project is being ejected.
files
FileBase[]
All files in this project.
gitattributes
GitAttributesFile
The .gitattributes file for this repository.
gitignore
IgnoreFile
.gitignore.
logger
Logger
Logging utilities.
name
stringProject name.
outdir
stringAbsolute output directory of this project.
packageTask
Task
No description.
postCompileTask
Task
No description.
preCompileTask
Task
No description.
projectBuild
ProjectBuild
Manages the build process of the project.
projenCommand
stringThe command to use in order to run the projen CLI.
root
Project
The root project.
subprojects
Project[]
Returns all the subprojects within this project.
tasks
Tasks
Project tasks.
testTask
Task
No description.
defaultTask
Task
This is the "default" task, the one that executes "projen".
initProject
InitProject
The options used when this project is bootstrapped via projen new.
parent
Project
A parent project.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


buildTaskRequired
public readonly buildTask: Task;

commitGeneratedRequired
public readonly commitGenerated: boolean;
  • Type: boolean

Whether to commit the managed files by default.


compileTaskRequired
public readonly compileTask: Task;

componentsRequired
public readonly components: Component[];

Returns all the components within this project.


depsRequired
public readonly deps: Dependencies;

Project dependencies.


ejectedRequired
public readonly ejected: boolean;
  • Type: boolean

Whether or not the project is being ejected.


filesRequired
public readonly files: FileBase[];

All files in this project.


gitattributesRequired
public readonly gitattributes: GitAttributesFile;

The .gitattributes file for this repository.


gitignoreRequired
public readonly gitignore: IgnoreFile;

.gitignore.


loggerRequired
public readonly logger: Logger;

Logging utilities.


nameRequired
public readonly name: string;
  • Type: string

Project name.


outdirRequired
public readonly outdir: string;
  • Type: string

Absolute output directory of this project.


packageTaskRequired
public readonly packageTask: Task;

postCompileTaskRequired
public readonly postCompileTask: Task;

preCompileTaskRequired
public readonly preCompileTask: Task;

projectBuildRequired
public readonly projectBuild: ProjectBuild;

Manages the build process of the project.


projenCommandRequired
public readonly projenCommand: string;
  • Type: string

The command to use in order to run the projen CLI.


rootRequired
public readonly root: Project;

The root project.


subprojectsRequired
public readonly subprojects: Project[];

Returns all the subprojects within this project.


tasksRequired
public readonly tasks: Tasks;

Project tasks.


testTaskRequired
public readonly testTask: Task;

defaultTaskOptional
public readonly defaultTask: Task;

This is the "default" task, the one that executes "projen".

Undefined if the project is being ejected.


initProjectOptional
public readonly initProject: InitProject;

The options used when this project is bootstrapped via projen new.

It includes the original set of options passed to the CLI and also the JSII FQN of the project type.


parentOptional
public readonly parent: Project;

A parent project.

If undefined, this is the root project.


Constants

NameTypeDescription
DEFAULT_TASK
stringThe name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
public readonly DEFAULT_TASK: string;
  • Type: string

The name of the default task (the task executed when projen is run without arguments).

Normally this task should synthesize the project files.


ProjectBuild

Manages a standard build process for all projects.

Build spawns these tasks in order:

  1. default
  2. pre-compile
  3. compile
  4. post-compile
  5. test
  6. package

Initializers

import { ProjectBuild } from 'projen'

new ProjectBuild(project: Project)
NameTypeDescription
project
Project
No description.

projectRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { ProjectBuild } from 'projen'

ProjectBuild.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { ProjectBuild } from 'projen'

ProjectBuild.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
buildTask
Task
The task responsible for a full release build.
compileTask
Task
Compiles the code.
packageTask
Task
The "package" task.
postCompileTask
Task
Post-compile task.
preCompileTask
Task
Pre-compile task.
testTask
Task
Tests the code.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

buildTaskRequired
public readonly buildTask: Task;

The task responsible for a full release build.


compileTaskRequired
public readonly compileTask: Task;

Compiles the code.

By default for node.js projects this task is empty.


packageTaskRequired
public readonly packageTask: Task;

The "package" task.


postCompileTaskRequired
public readonly postCompileTask: Task;

Post-compile task.


preCompileTaskRequired
public readonly preCompileTask: Task;

Pre-compile task.


testTaskRequired
public readonly testTask: Task;

Tests the code.


ProjectTree

Initializers

import { ProjectTree } from 'projen'

new ProjectTree(project: Project)
NameTypeDescription
project
Project
No description.

projectRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { ProjectTree } from 'projen'

ProjectTree.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { ProjectTree } from 'projen'

ProjectTree.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
file
JsonFile
No description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

fileRequired
public readonly file: JsonFile;

Projenrc

Initializers

import { Projenrc } from 'projen'

new Projenrc(project: Project, options?: ProjenrcJsonOptions)
NameTypeDescription
project
Project
No description.
options
ProjenrcJsonOptions
No description.

projectRequired

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.
of
Returns the Projenrc instance associated with a project or undefined if there is no Projenrc.

isConstruct
import { Projenrc } from 'projen'

Projenrc.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { Projenrc } from 'projen'

Projenrc.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

of
import { Projenrc } from 'projen'

Projenrc.of(project: Project)

Returns the Projenrc instance associated with a project or undefined if there is no Projenrc.

projectRequired

The project.


Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
filePath
stringThe path of the projenrc file.

nodeRequired
  • Deprecated: use ProjenrcJson
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
  • Deprecated: use ProjenrcJson
public readonly project: Project;

filePathRequired
  • Deprecated: use ProjenrcJson
public readonly filePath: string;
  • Type: string

The path of the projenrc file.


ProjenrcFile

A component representing the projen runtime configuration.

Initializers

import { ProjenrcFile } from 'projen'

new ProjenrcFile(scope: IConstruct, id?: string)
NameTypeDescription
scope
constructs.IConstructNo description.
id
stringNo description.

scopeRequired
  • Type: constructs.IConstruct

idOptional
  • Type: string

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.
of
Returns the Projenrc instance associated with a project or undefined if there is no Projenrc.

isConstruct
import { ProjenrcFile } from 'projen'

ProjenrcFile.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { ProjenrcFile } from 'projen'

ProjenrcFile.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

of
import { ProjenrcFile } from 'projen'

ProjenrcFile.of(project: Project)

Returns the Projenrc instance associated with a project or undefined if there is no Projenrc.

projectRequired

The project.


Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
filePath
stringThe path of the projenrc file.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

filePathRequired
public readonly filePath: string;
  • Type: string

The path of the projenrc file.


ProjenrcJson

Sets up a project to use JSON for projenrc.

Initializers

import { ProjenrcJson } from 'projen'

new ProjenrcJson(project: Project, options?: ProjenrcJsonOptions)
NameTypeDescription
project
Project
No description.
options
ProjenrcJsonOptions
No description.

projectRequired

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.
of
Returns the Projenrc instance associated with a project or undefined if there is no Projenrc.

isConstruct
import { ProjenrcJson } from 'projen'

ProjenrcJson.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { ProjenrcJson } from 'projen'

ProjenrcJson.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

of
import { ProjenrcJson } from 'projen'

ProjenrcJson.of(project: Project)

Returns the Projenrc instance associated with a project or undefined if there is no Projenrc.

projectRequired

The project.


Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
filePath
stringThe path of the projenrc file.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

filePathRequired
public readonly filePath: string;
  • Type: string

The path of the projenrc file.


Renovatebot

Defines renovatebot configuration for projen project.

Ignores the versions controlled by Projen.

Initializers

import { Renovatebot } from 'projen'

new Renovatebot(project: Project, options?: RenovatebotOptions)
NameTypeDescription
project
Project
No description.
options
RenovatebotOptions
No description.

projectRequired

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { Renovatebot } from 'projen'

Renovatebot.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { Renovatebot } from 'projen'

Renovatebot.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
Project
No description.
file
JsonFile
The file holding the renovatebot configuration.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;

fileRequired
public readonly file: JsonFile;

The file holding the renovatebot configuration.


SampleDir

Renders the given files into the directory if the directory does not exist.

Use this to create sample code files

Initializers

import { SampleDir } from 'projen'

new SampleDir(project: Project, dir: string, options: SampleDirOptions)
NameTypeDescription
project
Project
Parent project to add files to.
dir
stringdirectory to add files to.
options
SampleDirOptions
options for which files to create.

projectRequired

Parent project to add files to.


dirRequired
  • Type: string

directory to add files to.

If directory already exists, nothing is added.


optionsRequired

options for which files to create.


Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Function