Skip to main content

API Reference

Submodules ​

The following submodules are available:

Constructs ​

AiInstructions ​

Generates instruction files for AI coding assistants with projen-specific guidance.

This component creates configuration files that help AI tools like GitHub Copilot, Cursor IDE, Claude Code, and Amazon Q understand that the project is managed by projen and should follow projen conventions.

Example

const project = new TypeScriptProject({
name: "my-project",
});

// Basic usage - generates files for all supported AI agents
new AiInstructions(project);

// Custom usage - specify which agents and add custom instructions
new AiInstructions(project, {
agents: [AiAgent.GITHUB_COPILOT, AiAgent.CURSOR],
agentSpecificInstructions: {
[AiAgent.GITHUB_COPILOT]: ["Always use descriptive commit messages."],
},
});

// Add more instructions after instantiation
const ai = new AiInstructions(project);
ai.addInstructions("Use functional programming patterns.");
ai.addInstructions("Always write comprehensive tests.");

Initializers ​

import { AiInstructions } from 'projen'

new AiInstructions(project: Project, options?: AiInstructionsOptions)
NameTypeDescription
project
Project
No description.
options
AiInstructionsOptions
No description.

projectRequired ​

optionsOptional ​

Methods ​

NameDescription
toString
Returns a string representation of this construct.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.
addAgentSpecificInstructions
Add instructions for a specific AI agent.
addInstructions
Adds instructions that will be included for all selected AI agents.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Synthesizes files to the project output directory.

addAgentSpecificInstructions ​
public addAgentSpecificInstructions(agent: AiAgent, instructions: ...string[]): void

Add instructions for a specific AI agent.

This can also be used to add instructions for an AI agent that was previously not enabled.

Example

aiInstructions.addAgentSpecificInstructions(AiAgent.GITHUB_COPILOT, "Use descriptive commit messages.");
agentRequired ​

The AI agent to add instructions for.


instructionsRequired ​
  • Type: ...string[]

The instruction(s) to add.


addInstructions ​
public addInstructions(instructions: ...string[]): void

Adds instructions that will be included for all selected AI agents.

Example

aiInstructions.addInstructions("Always use TypeScript strict mode.");
aiInstructions.addInstructions("Prefer functional programming.", "Avoid mutations.");
instructionsRequired ​
  • Type: ...string[]

The instructions to add.


Static Functions ​

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.
bestPractices
Returns development best practices instructions for AI agents.
projen
Returns projen-specific instructions for AI agents.

isConstruct ​
import { AiInstructions } from 'projen'

AiInstructions.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 { AiInstructions } from 'projen'

AiInstructions.isComponent(x: any)

Test whether the given construct is a component.

xRequired ​
  • Type: any

bestPractices ​
import { AiInstructions } from 'projen'

AiInstructions.bestPractices(project: Project)

Returns development best practices instructions for AI agents.

projectRequired ​

projen ​
import { AiInstructions } from 'projen'

AiInstructions.projen(project: Project)

Returns projen-specific instructions for AI agents.

projectRequired ​

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;

AiInstructionsFile ​

Initializers ​

import { AiInstructionsFile } from 'projen'

new AiInstructionsFile(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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Writes the file to the project's output directory.
diff
Returns a unified diff of the old and new file contents with context lines and hunk headers.
addInstructions
Adds instructions to the instruction file.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Writes the file to the project's output directory.

diff ​
public diff(colorize?: boolean, contextLines?: number): string[]

Returns a unified diff of the old and new file contents with context lines and hunk headers.

Only available after synthesis.

This is an expensive operation and should only be used on non time-critical code paths, like debug output.

colorizeOptional ​
  • Type: boolean

Whether to colorize the diff output.


contextLinesOptional ​
  • Type: number

Number of context lines around changes.


addInstructions ​
public addInstructions(instructions: ...string[]): void

Adds instructions to the instruction file.

instructionsRequired ​
  • Type: ...string[]

Static Functions ​

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

isConstruct ​
import { AiInstructionsFile } from 'projen'

AiInstructionsFile.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 { AiInstructionsFile } from 'projen'

AiInstructionsFile.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.
committed
booleanIndicates if the file will be committed.
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.


committedRequired ​
public readonly committed: boolean;
  • Type: boolean

Indicates if the file will be committed.


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.


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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.
addDependency
Adds a dependency to this project.
getDependency
Returns a dependency by name.
isDependencySatisfied
Checks if an existing dependency satisfies a dependency requirement.
removeDependency
Removes a dependency.
requestDependency
Request a dependency. Unlike addDependency, this merges intelligently with existing dependencies of the same name and type:.
tryGetDependency
Returns a dependency by name.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


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.


isDependencySatisfied ​
public isDependencySatisfied(name: string, type: DependencyType, expectedRange: string): boolean

Checks if an existing dependency satisfies a dependency requirement.

nameRequired ​
  • Type: string

The name of the dependency to check (without the version).


typeRequired ​

The dependency type.


expectedRangeRequired ​
  • Type: string

The version constraint to check (e.g. ^3.4.0). The constraint of the dependency must be a subset of the expected range to satisfy the requirements.


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.


requestDependency ​
public requestDependency(request: DependencyRequest): Dependency

Request a dependency. Unlike addDependency, this merges intelligently with existing dependencies of the same name and type:.

If the dep exists with a version that already satisfies the request, the version is not changed.

  • If the dep doesn't exist, it is added with the requested type/version.
  • If the dep exists but the versions don't intersect, an error is thrown.
  • If no type is provided, an existing dependency of any type will satisfy the request. If none exists, it is added as BUILD.
requestRequired ​

The dependency request.


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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
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.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Writes the file to the project's output directory.
diff
Returns a unified diff of the old and new file contents with context lines and hunk headers.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Writes the file to the project's output directory.

diff ​
public diff(colorize?: boolean, contextLines?: number): string[]

Returns a unified diff of the old and new file contents with context lines and hunk headers.

Only available after synthesis.

This is an expensive operation and should only be used on non time-critical code paths, like debug output.

colorizeOptional ​
  • Type: boolean

Whether to colorize the diff output.


contextLinesOptional ​
  • Type: number

Number of context lines around changes.


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.
committed
booleanIndicates if the file will be committed.
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.


committedRequired ​
public readonly committed: boolean;
  • Type: boolean

Indicates if the file will be committed.


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.


FutureComponent ​

A {@link Component} that is created detached from any project and attached to one later via {@link FutureComponent.attach}.

Like a regular component, but constructed without a project. It improves on a naive deferred component in three ways:

  • Use-before-attach is an error, not a silent footgun. The constructor hands the caller a guard proxy; touching project, node, synthesize() or any subclass feature before attach() throws.
  • No global shadow-tree leak. Each instance gets its own throwaway shadow root, so detached components never share an id counter and the root becomes garbage once the component is reparented on attach.
  • attach() returns the unwrapped component, so callers can opt out of the proxy entirely.

The constructor takes no arguments (super()). A subclass that needs options captures them itself, reading the local parameter inside its constructor - NOT this.options, which the guard blocks until attach.

class Worker extends FutureComponent {
private readonly options: WorkerOptions;
constructor(options: WorkerOptions = {}) {
super();
this.options = options; // set: allowed
}
protected init() {
// this.project is available here
}
}

const w = new Worker({ retries: 3 });
// w.project; // throws: not attached yet
const real = w.attach(project); // reparents, runs init(), returns the bare instance

Initializers ​

import { FutureComponent } from 'projen'

new FutureComponent()
NameTypeDescription

Methods ​

NameDescription
toString
Returns a string representation of this construct.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.
attach
Attach the component to a scope. Only now does it become usable.
tryAttach
Attach the component if it isn't already, without caring where.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Synthesizes files to the project output directory.

attach ​
public attach(scope: IConstruct, id?: string): FutureComponent

Attach the component to a scope. Only now does it become usable.

Returns the real, unwrapped component (not the proxy). A component may be attached exactly once; attaching an already-attached component throws (copy it first to attach a variant elsewhere). Use tryAttach() if you don't care whether it has already been attached.

scopeRequired ​
  • Type: constructs.IConstruct

idOptional ​
  • Type: string

tryAttach ​
public tryAttach(scope: IConstruct, id?: string): FutureComponent

Attach the component if it isn't already, without caring where.

Unlike attach(), never throws on an already-attached component: if attached anywhere at all, the existing instance is returned and scope is ignored. Use attach() when attaching to a specific scope is part of your contract and a pre-existing attachment elsewhere would be a bug.

scopeRequired ​
  • Type: constructs.IConstruct

idOptional ​
  • Type: string

Static Functions ​

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

isConstruct ​
import { FutureComponent } from 'projen'

FutureComponent.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 { FutureComponent } from 'projen'

FutureComponent.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.
attached
booleanWhether attach() has been called.

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

The tree node.


projectRequired ​
public readonly project: Project;

attachedRequired ​
public readonly attached: boolean;
  • Type: boolean

Whether attach() has been called.

A convenience for tests/introspection; prefer tryAttach() over reading this and branching.


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, options?: GitAttributesFileOptions)
NameTypeDescription
scope
constructs.IConstructNo description.
options
GitAttributesFileOptions
No description.

scopeRequired ​
  • Type: constructs.IConstruct

optionsOptional ​

Methods ​

NameDescription
toString
Returns a string representation of this construct.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Writes the file to the project's output directory.
diff
Returns a unified diff of the old and new file contents with context lines and hunk headers.
addAttributes
Maps a set of attributes to a set of files.
addLfsPattern
Add attributes necessary to mark these files as stored in LFS.
removeAttributes
Removes attributes from a set of files.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Writes the file to the project's output directory.

diff ​
public diff(colorize?: boolean, contextLines?: number): string[]

Returns a unified diff of the old and new file contents with context lines and hunk headers.

Only available after synthesis.

This is an expensive operation and should only be used on non time-critical code paths, like debug output.

colorizeOptional ​
  • Type: boolean

Whether to colorize the diff output.


contextLinesOptional ​
  • Type: number

Number of context lines around changes.


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

removeAttributes ​
public removeAttributes(glob: string, attributes: ...string[]): void

Removes attributes from a set of files.

If no attributes are provided, the glob pattern will be removed completely.

globRequired ​
  • Type: string

Glob pattern to modify.


attributesRequired ​
  • Type: ...string[]

Attributes to remove from matched files.


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.
committed
booleanIndicates if the file will be committed.
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.
endOfLine
EndOfLine
The default end of line character for text files.
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.


committedRequired ​
public readonly committed: boolean;
  • Type: boolean

Indicates if the file will be committed.


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.


endOfLineRequired ​
public readonly endOfLine: EndOfLine;

The default end of line character for text files.


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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
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.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Writes the file to the project's output directory.
diff
Returns a unified diff of the old and new file contents with context lines and hunk headers.
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.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Writes the file to the project's output directory.

diff ​
public diff(colorize?: boolean, contextLines?: number): string[]

Returns a unified diff of the old and new file contents with context lines and hunk headers.

Only available after synthesis.

This is an expensive operation and should only be used on non time-critical code paths, like debug output.

colorizeOptional ​
  • Type: boolean

Whether to colorize the diff output.


contextLinesOptional ​
  • Type: number

Number of context lines around changes.


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.
committed
booleanIndicates if the file will be committed.
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.


committedRequired ​
public readonly committed: boolean;
  • Type: boolean

Indicates if the file will be committed.


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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Writes the file to the project's output directory.
diff
Returns a unified diff of the old and new file contents with context lines and hunk headers.
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.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Writes the file to the project's output directory.

diff ​
public diff(colorize?: boolean, contextLines?: number): string[]

Returns a unified diff of the old and new file contents with context lines and hunk headers.

Only available after synthesis.

This is an expensive operation and should only be used on non time-critical code paths, like debug output.

colorizeOptional ​
  • Type: boolean

Whether to colorize the diff output.


contextLinesOptional ​
  • Type: number

Number of context lines around changes.


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": ["es2020"]
...
}
...
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": ["es2020", "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": ["es2020"]
...
}
...
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.
committed
booleanIndicates if the file will be committed.
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.


committedRequired ​
public readonly committed: boolean;
  • Type: boolean

Indicates if the file will be committed.


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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Writes the file to the project's output directory.
diff
Returns a unified diff of the old and new file contents with context lines and hunk headers.
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.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Writes the file to the project's output directory.

diff ​
public diff(colorize?: boolean, contextLines?: number): string[]

Returns a unified diff of the old and new file contents with context lines and hunk headers.

Only available after synthesis.

This is an expensive operation and should only be used on non time-critical code paths, like debug output.

colorizeOptional ​
  • Type: boolean

Whether to colorize the diff output.


contextLinesOptional ​
  • Type: number

Number of context lines around changes.


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": ["es2020"]
...
}
...
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": ["es2020", "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": ["es2020"]
...
}
...
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.
committed
booleanIndicates if the file will be committed.
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
booleanIndicates if the files supports comments.

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.


committedRequired ​
public readonly committed: boolean;
  • Type: boolean

Indicates if the file will be committed.


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

Indicates if the files supports comments.


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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Writes the file to the project's output directory.
diff
Returns a unified diff of the old and new file contents with context lines and hunk headers.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Writes the file to the project's output directory.

diff ​
public diff(colorize?: boolean, contextLines?: number): string[]

Returns a unified diff of the old and new file contents with context lines and hunk headers.

Only available after synthesis.

This is an expensive operation and should only be used on non time-critical code paths, like debug output.

colorizeOptional ​
  • Type: boolean

Whether to colorize the diff output.


contextLinesOptional ​
  • Type: number

Number of context lines around changes.


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.
committed
booleanIndicates if the file will be committed.
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.


committedRequired ​
public readonly committed: boolean;
  • Type: boolean

Indicates if the file will be committed.


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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
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.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Writes the file to the project's output directory.
diff
Returns a unified diff of the old and new file contents with context lines and hunk headers.
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.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Writes the file to the project's output directory.

diff ​
public diff(colorize?: boolean, contextLines?: number): string[]

Returns a unified diff of the old and new file contents with context lines and hunk headers.

Only available after synthesis.

This is an expensive operation and should only be used on non time-critical code paths, like debug output.

colorizeOptional ​
  • Type: boolean

Whether to colorize the diff output.


contextLinesOptional ​
  • Type: number

Number of context lines around changes.


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.
committed
booleanIndicates if the file will be committed.
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.


committedRequired ​
public readonly committed: boolean;
  • Type: boolean

Indicates if the file will be committed.


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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Writes the file to the project's output directory.
diff
Returns a unified diff of the old and new file contents with context lines and hunk headers.
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.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Writes the file to the project's output directory.

diff ​
public diff(colorize?: boolean, contextLines?: number): string[]

Returns a unified diff of the old and new file contents with context lines and hunk headers.

Only available after synthesis.

This is an expensive operation and should only be used on non time-critical code paths, like debug output.

colorizeOptional ​
  • Type: boolean

Whether to colorize the diff output.


contextLinesOptional ​
  • Type: number

Number of context lines around changes.


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": ["es2020"]
...
}
...
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": ["es2020", "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": ["es2020"]
...
}
...
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.
committed
booleanIndicates if the file will be committed.
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.


committedRequired ​
public readonly committed: boolean;
  • Type: boolean

Indicates if the file will be committed.


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.
with
Applies one or more mixins to 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.
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.
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.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


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.


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 "projectCreation()" for all components, only if the project is being created for the first time
  6. Call "postSynthesize()" for all components of this project
  7. Call "this.postSynthesize()"
  8. Call "postProjectCreation()" for all components, only if the project is being created for the first time
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.


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 ​
  • Deprecated: use the initProject argument passed to Component.projectCreation() instead.
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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


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 ​

Generates a .projen/tree.json file that provides a snapshot of your project's component hierarchy. This file includes metadata about each component such as file paths, types, and the projen version used.

The tree file is helpful for:

  • Understanding how your project is structured
  • Debugging component relationships
  • Verifying which versions synthesized the project

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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


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;

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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

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.


PropertiesFile ​

Represents a Java .properties file.

Properties files consist of key=value pairs, one per line, with # used for comments. This file format is commonly used by tools like SonarQube, Gradle, and other JVM-based ecosystem tools.

The object passed as obj can be a nested structure. Nested keys are flattened into dot-separated property keys on synthesis. For example, { sonar: { sources: "src" } } produces sonar.sources=src.

This means addOverride uses dot notation as a path separator, consistent with ObjectFile/JsonPatch semantics.

Example

new PropertiesFile(project, 'sonar-project.properties', {
obj: {
sonar: {
projectKey: 'my-project',
sources: 'src',
},
},
});

// Produces:
// sonar.projectKey=my-project
// sonar.sources=src

Initializers ​

import { PropertiesFile } from 'projen'

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

scopeRequired ​
  • Type: constructs.IConstruct

filePathRequired ​
  • Type: string

optionsRequired ​

Methods ​

NameDescription
toString
Returns a string representation of this construct.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Writes the file to the project's output directory.
diff
Returns a unified diff of the old and new file contents with context lines and hunk headers.
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.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Writes the file to the project's output directory.

diff ​
public diff(colorize?: boolean, contextLines?: number): string[]

Returns a unified diff of the old and new file contents with context lines and hunk headers.

Only available after synthesis.

This is an expensive operation and should only be used on non time-critical code paths, like debug output.

colorizeOptional ​
  • Type: boolean

Whether to colorize the diff output.


contextLinesOptional ​
  • Type: number

Number of context lines around changes.


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": ["es2020"]
...
}
...
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": ["es2020", "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": ["es2020"]
...
}
...
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 { PropertiesFile } from 'projen'

PropertiesFile.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 { PropertiesFile } from 'projen'

PropertiesFile.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.
committed
booleanIndicates if the file will be committed.
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.


committedRequired ​
public readonly committed: boolean;
  • Type: boolean

Indicates if the file will be committed.


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.


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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


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.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


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 { SampleDir } from 'projen'

SampleDir.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 { SampleDir } from 'projen'

SampleDir.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;

SampleFile ​

Produces a file with the given contents but only once, if the file doesn't already exist.

Use this for creating example code files or other resources.

Initializers ​

import { SampleFile } from 'projen'

new SampleFile(project: Project, filePath: string, options: SampleFileOptions)
NameTypeDescription
project
Project
- the project to tie this file to.
filePath
string- the relative path in the project to put the file.
options
SampleFileOptions
- the options for the file.

projectRequired ​

the project to tie this file to.


filePathRequired ​
  • Type: string

the relative path in the project to put the file.


optionsRequired ​

the options for the file.


Methods ​

NameDescription
toString
Returns a string representation of this construct.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


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 { SampleFile } from 'projen'

SampleFile.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 { SampleFile } from 'projen'

SampleFile.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;

SampleReadme ​

Represents a README.md sample file. You are expected to manage this file after creation.

Initializers ​

import { SampleReadme } from 'projen'

new SampleReadme(project: Project, props?: SampleReadmeProps)
NameTypeDescription
project
Project
No description.
props
SampleReadmeProps
No description.

projectRequired ​

propsOptional ​

Methods ​

NameDescription
toString
Returns a string representation of this construct.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


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 { SampleReadme } from 'projen'

SampleReadme.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 { SampleReadme } from 'projen'

SampleReadme.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;

ScriptRunner ​

A script runner that executes the entrypoint file directly.

A runner is a {@link FutureComponent}: it can be created standalone (e.g. in .projenrc.ts) and is attached to a project by whoever consumes it.

Initializers ​

import { ScriptRunner } from 'projen'

new ScriptRunner()
NameTypeDescription

Methods ​

NameDescription
toString
Returns a string representation of this construct.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.
attach
Attach the component to a scope. Only now does it become usable.
tryAttach
Attach the component if it isn't already, without caring where.
configFor
Produce the configuration to run the given entrypoint.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Synthesizes files to the project output directory.

attach ​
public attach(scope: IConstruct, id?: string): FutureComponent

Attach the component to a scope. Only now does it become usable.

Returns the real, unwrapped component (not the proxy). A component may be attached exactly once; attaching an already-attached component throws (copy it first to attach a variant elsewhere). Use tryAttach() if you don't care whether it has already been attached.

scopeRequired ​
  • Type: constructs.IConstruct

idOptional ​
  • Type: string

tryAttach ​
public tryAttach(scope: IConstruct, id?: string): FutureComponent

Attach the component if it isn't already, without caring where.

Unlike attach(), never throws on an already-attached component: if attached anywhere at all, the existing instance is returned and scope is ignored. Use attach() when attaching to a specific scope is part of your contract and a pre-existing attachment elsewhere would be a bug.

scopeRequired ​
  • Type: constructs.IConstruct

idOptional ​
  • Type: string

configFor ​
public configFor(entrypoint: string): RunScriptConfig

Produce the configuration to run the given entrypoint.

entrypointRequired ​
  • Type: string

Static Functions ​

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

isConstruct ​
import { ScriptRunner } from 'projen'

ScriptRunner.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 { ScriptRunner } from 'projen'

ScriptRunner.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.
attached
booleanWhether attach() has been called.

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

The tree node.


projectRequired ​
public readonly project: Project;

attachedRequired ​
public readonly attached: boolean;
  • Type: boolean

Whether attach() has been called.

A convenience for tests/introspection; prefer tryAttach() over reading this and branching.


SourceCode ​

Represents a source file.

Initializers ​

import { SourceCode } from 'projen'

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

projectRequired ​

filePathRequired ​
  • Type: string

optionsOptional ​

Methods ​

NameDescription
toString
Returns a string representation of this construct.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.
close
Decreases the indentation level and closes a code block.
line
Emit a line of code.
open
Opens a code block and increases the indentation level.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Synthesizes files to the project output directory.

close ​
public close(code?: string): void

Decreases the indentation level and closes a code block.

codeOptional ​
  • Type: string

The code after the block is closed (e.g. }).


line ​
public line(code?: string): void

Emit a line of code.

codeOptional ​
  • Type: string

The contents, if not specified, just adds a newline.


open ​
public open(code?: string): void

Opens a code block and increases the indentation level.

codeOptional ​
  • Type: string

The code before the block starts (e.g. export class {).


Static Functions ​

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

isConstruct ​
import { SourceCode } from 'projen'

SourceCode.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 { SourceCode } from 'projen'

SourceCode.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.
filePath
stringNo description.
marker
stringNo description.

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

The tree node.


projectRequired ​
public readonly project: Project;

filePathRequired ​
public readonly filePath: string;
  • Type: string

markerOptional ​
public readonly marker: string;
  • Type: string

Tasks ​

Defines and manages project tasks.

Tasks extend the projen CLI by adding subcommands to it. Task definitions are synthesized into .projen/tasks.json.

Initializers ​

import { Tasks } from 'projen'

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

projectRequired ​

Methods ​

NameDescription
toString
Returns a string representation of this construct.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.
addEnvironment
Adds global environment.
addTask
Adds a task to a project.
removeTask
Removes a task from a project.
resolveTasksManifest
No description.
runTask
Runs the specified task.
tryFind
Finds a task by name.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Synthesizes files to the project output directory.

addEnvironment ​
public addEnvironment(name: string, value: string): void

Adds global environment.

nameRequired ​
  • Type: string

Environment variable name.


valueRequired ​
  • Type: string

Value.


addTask ​
public addTask(name: string, options?: TaskOptions): Task

Adds a task to a project.

nameRequired ​
  • Type: string

The name of the task.


optionsOptional ​

Task options.


removeTask ​
public removeTask(name: string): Task

Removes a task from a project.

nameRequired ​
  • Type: string

The name of the task to remove.


resolveTasksManifest ​
public resolveTasksManifest(resolver: IResolver): TasksManifest
resolverRequired ​

runTask ​
public runTask(name: string, args?: (string | number)[]): void

Runs the specified task.

nameRequired ​
  • Type: string

The name of the task to run.


argsOptional ​
  • Type: string | number[]

Arguments to pass to the task.


tryFind ​
public tryFind(name: string): Task

Finds a task by name.

Returns undefined if the task cannot be found.

nameRequired ​
  • Type: string

The name of the task.


Static Functions ​

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

isConstruct ​
import { Tasks } from 'projen'

Tasks.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 { Tasks } from 'projen'

Tasks.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.
all
Task[]
All tasks.
env
{[ key: string ]: string}Returns a copy of the currently global environment for this project.
shell
TaskShell
The default shell used to run all task commands, or undefined for the built-in cross-platform projen shell.

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

The tree node.


projectRequired ​
public readonly project: Project;

allRequired ​
public readonly all: Task[];

All tasks.


envRequired ​
public readonly env: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Returns a copy of the currently global environment for this project.


shellOptional ​
public readonly shell: TaskShell;

The default shell used to run all task commands, or undefined for the built-in cross-platform projen shell.

Individual tasks and steps can override this. Sets the default shell used to run all task commands.

[{@link TaskCommonOptions.shell }]({@link TaskCommonOptions.shell })


TextFile ​

A text file.

Initializers ​

import { TextFile } from 'projen'

new TextFile(scope: IConstruct, filePath: string, options?: TextFileOptions)
NameTypeDescription
scope
constructs.IConstructNo description.
filePath
stringFile path.
options
TextFileOptions
Options.

scopeRequired ​
  • Type: constructs.IConstruct

filePathRequired ​
  • Type: string

File path.


optionsOptional ​

Options.


Methods ​

NameDescription
toString
Returns a string representation of this construct.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Writes the file to the project's output directory.
diff
Returns a unified diff of the old and new file contents with context lines and hunk headers.
addLine
Adds a line to the text file.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Writes the file to the project's output directory.

diff ​
public diff(colorize?: boolean, contextLines?: number): string[]

Returns a unified diff of the old and new file contents with context lines and hunk headers.

Only available after synthesis.

This is an expensive operation and should only be used on non time-critical code paths, like debug output.

colorizeOptional ​
  • Type: boolean

Whether to colorize the diff output.


contextLinesOptional ​
  • Type: number

Number of context lines around changes.


addLine ​
public addLine(line: string): void

Adds a line to the text file.

lineRequired ​
  • Type: string

the line to add (can use tokens).


Static Functions ​

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

isConstruct ​
import { TextFile } from 'projen'

TextFile.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 { TextFile } from 'projen'

TextFile.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.
committed
booleanIndicates if the file will be committed.
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.


committedRequired ​
public readonly committed: boolean;
  • Type: boolean

Indicates if the file will be committed.


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.


TomlFile ​

Represents a TOML file.

Initializers ​

import { TomlFile } from 'projen'

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

scopeRequired ​
  • Type: constructs.IConstruct

filePathRequired ​
  • Type: string

optionsRequired ​

Methods ​

NameDescription
toString
Returns a string representation of this construct.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Writes the file to the project's output directory.
diff
Returns a unified diff of the old and new file contents with context lines and hunk headers.
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.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Writes the file to the project's output directory.

diff ​
public diff(colorize?: boolean, contextLines?: number): string[]

Returns a unified diff of the old and new file contents with context lines and hunk headers.

Only available after synthesis.

This is an expensive operation and should only be used on non time-critical code paths, like debug output.

colorizeOptional ​
  • Type: boolean

Whether to colorize the diff output.


contextLinesOptional ​
  • Type: number

Number of context lines around changes.


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": ["es2020"]
...
}
...
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": ["es2020", "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": ["es2020"]
...
}
...
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 { TomlFile } from 'projen'

TomlFile.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 { TomlFile } from 'projen'

TomlFile.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.
committed
booleanIndicates if the file will be committed.
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.


committedRequired ​
public readonly committed: boolean;
  • Type: boolean

Indicates if the file will be committed.


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.


Version ​

Initializers ​

import { Version } from 'projen'

new Version(scope: IConstruct, options: VersionOptions)
NameTypeDescription
scope
constructs.IConstructNo description.
options
VersionOptions
No description.

scopeRequired ​
  • Type: constructs.IConstruct

optionsRequired ​

Methods ​

NameDescription
toString
Returns a string representation of this construct.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Synthesizes files to the project output directory.
envForBranch
Return the environment variables to modify the bump command for release branches.

toString ​
public toString(): string

Returns a string representation of this construct.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Synthesizes files to the project output directory.

envForBranch ​
public envForBranch(branchOptions: VersionBranchOptions): {[ key: string ]: string}

Return the environment variables to modify the bump command for release branches.

These options are used to modify the behavior of the version bumping script for additional branches, by setting environment variables.

No settings are inherited from the base Version object (but any parameters that control versions do conflict with the use of a nextVersionCommand).

branchOptionsRequired ​

Static Functions ​

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

isConstruct ​
import { Version } from 'projen'

Version.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 { Version } from 'projen'

Version.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.
bumpPackage
stringThe package used to bump package versions, as a dependency string.
bumpTask
Task
No description.
changelogFileName
stringThe name of the changelog file (under artifactsDirectory).
releasableCommitsTask
Task
The task that prints the releasable commits since the latest tag.
releaseTagFileName
stringThe name of the file that contains the release tag (under artifactsDirectory).
unbumpTask
Task
No description.
versionFileName
stringThe name of the file that contains the version (under artifactsDirectory).
nextVersionTask
Task
The task that runs the user's nextVersionCommand, if configured.

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

The tree node.


projectRequired ​
public readonly project: Project;

bumpPackageRequired ​
public readonly bumpPackage: string;
  • Type: string

The package used to bump package versions, as a dependency string.

This is a commit-and-tag-version compatible package.


bumpTaskRequired ​
public readonly bumpTask: Task;

changelogFileNameRequired ​
public readonly changelogFileName: string;
  • Type: string

The name of the changelog file (under artifactsDirectory).


releasableCommitsTaskRequired ​
public readonly releasableCommitsTask: Task;

The task that prints the releasable commits since the latest tag.

Spawned by bump; its shell can be overridden via task.shell.


releaseTagFileNameRequired ​
public readonly releaseTagFileName: string;
  • Type: string

The name of the file that contains the release tag (under artifactsDirectory).


unbumpTaskRequired ​
public readonly unbumpTask: Task;

versionFileNameRequired ​
public readonly versionFileName: string;
  • Type: string

The name of the file that contains the version (under artifactsDirectory).


nextVersionTaskOptional ​
public readonly nextVersionTask: Task;

The task that runs the user's nextVersionCommand, if configured.

Spawned by bump; its shell can be overridden via task.shell.


XmlFile ​

Represents an XML file.

Objects passed in will be synthesized using the npm "xml" library.

https://www.npmjs.com/package/xml

Initializers ​

import { XmlFile } from 'projen'

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

projectRequired ​

filePathRequired ​
  • Type: string

optionsOptional ​

Methods ​

NameDescription
toString
Returns a string representation of this construct.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Writes the file to the project's output directory.
diff
Returns a unified diff of the old and new file contents with context lines and hunk headers.
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.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Writes the file to the project's output directory.

diff ​
public diff(colorize?: boolean, contextLines?: number): string[]

Returns a unified diff of the old and new file contents with context lines and hunk headers.

Only available after synthesis.

This is an expensive operation and should only be used on non time-critical code paths, like debug output.

colorizeOptional ​
  • Type: boolean

Whether to colorize the diff output.


contextLinesOptional ​
  • Type: number

Number of context lines around changes.


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": ["es2020"]
...
}
...
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": ["es2020", "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": ["es2020"]
...
}
...
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 { XmlFile } from 'projen'

XmlFile.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 { XmlFile } from 'projen'

XmlFile.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.
committed
booleanIndicates if the file will be committed.
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.


committedRequired ​
public readonly committed: boolean;
  • Type: boolean

Indicates if the file will be committed.


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.


YamlFile ​

Represents a YAML file.

Initializers ​

import { YamlFile } from 'projen'

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

scopeRequired ​
  • Type: constructs.IConstruct

filePathRequired ​
  • Type: string

optionsRequired ​

Methods ​

NameDescription
toString
Returns a string representation of this construct.
with
Applies one or more mixins to this construct.
postProjectCreation
Called once, right after postSynthesize(), only when the project is created for the first time.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
projectCreation
Called once, right after synthesize(), only when the project is created for the first time.
synthesize
Writes the file to the project's output directory.
diff
Returns a unified diff of the old and new file contents with context lines and hunk headers.
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.

with ​
public with(mixins: ...IMixin[]): IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

mixinsRequired ​
  • Type: ...constructs.IMixin[]

The mixins to apply.


postProjectCreation ​
public postProjectCreation(initProject: InitProject): void

Called once, right after postSynthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST. Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate feedback on their new project. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


postSynthesize ​
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize ​
public preSynthesize(): void

Called before synthesis.

projectCreation ​
public projectCreation(initProject: InitProject): void

Called once, right after synthesize(), only when the project is created for the first time.

It does not run on later projen invocations. It only fires for projen new (or Projects.createProject). Use it for deterministic, one-off file generation. Order across components is not guaranteed.

initProjectRequired ​

Details about how the project was created, e.g. its type and the original CLI args.


synthesize ​
public synthesize(): void

Writes the file to the project's output directory.

diff ​
public diff(colorize?: boolean, contextLines?: number): string[]

Returns a unified diff of the old and new file contents with context lines and hunk headers.

Only available after synthesis.

This is an expensive operation and should only be used on non time-critical code paths, like debug output.

colorizeOptional ​
  • Type: boolean

Whether to colorize the diff output.


contextLinesOptional ​
  • Type: number

Number of context lines around changes.


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": ["es2020"]
...
}
...
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": ["es2020", "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": ["es2020"]
...
}
...
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 { YamlFile } from 'projen'

YamlFile.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 { YamlFile } from 'projen'

YamlFile.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.
committed
booleanIndicates if the file will be committed.
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.
lineWidth
numberMaximum line width (set to 0 to disable folding).

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.


committedRequired ​
public readonly committed: boolean;
  • Type: boolean

Indicates if the file will be committed.


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.


lineWidthRequired ​
public readonly lineWidth: number;
  • Type: number

Maximum line width (set to 0 to disable folding).


Structs ​

AiInstructionsOptions ​

Options for configuring AI tool instruction files.

Initializer ​

import { AiInstructionsOptions } from 'projen'

const aiInstructionsOptions: AiInstructionsOptions = { ... }

Properties ​

NameTypeDescription
agents
AiAgent[]
Which AI agents to generate instruction files for.
agentSpecificInstructions
{[ key: string ]: string[]}Per-agent custom instructions.
includeDefaultInstructions
booleanInclude default instructions for projen and general best practices.
instructions
string[]General instructions applicable to all agents.

agentsOptional ​
public readonly agents: AiAgent[];
  • Type: AiAgent[]
  • Default: All agents: [AiAgent.GITHUB_COPILOT, AiAgent.CURSOR, AiAgent.CLAUDE, AiAgent.AMAZON_Q, AiAgent.KIRO, AiAgent.CODEX]

Which AI agents to generate instruction files for.


agentSpecificInstructionsOptional ​
public readonly agentSpecificInstructions: {[ key: string ]: string[]};
  • Type: {[ key: string ]: string[]}
  • Default: no agent specific instructions

Per-agent custom instructions.

Allows different instructions for different AI tools.


Example

{
[AiAgent.GITHUB_COPILOT]: {
instructions: ["Use descriptive commit messages."]
},
[AiAgent.CURSOR]: {
instructions: ["Prefer functional patterns.", "Always add tests."]
}
}
includeDefaultInstructionsOptional ​
public readonly includeDefaultInstructions: boolean;
  • Type: boolean
  • Default: true

Include default instructions for projen and general best practices.

Default instructions will only be included for agents provided in the agents option. If agents is not provided, default instructions will be included for all agents.


instructionsOptional ​
public readonly instructions: string[];
  • Type: string[]
  • Default: no agent specific instructions

General instructions applicable to all agents.


CreateProjectOptions ​

Initializer ​

import { CreateProjectOptions } from 'projen'

const createProjectOptions: CreateProjectOptions = { ... }

Properties ​

NameTypeDescription
dir
stringDirectory that the project will be generated in.
projectFqn
stringFully-qualified name of the project type (usually formatted as projen.module.ProjectType).
projectOptions
{[ key: string ]: any}Project options.
optionHints
InitProjectOptionHints
Should we render commented-out default options in the projenrc file?
post
booleanShould we execute post synthesis hooks?
synth
booleanShould we call project.synth() or instantiate the project (could still have side-effects) and render the .projenrc file.

dirRequired ​
public readonly dir: string;
  • Type: string

Directory that the project will be generated in.


projectFqnRequired ​
public readonly projectFqn: string;
  • Type: string

Fully-qualified name of the project type (usually formatted as projen.module.ProjectType).


Example

`projen.typescript.TypescriptProject`
projectOptionsRequired ​
public readonly projectOptions: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

Project options.

Only JSON-like values can be passed in (strings, booleans, numbers, enums, arrays, and objects that are not derived from classes).

Consult the API reference of the project type you are generating for information about what fields and types are available.


optionHintsOptional ​
public readonly optionHints: InitProjectOptionHints;

Should we render commented-out default options in the projenrc file?

Does not apply to projenrc.json files.


postOptional ​
public readonly post: boolean;
  • Type: boolean
  • Default: true

Should we execute post synthesis hooks?

(usually package manager install).


synthOptional ​
public readonly synth: boolean;
  • Type: boolean
  • Default: true

Should we call project.synth() or instantiate the project (could still have side-effects) and render the .projenrc file.


Dependency ​

Represents a project dependency.

Initializer ​

import { Dependency } from 'projen'

const dependency: Dependency = { ... }

Properties ​

NameTypeDescription
name
stringThe package manager name of the dependency (e.g. leftpad for npm).
version
stringSemantic version version requirement.
type
DependencyType
Which type of dependency this is (runtime, build-time, etc).
metadata
{[ key: string ]: any}Additional JSON metadata associated with the dependency (package manager specific).

nameRequired ​
public readonly name: string;
  • Type: string

The package manager name of the dependency (e.g. leftpad for npm).

NOTE: For package managers that use complex coordinates (like Maven), we will codify it into a string somehow.


versionOptional ​
public readonly version: string;
  • Type: string
  • Default: requirement is managed by the package manager (e.g. npm/yarn).

Semantic version version requirement.


typeRequired ​
public readonly type: DependencyType;

Which type of dependency this is (runtime, build-time, etc).


metadataOptional ​
public readonly metadata: {[ key: string ]: any};
  • Type: {[ key: string ]: any}
  • Default: {}

Additional JSON metadata associated with the dependency (package manager specific).


DependencyCoordinates ​

Coordinates of the dependency (name and version).

Initializer ​

import { DependencyCoordinates } from 'projen'

const dependencyCoordinates: DependencyCoordinates = { ... }

Properties ​

NameTypeDescription
name
stringThe package manager name of the dependency (e.g. leftpad for npm).
version
stringSemantic version version requirement.

nameRequired ​
public readonly name: string;
  • Type: string

The package manager name of the dependency (e.g. leftpad for npm).

NOTE: For package managers that use complex coordinates (like Maven), we will codify it into a string somehow.


versionOptional ​
public readonly version: string;
  • Type: string
  • Default: requirement is managed by the package manager (e.g. npm/yarn).

Semantic version version requirement.


DependencyRequest ​

A request for a dependency.

Unlike adding a dependency directly, requesting a dependency will intelligently merge with existing dependencies of the same name and type.

Initializer ​

import { DependencyRequest } from 'projen'

const dependencyRequest: DependencyRequest = { ... }

Properties ​

NameTypeDescription
name
stringThe package name.
metadata
{[ key: string ]: any}Additional metadata.
type
DependencyType
Dependency type.
version
stringSemantic version constraint.

nameRequired ​
public readonly name: string;
  • Type: string

The package name.


metadataOptional ​
public readonly metadata: {[ key: string ]: any};
  • Type: {[ key: string ]: any}
  • Default: none

Additional metadata.


typeOptional ​
public readonly type: DependencyType;
  • Type: DependencyType
  • Default: any existing type, or DependencyType.BUILD

Dependency type.

If not provided, an existing dependency of any type will satisfy the request. If none exists, it is added as BUILD.


versionOptional ​
public readonly version: string;
  • Type: string
  • Default: any version

Semantic version constraint.


DepsManifest ​

Initializer ​

import { DepsManifest } from 'projen'

const depsManifest: DepsManifest = { ... }

Properties ​

NameTypeDescription
dependencies
Dependency[]
All dependencies of this module.

dependenciesRequired ​
public readonly dependencies: Dependency[];

All dependencies of this module.


DevEnvironmentOptions ​

Base options for configuring a container-based development environment.

Initializer ​

import { DevEnvironmentOptions } from 'projen'

const devEnvironmentOptions: DevEnvironmentOptions = { ... }

Properties ​

NameTypeDescription
dockerImage
DevEnvironmentDockerImage
A Docker image or Dockerfile for the container.
ports
string[]An array of ports that should be exposed from the container.
tasks
Task[]
An array of tasks that should be run when the container starts.
vscodeExtensions
string[]An array of extension IDs that specify the extensions that should be installed inside the container when it is created.

dockerImageOptional ​
public readonly dockerImage: DevEnvironmentDockerImage;

A Docker image or Dockerfile for the container.


portsOptional ​
public readonly ports: string[];
  • Type: string[]

An array of ports that should be exposed from the container.


tasksOptional ​
public readonly tasks: Task[];

An array of tasks that should be run when the container starts.


vscodeExtensionsOptional ​
public readonly vscodeExtensions: string[];
  • Type: string[]

An array of extension IDs that specify the extensions that should be installed inside the container when it is created.


DockerComposeBuild ​

Build arguments for creating a docker image.

Initializer ​

import { DockerComposeBuild } from 'projen'

const dockerComposeBuild: DockerComposeBuild = { ... }

Properties ​

NameTypeDescription
context
stringDocker build context directory.
args
{[ key: string ]: string}Build args.
dockerfile
stringA dockerfile to build from.

contextRequired ​
public readonly context: string;
  • Type: string

Docker build context directory.


argsOptional ​
public readonly args: {[ key: string ]: string};
  • Type: {[ key: string ]: string}
  • Default: none are provided

Build args.


dockerfileOptional ​
public readonly dockerfile: string;
  • Type: string
  • Default: "Dockerfile"

A dockerfile to build from.


DockerComposeNetworkConfig ​

Network configuration.

Initializer ​

import { DockerComposeNetworkConfig } from 'projen'

const dockerComposeNetworkConfig: DockerComposeNetworkConfig = { ... }

Properties ​

NameTypeDescription
attachable
booleanSet to true to indicate that standalone containers can attach to this network, in addition to services.
bridge
booleanSet to true to indicate that the network is a bridge network.
driver
stringDriver to use for the network.
driverOpts
objectOptions for the configured driver.
external
booleanSet to true to indicate that the network is externally created.
internal
booleanSet to true to indicate that you want to create an externally isolated overlay network.
ipam
DockerComposeNetworkIpamConfig
Specify custom IPAM config.
labels
string[]Attach labels to the network.
name
stringName of the network for when the network name isn't going to work in YAML.
overlay
booleanSet to true to indicate that the network is an overlay network.

attachableOptional ​
public readonly attachable: boolean;
  • Type: boolean
  • Default: unset

Set to true to indicate that standalone containers can attach to this network, in addition to services.


bridgeOptional ​
public readonly bridge: boolean;
  • Type: boolean
  • Default: unset

Set to true to indicate that the network is a bridge network.


driverOptional ​
public readonly driver: string;
  • Type: string
  • Default: value is not provided

Driver to use for the network.


driverOptsOptional ​
public readonly driverOpts: object;
  • Type: object
  • Default: value is not provided

Options for the configured driver.

Those options are driver-dependent - consult the driver’s documentation for more information


externalOptional ​
public readonly external: boolean;
  • Type: boolean
  • Default: unset, indicating that docker-compose creates the network

Set to true to indicate that the network is externally created.


internalOptional ​
public readonly internal: boolean;
  • Type: boolean
  • Default: unset

Set to true to indicate that you want to create an externally isolated overlay network.


ipamOptional ​
public readonly ipam: DockerComposeNetworkIpamConfig;

Specify custom IPAM config.


labelsOptional ​
public readonly labels: string[];
  • Type: string[]
  • Default: unset

Attach labels to the network.


nameOptional ​
public readonly name: string;
  • Type: string
  • Default: unset, indicating that docker-compose creates networks as usual

Name of the network for when the network name isn't going to work in YAML.


overlayOptional ​
public readonly overlay: boolean;
  • Type: boolean
  • Default: unset

Set to true to indicate that the network is an overlay network.


DockerComposeNetworkIpamConfig ​

IPAM configuration.

Initializer ​

import { DockerComposeNetworkIpamConfig } from 'projen'

const dockerComposeNetworkIpamConfig: DockerComposeNetworkIpamConfig = { ... }

Properties ​

NameTypeDescription
config
DockerComposeNetworkIpamSubnetConfig[]
A list with zero or more config blocks specifying custom IPAM configuration.
driver
stringDriver to use for custom IPAM config.

configOptional ​
public readonly config: DockerComposeNetworkIpamSubnetConfig[];

A list with zero or more config blocks specifying custom IPAM configuration.


driverOptional ​
public readonly driver: string;
  • Type: string
  • Default: value is not provided

Driver to use for custom IPAM config.


DockerComposeNetworkIpamSubnetConfig ​

IPAM subnet configuration.

Initializer ​

import { DockerComposeNetworkIpamSubnetConfig } from 'projen'

const dockerComposeNetworkIpamSubnetConfig: DockerComposeNetworkIpamSubnetConfig = { ... }

Properties ​

NameTypeDescription
subnet
stringSubnet in CIDR format that represents a network segment.

subnetOptional ​
public readonly subnet: string;
  • Type: string
  • Default: value is not provided

Subnet in CIDR format that represents a network segment.


DockerComposePortMappingOptions ​

Options for port mappings.

Initializer ​

import { DockerComposePortMappingOptions } from 'projen'

const dockerComposePortMappingOptions: DockerComposePortMappingOptions = { ... }

Properties ​

NameTypeDescription
protocol
DockerComposeProtocol
Port mapping protocol.

protocolOptional ​
public readonly protocol: DockerComposeProtocol;

Port mapping protocol.


DockerComposeProps ​

Props for DockerCompose.

Initializer ​

import { DockerComposeProps } from 'projen'

const dockerComposeProps: DockerComposeProps = { ... }

Properties ​

NameTypeDescription
nameSuffix
stringA name to add to the docker-compose.yml filename.
schemaVersion
stringDocker Compose schema version do be used.
services
{[ key: string ]: DockerComposeServiceDescription}
Service descriptions.

nameSuffixOptional ​
public readonly nameSuffix: string;
  • Type: string
  • Default: no name is added

A name to add to the docker-compose.yml filename.


Example

'myname' yields 'docker-compose.myname.yml'
schemaVersionOptional ​
public readonly schemaVersion: string;
  • Type: string
  • Default: no version is provided

Docker Compose schema version do be used.


servicesOptional ​
public readonly services: {[ key: string ]: DockerComposeServiceDescription};

Service descriptions.


DockerComposeServiceDescription ​

Description of a docker-compose.yml service.

Initializer ​

import { DockerComposeServiceDescription } from 'projen'

const dockerComposeServiceDescription: DockerComposeServiceDescription = { ... }

Properties ​

NameTypeDescription
command
string[]Provide a command to the docker container.
dependsOn
IDockerComposeServiceName[]
Names of other services this service depends on.
entrypoint
string[]Entrypoint to run in the container.
environment
{[ key: string ]: string}Add environment variables.
image
stringUse a docker image.
imageBuild
DockerComposeBuild
Build a docker image.
labels
{[ key: string ]: string}Add labels.
networks
IDockerComposeNetworkBinding[]
Add some networks to the service.
platform
stringAdd platform.
ports
DockerComposeServicePort[]
Map some ports.
privileged
booleanRun in privileged mode.
volumes
IDockerComposeVolumeBinding[]
Mount some volumes into the service.

commandOptional ​
public readonly command: string[];
  • Type: string[]
  • Default: use the container's default command

Provide a command to the docker container.


dependsOnOptional ​
public readonly dependsOn: IDockerComposeServiceName[];

Names of other services this service depends on.


entrypointOptional ​
public readonly entrypoint: string[];
  • Type: string[]

Entrypoint to run in the container.


environmentOptional ​
public readonly environment: {[ key: string ]: string};
  • Type: {[ key: string ]: string}
  • Default: no environment variables are provided

Add environment variables.


imageOptional ​
public readonly image: string;
  • Type: string

Use a docker image.

Note: You must specify either build or image key.

imageBuild


imageBuildOptional ​
public readonly imageBuild: DockerComposeBuild;

Build a docker image.

Note: You must specify either imageBuild or image key.

image


labelsOptional ​
public readonly labels: {[ key: string ]: string};
  • Type: {[ key: string ]: string}
  • Default: no labels are provided

Add labels.


networksOptional ​
public readonly networks: IDockerComposeNetworkBinding[];

Add some networks to the service.

[DockerCompose.network () to create & mount a named network](DockerCompose.network () to create & mount a named network)


platformOptional ​
public readonly platform: string;
  • Type: string
  • Default: no platform is provided

Add platform.


portsOptional ​
public readonly ports: DockerComposeServicePort[];

Map some ports.


privilegedOptional ​
public readonly privileged: boolean;
  • Type: boolean
  • Default: no privileged mode flag is provided

Run in privileged mode.


volumesOptional ​
public readonly volumes: IDockerComposeVolumeBinding[];

Mount some volumes into the service.

Use one of the following to create volumes:

[DockerCompose.namedVolume () to create & mount a named volume](DockerCompose.namedVolume () to create & mount a named volume)


DockerComposeServicePort ​

A service port mapping.

Initializer ​

import { DockerComposeServicePort } from 'projen'

const dockerComposeServicePort: DockerComposeServicePort = { ... }

Properties ​

NameTypeDescription
mode
stringPort mapping mode.
protocol
DockerComposeProtocol
Network protocol.
published
numberPublished port number.
target
numberTarget port number.

modeRequired ​
public readonly mode: string;
  • Type: string

Port mapping mode.


protocolRequired ​
public readonly protocol: DockerComposeProtocol;

Network protocol.


publishedRequired ​
public readonly published: number;
  • Type: number

Published port number.


targetRequired ​
public readonly target: number;
  • Type: number

Target port number.


DockerComposeVolumeConfig ​

Volume configuration.

Initializer ​

import { DockerComposeVolumeConfig } from 'projen'

const dockerComposeVolumeConfig: DockerComposeVolumeConfig = { ... }

Properties ​

NameTypeDescription
driver
stringDriver to use for the volume.
driverOpts
{[ key: string ]: string}Options to provide to the driver.
external
booleanSet to true to indicate that the volume is externally created.
name
stringName of the volume for when the volume name isn't going to work in YAML.

driverOptional ​
public readonly driver: string;
  • Type: string
  • Default: value is not provided

Driver to use for the volume.


driverOptsOptional ​
public readonly driverOpts: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Options to provide to the driver.


externalOptional ​
public readonly external: boolean;
  • Type: boolean
  • Default: unset, indicating that docker-compose creates the volume

Set to true to indicate that the volume is externally created.


nameOptional ​
public readonly name: string;
  • Type: string
  • Default: unset, indicating that docker-compose creates volumes as usual

Name of the volume for when the volume name isn't going to work in YAML.


DockerComposeVolumeMount ​

Service volume mounting information.

Initializer ​

import { DockerComposeVolumeMount } from 'projen'

const dockerComposeVolumeMount: DockerComposeVolumeMount = { ... }

Properties ​

NameTypeDescription
source
stringVolume source.
target
stringVolume target.
type
stringType of volume.

sourceRequired ​
public readonly source: string;
  • Type: string

Volume source.


targetRequired ​
public readonly target: string;
  • Type: string

Volume target.


typeRequired ​
public readonly type: string;
  • Type: string

Type of volume.


FileBaseOptions ​

Initializer ​

import { FileBaseOptions } from 'projen'

const fileBaseOptions: FileBaseOptions = { ... }

Properties ​

NameTypeDescription
committed
booleanIndicates whether this file should be committed to git or ignored.
editGitignore
booleanUpdate the project's .gitignore file.
executable
booleanWhether the generated file should be marked as executable.
marker
booleanAdds the projen marker to the file.
readonly
booleanWhether the generated file should be readonly.

committedOptional ​
public readonly committed: boolean;
  • Type: boolean
  • Default: true

Indicates whether this file should be committed to git or ignored.

By default, all generated files are committed and anti-tamper is used to protect against manual modifications.


editGitignoreOptional ​
public readonly editGitignore: boolean;
  • Type: boolean
  • Default: true

Update the project's .gitignore file.


executableOptional ​
public readonly executable: boolean;
  • Type: boolean
  • Default: false

Whether the generated file should be marked as executable.


markerOptional ​
public readonly marker: boolean;
  • Type: boolean
  • Default: marker will be included as long as the project is not ejected

Adds the projen marker to the file.


readonlyOptional ​
public readonly readonly: boolean;
  • Type: boolean
  • Default: true

Whether the generated file should be readonly.


GitAttributesFileOptions ​

Options for GitAttributesFile.

Initializer ​

import { GitAttributesFileOptions } from 'projen'

const gitAttributesFileOptions: GitAttributesFileOptions = { ... }

Properties ​

NameTypeDescription
endOfLine
EndOfLine
The default end of line character for text files.

endOfLineOptional ​
public readonly endOfLine: EndOfLine;

The default end of line character for text files.

endOfLine it's useful to keep the same end of line between Windows and Unix operative systems for git checking/checkout operations. Hence, it can avoid simple repository mutations consisting only of changes in the end of line characters. It will be set in the first line of the .gitattributes file to make it the first match with high priority but it can be overriden in a later line. Can be disabled by setting explicitly: { endOfLine: EndOfLine.NONE }.


GitOptions ​

Git configuration options.

Initializer ​

import { GitOptions } from 'projen'

const gitOptions: GitOptions = { ... }

Properties ​

NameTypeDescription
endOfLine
EndOfLine
The default end of line character for text files.
lfsPatterns
string[]File patterns to mark as stored in Git LFS.

endOfLineOptional ​
public readonly endOfLine: EndOfLine;

The default end of line character for text files.

endOfLine it's useful to keep the same end of line between Windows and Unix operative systems for git checking/checkout operations. Hence, it can avoid simple repository mutations consisting only of changes in the end of line characters. It will be set in the first line of the .gitattributes file to make it the first match with high priority but it can be overriden in a later line. Can be disabled by setting: endOfLine: EndOfLine.NONE.


lfsPatternsOptional ​
public readonly lfsPatterns: string[];
  • Type: string[]
  • Default: No files stored in LFS

File patterns to mark as stored in Git LFS.


GitpodOptions ​

Constructor options for the Gitpod component.

By default, Gitpod uses the 'gitpod/workspace-full' docker image.

[https://github.com/gitpod-io/workspace-images/blob/master/full/Dockerfile

By default, all tasks will be run in parallel. To run the tasks in sequence, create a new task and specify the other tasks as subtasks.](https://github.com/gitpod-io/workspace-images/blob/master/full/Dockerfile

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

Initializer ​

import { GitpodOptions } from 'projen'

const gitpodOptions: GitpodOptions = { ... }

Properties ​

NameTypeDescription
dockerImage
DevEnvironmentDockerImage
A Docker image or Dockerfile for the container.
ports
string[]An array of ports that should be exposed from the container.
tasks
Task[]
An array of tasks that should be run when the container starts.
vscodeExtensions
string[]An array of extension IDs that specify the extensions that should be installed inside the container when it is created.
prebuilds
GitpodPrebuilds
Optional Gitpod's Github App integration for prebuilds If this is not set and Gitpod's Github App is installed, then Gitpod will apply these defaults: https://www.gitpod.io/docs/prebuilds/#configure-the-github-app.

dockerImageOptional ​
public readonly dockerImage: DevEnvironmentDockerImage;

A Docker image or Dockerfile for the container.


portsOptional ​
public readonly ports: string[];
  • Type: string[]

An array of ports that should be exposed from the container.


tasksOptional ​
public readonly tasks: Task[];

An array of tasks that should be run when the container starts.


vscodeExtensionsOptional ​
public readonly vscodeExtensions: string[];
  • Type: string[]

An array of extension IDs that specify the extensions that should be installed inside the container when it is created.


prebuildsOptional ​
public readonly prebuilds: GitpodPrebuilds;

Optional Gitpod's Github App integration for prebuilds If this is not set and Gitpod's Github App is installed, then Gitpod will apply these defaults: https://www.gitpod.io/docs/prebuilds/#configure-the-github-app.


GitpodPort ​

Options for an exposed port on Gitpod.

Initializer ​

import { GitpodPort } from 'projen'

const gitpodPort: GitpodPort = { ... }

Properties ​

NameTypeDescription
onOpen
GitpodOnOpen
What to do when a service on a port is detected.
port
stringA port that should be exposed (forwarded) from the container.
visibility
GitpodPortVisibility
Whether the port visibility should be private or public.

onOpenOptional ​
public readonly onOpen: GitpodOnOpen;

What to do when a service on a port is detected.


portOptional ​
public readonly port: string;
  • Type: string

A port that should be exposed (forwarded) from the container.


Example

"8080"
visibilityOptional ​
public readonly visibility: GitpodPortVisibility;

Whether the port visibility should be private or public.


GitpodPrebuilds ​

Configure the Gitpod App for prebuilds.

Currently only GitHub is supported.

https://www.gitpod.io/docs/prebuilds/

Initializer ​

import { GitpodPrebuilds } from 'projen'

const gitpodPrebuilds: GitpodPrebuilds = { ... }

Properties ​

NameTypeDescription
addBadge
booleanAdd a "Review in Gitpod" button to the pull request's description.
addCheck
booleanAdd a check to pull requests.
addComment
booleanAdd a "Review in Gitpod" button as a comment to pull requests.
addLabel
booleanAdd a label once the prebuild is ready to pull requests.
branches
booleanEnable for all branches in this repo.
master
booleanEnable for the master/default branch.
pullRequests
booleanEnable for pull requests coming from this repo.
pullRequestsFromForks
booleanEnable for pull requests coming from forks.

addBadgeOptional ​
public readonly addBadge: boolean;
  • Type: boolean
  • Default: false

Add a "Review in Gitpod" button to the pull request's description.


addCheckOptional ​
public readonly addCheck: boolean;
  • Type: boolean
  • Default: true

Add a check to pull requests.


addCommentOptional ​
public readonly addComment: boolean;
  • Type: boolean
  • Default: false

Add a "Review in Gitpod" button as a comment to pull requests.


addLabelOptional ​
public readonly addLabel: boolean;
  • Type: boolean
  • Default: false

Add a label once the prebuild is ready to pull requests.


branchesOptional ​
public readonly branches: boolean;
  • Type: boolean
  • Default: false

Enable for all branches in this repo.


masterOptional ​
public readonly master: boolean;
  • Type: boolean
  • Default: true

Enable for the master/default branch.


pullRequestsOptional ​
public readonly pullRequests: boolean;
  • Type: boolean
  • Default: true

Enable for pull requests coming from this repo.


pullRequestsFromForksOptional ​
public readonly pullRequestsFromForks: boolean;
  • Type: boolean
  • Default: false

Enable for pull requests coming from forks.


GitpodTask ​

Configure options for a task to be run when opening a Gitpod workspace (e.g. running tests, or starting a dev server).

Start Mode | Execution Fresh Workspace | before && init && command Restart Workspace | before && command Snapshot | before && command Prebuild | before && init && prebuild

Initializer ​

import { GitpodTask } from 'projen'

const gitpodTask: GitpodTask = { ... }

Properties ​

NameTypeDescription
command
stringRequired.
before
stringIn case you need to run something even before init, that is a requirement for both init and command, you can use the before property.
init
stringThe init property can be used to specify shell commands that should only be executed after a workspace was freshly cloned and needs to be initialized somehow.
name
stringA name for this task.
openIn
GitpodOpenIn
You can configure where in the IDE the terminal should be opened.
openMode
GitpodOpenMode
You can configure how the terminal should be opened relative to the previous task.
prebuild
stringThe optional prebuild command will be executed during prebuilds.

commandRequired ​
public readonly command: string;
  • Type: string

Required.

The shell command to run


beforeOptional ​
public readonly before: string;
  • Type: string

In case you need to run something even before init, that is a requirement for both init and command, you can use the before property.

A shell command, chained with the other task commands using &&.


initOptional ​
public readonly init: string;
  • Type: string

The init property can be used to specify shell commands that should only be executed after a workspace was freshly cloned and needs to be initialized somehow.

Such tasks are usually builds or downloading dependencies. Anything you only want to do once but not when you restart a workspace or start a snapshot.


nameOptional ​
public readonly name: string;
  • Type: string
  • Default: task names are omitted when blank

A name for this task.


openInOptional ​
public readonly openIn: GitpodOpenIn;

You can configure where in the IDE the terminal should be opened.


openModeOptional ​
public readonly openMode: GitpodOpenMode;

You can configure how the terminal should be opened relative to the previous task.


prebuildOptional ​
public readonly prebuild: string;
  • Type: string

The optional prebuild command will be executed during prebuilds.

It is meant to run additional long running processes that could be useful, e.g. running test suites.

A shell command, chained with the other task commands using &&.


GroupRunnerOptions ​

Initializer ​

import { GroupRunnerOptions } from 'projen'

const groupRunnerOptions: GroupRunnerOptions = { ... }

Properties ​

NameTypeDescription
group
stringNo description.
labels
string[]No description.

groupRequired ​
public readonly group: string;
  • Type: string

labelsOptional ​
public readonly labels: string[];
  • Type: string[]

IgnoreFileOptions ​

Initializer ​

import { IgnoreFileOptions } from 'projen'

const ignoreFileOptions: IgnoreFileOptions = { ... }

Properties ​

NameTypeDescription
filterCommentLines
booleanFilter out comment lines?
filterEmptyLines
booleanFilter out blank/empty lines?
ignorePatterns
string[]Patterns to add to the ignore file.

filterCommentLinesOptional ​
public readonly filterCommentLines: boolean;
  • Type: boolean
  • Default: true

Filter out comment lines?


filterEmptyLinesOptional ​
public readonly filterEmptyLines: boolean;
  • Type: boolean
  • Default: true

Filter out blank/empty lines?


ignorePatternsOptional ​
public readonly ignorePatterns: string[];
  • Type: string[]
  • Default: []

Patterns to add to the ignore file.


IniFileOptions ​

Options for IniFile.

Initializer ​

import { IniFileOptions } from 'projen'

const iniFileOptions: IniFileOptions = { ... }

Properties ​

NameTypeDescription
committed
booleanIndicates whether this file should be committed to git or ignored.
editGitignore
booleanUpdate the project's .gitignore file.
executable
booleanWhether the generated file should be marked as executable.
marker
booleanAdds the projen marker to the file.
readonly
booleanWhether the generated file should be readonly.
obj
anyThe object that will be serialized. You can modify the object's contents before synthesis.
omitEmpty
booleanOmits empty objects and arrays.

committedOptional ​
public readonly committed: boolean;
  • Type: boolean
  • Default: true

Indicates whether this file should be committed to git or ignored.

By default, all generated files are committed and anti-tamper is used to protect against manual modifications.


editGitignoreOptional ​
public readonly editGitignore: boolean;
  • Type: boolean
  • Default: true

Update the project's .gitignore file.


executableOptional ​
public readonly executable: boolean;
  • Type: boolean
  • Default: false

Whether the generated file should be marked as executable.


markerOptional ​
public readonly marker: boolean;
  • Type: boolean
  • Default: marker will be included as long as the project is not ejected

Adds the projen marker to the file.


readonlyOptional ​
public readonly readonly: boolean;
  • Type: boolean
  • Default: true

Whether the generated file should be readonly.


objOptional ​
public readonly obj: any;
  • Type: any
  • Default: {} an empty object (use file.obj to mutate).

The object that will be serialized. You can modify the object's contents before synthesis.

Serialization of the object is similar to JSON.stringify with few enhancements:

  • values that are functions will be called during synthesis and the result will be serialized - this allow to have lazy values.
  • Set will be converted to array
  • Map will be converted to a plain object ({ key: value, ... }})
  • RegExp without flags will be converted to string representation of the source

omitEmptyOptional ​
public readonly omitEmpty: boolean;
  • Type: boolean
  • Default: false

Omits empty objects and arrays.


InitProject ​

Information passed from projen new to the project object when the project is first created.

It is used to generate projenrc files in various languages.

Initializer ​

import { InitProject } from 'projen'

const initProject: InitProject = { ... }

Properties ​

NameTypeDescription
args
{[ key: string ]: any}Initial arguments passed to projen new.
comments
InitProjectOptionHints
Include commented out options.
fqn
stringThe JSII FQN of the project type.
post
booleanWhether projen new should run post-synthesis steps (e.g. package manager install).
synth
booleanWhether projen new should call project.synth() after construction.
type
ProjectType
Project metadata.

argsRequired ​
public readonly args: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

Initial arguments passed to projen new.


commentsRequired ​
public readonly comments: InitProjectOptionHints;

Include commented out options.

Does not apply to projenrc.json files.


fqnRequired ​
public readonly fqn: string;
  • Type: string

The JSII FQN of the project type.


postRequired ​
public readonly post: boolean;
  • Type: boolean
  • Default: true

Whether projen new should run post-synthesis steps (e.g. package manager install).


synthRequired ​
public readonly synth: boolean;
  • Type: boolean
  • Default: true

Whether projen new should call project.synth() after construction.


typeRequired ​
public readonly type: ProjectType;

Project metadata.


JsonFileOptions ​

Options for JsonFile.

Initializer ​

import { JsonFileOptions } from 'projen'

const jsonFileOptions: JsonFileOptions = { ... }

Properties ​

NameTypeDescription
committed
booleanIndicates whether this file should be committed to git or ignored.
editGitignore
booleanUpdate the project's .gitignore file.
executable
booleanWhether the generated file should be marked as executable.
marker
booleanAdds the projen marker to the file.
readonly
booleanWhether the generated file should be readonly.
obj
anyThe object that will be serialized. You can modify the object's contents before synthesis.
omitEmpty
booleanOmits empty objects and arrays.
allowComments
booleanAllow the use of comments in this file.
newline
booleanAdds a newline at the end of the file.

committedOptional ​
public readonly committed: boolean;
  • Type: boolean
  • Default: true

Indicates whether this file should be committed to git or ignored.

By default, all generated files are committed and anti-tamper is used to protect against manual modifications.


editGitignoreOptional ​
public readonly editGitignore: boolean;
  • Type: boolean
  • Default: true

Update the project's .gitignore file.


executableOptional ​
public readonly executable: boolean;
  • Type: boolean
  • Default: false

Whether the generated file should be marked as executable.


markerOptional ​
public readonly marker: boolean;
  • Type: boolean
  • Default: marker will be included as long as the project is not ejected

Adds the projen marker to the file.


readonlyOptional ​
public readonly readonly: boolean;
  • Type: boolean
  • Default: true

Whether the generated file should be readonly.


objOptional ​
public readonly obj: any;
  • Type: any
  • Default: {} an empty object (use file.obj to mutate).

The object that will be serialized. You can modify the object's contents before synthesis.

Serialization of the object is similar to JSON.stringify with few enhancements:

  • values that are functions will be called during synthesis and the result will be serialized - this allow to have lazy values.
  • Set will be converted to array
  • Map will be converted to a plain object ({ key: value, ... }})
  • RegExp without flags will be converted to string representation of the source

omitEmptyOptional ​
public readonly omitEmpty: boolean;
  • Type: boolean
  • Default: false

Omits empty objects and arrays.


allowCommentsOptional ​
public readonly allowComments: boolean;
  • Type: boolean
  • Default: false for .json files, true for .json5 and .jsonc files

Allow the use of comments in this file.


newlineOptional ​
public readonly newline: boolean;
  • Type: boolean
  • Default: true

Adds a newline at the end of the file.


LicenseOptions ​

Initializer ​

import { LicenseOptions } from 'projen'

const licenseOptions: LicenseOptions = { ... }

Properties ​

NameTypeDescription
spdx
stringLicense type (SPDX).
copyrightOwner
stringCopyright owner.
copyrightPeriod
stringPeriod of license (e.g. "1998-2023").

spdxRequired ​
public readonly spdx: string;
  • Type: string

License type (SPDX).

[https://github.com/projen/projen/tree/main/license-text for list of supported licenses](https://github.com/projen/projen/tree/main/license-text for list of supported licenses)


copyrightOwnerOptional ​
public readonly copyrightOwner: string;
  • Type: string
  • Default:

Copyright owner.

If the license text has $copyright_owner, this option must be specified.


copyrightPeriodOptional ​
public readonly copyrightPeriod: string;
  • Type: string
  • Default: current year (e.g. "2020")

Period of license (e.g. "1998-2023").

The string $copyright_period will be substituted with this string.


LoggerOptions ​

Options for logging utilities.

Initializer ​

import { LoggerOptions } from 'projen'

const loggerOptions: LoggerOptions = { ... }

Properties ​

NameTypeDescription
level
LogLevel
The logging verbosity.
usePrefix
booleanInclude a prefix for all logging messages with the project name.

levelOptional ​
public readonly level: LogLevel;

The logging verbosity.

The levels available (in increasing verbosity) are OFF, ERROR, WARN, INFO, DEBUG, and VERBOSE.


usePrefixOptional ​
public readonly usePrefix: boolean;
  • Type: boolean
  • Default: false

Include a prefix for all logging messages with the project name.


MakefileOptions ​

Options for Makefiles.

Initializer ​

import { MakefileOptions } from 'projen'

const makefileOptions: MakefileOptions = { ... }

Properties ​

NameTypeDescription
committed
booleanIndicates whether this file should be committed to git or ignored.
editGitignore
booleanUpdate the project's .gitignore file.
executable
booleanWhether the generated file should be marked as executable.
marker
booleanAdds the projen marker to the file.
readonly
booleanWhether the generated file should be readonly.
all
string[]List of targets to build when Make is invoked without specifying any targets.
rules
Rule[]
Rules to include in the Makefile.

committedOptional ​
public readonly committed: boolean;
  • Type: boolean
  • Default: true

Indicates whether this file should be committed to git or ignored.

By default, all generated files are committed and anti-tamper is used to protect against manual modifications.


editGitignoreOptional ​
public readonly editGitignore: boolean;
  • Type: boolean
  • Default: true

Update the project's .gitignore file.


executableOptional ​
public readonly executable: boolean;
  • Type: boolean
  • Default: false

Whether the generated file should be marked as executable.


markerOptional ​
public readonly marker: boolean;
  • Type: boolean
  • Default: marker will be included as long as the project is not ejected

Adds the projen marker to the file.


readonlyOptional ​
public readonly readonly: boolean;
  • Type: boolean
  • Default: true

Whether the generated file should be readonly.


allOptional ​
public readonly all: string[];
  • Type: string[]
  • Default: []

List of targets to build when Make is invoked without specifying any targets.


rulesOptional ​
public readonly rules: Rule[];
  • Type: Rule[]
  • Default: []

Rules to include in the Makefile.


ObjectFileOptions ​

Options for ObjectFile.

Initializer ​

import { ObjectFileOptions } from 'projen'

const objectFileOptions: ObjectFileOptions = { ... }

Properties ​

NameTypeDescription
committed
booleanIndicates whether this file should be committed to git or ignored.
editGitignore
booleanUpdate the project's .gitignore file.
executable
booleanWhether the generated file should be marked as executable.
marker
booleanAdds the projen marker to the file.
readonly
booleanWhether the generated file should be readonly.
obj
anyThe object that will be serialized. You can modify the object's contents before synthesis.
omitEmpty
booleanOmits empty objects and arrays.

committedOptional ​
public readonly committed: boolean;
  • Type: boolean
  • Default: true

Indicates whether this file should be committed to git or ignored.

By default, all generated files are committed and anti-tamper is used to protect against manual modifications.


editGitignoreOptional ​
public readonly editGitignore: boolean;
  • Type: boolean
  • Default: true

Update the project's .gitignore file.


executableOptional ​
public readonly executable: boolean;
  • Type: boolean
  • Default: false

Whether the generated file should be marked as executable.


markerOptional ​
public readonly marker: boolean;
  • Type: boolean
  • Default: marker will be included as long as the project is not ejected

Adds the projen marker to the file.


readonlyOptional ​
public readonly readonly: boolean;
  • Type: boolean
  • Default: true

Whether the generated file should be readonly.


objOptional ​
public readonly obj: any;
  • Type: any
  • Default: {} an empty object (use file.obj to mutate).

The object that will be serialized. You can modify the object's contents before synthesis.

Serialization of the object is similar to JSON.stringify with few enhancements:

  • values that are functions will be called during synthesis and the result will be serialized - this allow to have lazy values.
  • Set will be converted to array
  • Map will be converted to a plain object ({ key: value, ... }})
  • RegExp without flags will be converted to string representation of the source

omitEmptyOptional ​
public readonly omitEmpty: boolean;
  • Type: boolean
  • Default: false

Omits empty objects and arrays.


ProjectOption ​

Initializer ​

import { ProjectOption } from 'projen'

const projectOption: ProjectOption = { ... }

Properties ​

NameTypeDescription
name
stringNo description.
type
anyNo description.
default
stringNo description.
deprecated
booleanNo description.
docs
stringNo description.
featured
booleanNo description.
fqn
stringNo description.
initialValue
stringNo description.
optional
booleanNo description.

nameRequired ​
public readonly name: string;
  • Type: string

typeRequired ​
public readonly type: any;
  • Type: any

defaultOptional ​
public readonly default: string;
  • Type: string

deprecatedOptional ​
public readonly deprecated: boolean;
  • Type: boolean

docsOptional ​
public readonly docs: string;
  • Type: string

featuredOptional ​
public readonly featured: boolean;
  • Type: boolean

fqnOptional ​
public readonly fqn: string;
  • Type: string

initialValueOptional ​
public readonly initialValue: string;
  • Type: string

optionalOptional ​
public readonly optional: boolean;
  • Type: boolean

ProjectOptions ​

Options for Project.

Initializer ​

import { ProjectOptions } from 'projen'

const projectOptions: ProjectOptions = { ... }

Properties ​

NameTypeDescription
name
stringThis is the name of your project.
commitGenerated
booleanWhether to commit the managed files by default.
gitIgnoreOptions
IgnoreFileOptions
Configuration options for .gitignore file.
gitOptions
GitOptions
Configuration options for git.
logging
LoggerOptions
Configure logging options such as verbosity.
outdir
stringThe root directory of the project.
parent
Project
The parent project, if this project is part of a bigger project.
projectTree
booleanGenerate a project tree file (.projen/tree.json) that shows all components and their relationships. Useful for understanding your project structure and debugging.
projenCommand
stringThe shell command to use in order to run the projen CLI.
projenrcJson
booleanGenerate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.
projenrcJsonOptions
ProjenrcJsonOptions
Options for .projenrc.json.
renovatebot
booleanUse renovatebot to handle dependency upgrades.
renovatebotOptions
RenovatebotOptions
Options for renovatebot.

nameRequired ​
public readonly name: string;
  • Type: string
  • Default: $BASEDIR

This is the name of your project.


commitGeneratedOptional ​
public readonly commitGenerated: boolean;
  • Type: boolean
  • Default: true

Whether to commit the managed files by default.


gitIgnoreOptionsOptional ​
public readonly gitIgnoreOptions: IgnoreFileOptions;

Configuration options for .gitignore file.


gitOptionsOptional ​
public readonly gitOptions: GitOptions;

Configuration options for git.


loggingOptional ​
public readonly logging: LoggerOptions;

Configure logging options such as verbosity.


outdirOptional ​
public readonly outdir: string;
  • Type: string
  • Default: "."

The root directory of the project.

Relative to this directory, all files are synthesized.

If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.


parentOptional ​
public readonly parent: Project;

The parent project, if this project is part of a bigger project.


projectTreeOptional ​
public readonly projectTree: boolean;
  • Type: boolean
  • Default: false

Generate a project tree file (.projen/tree.json) that shows all components and their relationships. Useful for understanding your project structure and debugging.


projenCommandOptional ​
public readonly projenCommand: string;
  • Type: string
  • Default: "npx projen"

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

Inserted verbatim into task steps, workflows and IDE configuration, and run by each of their shells - locally, in CI and in dev containers. Keep it a plain unquoted command, since shell syntax in it executes in all of them.

Can be used to customize in special environments.


projenrcJsonOptional ​
public readonly projenrcJson: boolean;
  • Type: boolean
  • Default: false

Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.


projenrcJsonOptionsOptional ​
public readonly projenrcJsonOptions: ProjenrcJsonOptions;

Options for .projenrc.json.


renovatebotOptional ​
public readonly renovatebot: boolean;
  • Type: boolean
  • Default: false

Use renovatebot to handle dependency upgrades.


renovatebotOptionsOptional ​
public readonly renovatebotOptions: RenovatebotOptions;

Options for renovatebot.


ProjectType ​

Initializer ​

import { ProjectType } from 'projen'

const projectType: ProjectType = { ... }

Properties ​

NameTypeDescription
docsurl
stringNo description.
fqn
stringNo description.
moduleName
stringNo description.
options
ProjectOption[]
No description.
pjid
stringNo description.
typename
stringNo description.
docs
stringNo description.

docsurlRequired ​
public readonly docsurl: string;
  • Type: string

fqnRequired ​
public readonly fqn: string;
  • Type: string

moduleNameRequired ​
public readonly moduleName: string;
  • Type: string

optionsRequired ​
public readonly options: ProjectOption[];

pjidRequired ​
public readonly pjid: string;
  • Type: string

typenameRequired ​
public readonly typename: string;
  • Type: string

docsOptional ​
public readonly docs: string;
  • Type: string

ProjenrcJsonOptions ​

Initializer ​

import { ProjenrcJsonOptions } from 'projen'

const projenrcJsonOptions: ProjenrcJsonOptions = { ... }

Properties ​

NameTypeDescription
filename
stringThe name of the projenrc file.

filenameOptional ​
public readonly filename: string;
  • Type: string
  • Default: ".projenrc.json"

The name of the projenrc file.


PropertiesFileOptions ​

Options for PropertiesFile.

Initializer ​

import { PropertiesFileOptions } from 'projen'

const propertiesFileOptions: PropertiesFileOptions = { ... }

Properties ​

NameTypeDescription
committed
booleanIndicates whether this file should be committed to git or ignored.
editGitignore
booleanUpdate the project's .gitignore file.
executable
booleanWhether the generated file should be marked as executable.
marker
booleanAdds the projen marker to the file.
readonly
booleanWhether the generated file should be readonly.
obj
anyThe object that will be serialized. You can modify the object's contents before synthesis.
omitEmpty
booleanOmits empty objects and arrays.
comment
string[]A comment to include at the top of the file (after the projen marker, if enabled).

committedOptional ​
public readonly committed: boolean;
  • Type: boolean
  • Default: true

Indicates whether this file should be committed to git or ignored.

By default, all generated files are committed and anti-tamper is used to protect against manual modifications.


editGitignoreOptional ​
public readonly editGitignore: boolean;
  • Type: boolean
  • Default: true

Update the project's .gitignore file.


executableOptional ​
public readonly executable: boolean;
  • Type: boolean
  • Default: false

Whether the generated file should be marked as executable.


markerOptional ​
public readonly marker: boolean;
  • Type: boolean
  • Default: marker will be included as long as the project is not ejected

Adds the projen marker to the file.


readonlyOptional ​
public readonly readonly: boolean;
  • Type: boolean
  • Default: true

Whether the generated file should be readonly.


objOptional ​
public readonly obj: any;
  • Type: any
  • Default: {} an empty object (use file.obj to mutate).

The object that will be serialized. You can modify the object's contents before synthesis.

Serialization of the object is similar to JSON.stringify with few enhancements:

  • values that are functions will be called during synthesis and the result will be serialized - this allow to have lazy values.
  • Set will be converted to array
  • Map will be converted to a plain object ({ key: value, ... }})
  • RegExp without flags will be converted to string representation of the source

omitEmptyOptional ​
public readonly omitEmpty: boolean;
  • Type: boolean
  • Default: false

Omits empty objects and arrays.


commentOptional ​
public readonly comment: string[];
  • Type: string[]
  • Default: no additional comment

A comment to include at the top of the file (after the projen marker, if enabled).

Each string in the array becomes a separate comment line.


RenovatebotOptions ​

Options for Renovatebot.

Initializer ​

import { RenovatebotOptions } from 'projen'

const renovatebotOptions: RenovatebotOptions = { ... }

Properties ​

NameTypeDescription
ignore
string[]You can use the ignore option to customize which dependencies are updated.
ignoreProjen
booleanIgnores updates to projen.
labels
string[]List of labels to apply to the created PR's.
marker
booleanNo description.
minimumReleaseAge
stringMinimum release age for packages before Renovate will propose an update.
minimumReleaseAgeBehaviour
RenovatebotMinimumReleaseAgeBehaviour
Controls whether a release timestamp is required when using minimumReleaseAge.
overrideConfig
anyNo description.
scheduleInterval
string[]How often to check for new versions and raise pull requests.

ignoreOptional ​
public readonly ignore: string[];
  • Type: string[]
  • Default: []

You can use the ignore option to customize which dependencies are updated.

The ignore option supports just package name.


ignoreProjenOptional ​
public readonly ignoreProjen: boolean;
  • Type: boolean
  • Default: true

Ignores updates to projen.

This is required since projen updates may cause changes in committed files and anti-tamper checks will fail.

Projen upgrades are covered through the ProjenUpgrade class.


labelsOptional ​
public readonly labels: string[];
  • Type: string[]

List of labels to apply to the created PR's.


markerOptional ​
public readonly marker: boolean;
  • Type: boolean

minimumReleaseAgeOptional ​
public readonly minimumReleaseAge: string;
  • Type: string
  • Default: no minimum release age

Minimum release age for packages before Renovate will propose an update.

This is a supply chain security feature to avoid updating to newly published, potentially malicious versions.

https://docs.renovatebot.com/configuration-options/#minimumreleaseage


minimumReleaseAgeBehaviourOptional ​
public readonly minimumReleaseAgeBehaviour: RenovatebotMinimumReleaseAgeBehaviour;

Controls whether a release timestamp is required when using minimumReleaseAge.

https://docs.renovatebot.com/configuration-options/#minimumreleaseagebehaviour


overrideConfigOptional ​
public readonly overrideConfig: any;
  • Type: any

scheduleIntervalOptional ​
public readonly scheduleInterval: string[];
  • Type: string[]
  • Default: ["at any time"]

How often to check for new versions and raise pull requests.

Can be given in CRON or LATER format, and use multiple schedules (e.g. different for weekdays and weekends). Multiple rules are handles as OR.

Some normal scheduling values defined in enum RenovatebotScheduleInterval.

https://docs.renovatebot.com/configuration-options/#schedule


ResolveOptions ​

Resolve options.

Initializer ​

import { ResolveOptions } from 'projen'

const resolveOptions: ResolveOptions = { ... }

Properties ​

NameTypeDescription
args
any[]Context arguments.
omitEmpty
booleanOmits empty arrays and objects.

argsOptional ​
public readonly args: any[];
  • Type: any[]
  • Default: []

Context arguments.


omitEmptyOptional ​
public readonly omitEmpty: boolean;
  • Type: boolean
  • Default: false

Omits empty arrays and objects.


Rule ​

A Make rule.

Initializer ​

import { Rule } from 'projen'

const rule: Rule = { ... }

Properties ​

NameTypeDescription
targets
string[]Files to be created or updated by this rule.
phony
booleanMarks whether the target is phony.
prerequisites
string[]Files that are used as inputs to create a target.
recipe
string[]Commands that are run (using prerequisites as inputs) to create a target.

targetsRequired ​
public readonly targets: string[];
  • Type: string[]

Files to be created or updated by this rule.

If the rule is phony then instead this represents the command's name(s).


phonyOptional ​
public readonly phony: boolean;
  • Type: boolean
  • Default: false

Marks whether the target is phony.


prerequisitesOptional ​
public readonly prerequisites: string[];
  • Type: string[]
  • Default: []

Files that are used as inputs to create a target.


recipeOptional ​
public readonly recipe: string[];
  • Type: string[]
  • Default: []

Commands that are run (using prerequisites as inputs) to create a target.

Each entry is a shell command, run by make in its own shell.


RunScriptConfig ​

The resolved configuration for running a script.

Initializer ​

import { RunScriptConfig } from 'projen'

const runScriptConfig: RunScriptConfig = { ... }

Properties ​

NameTypeDescription
dependencies
DependencyRequest[]
Dependencies required to run the script.
steps
TaskStep[]
The task steps to execute the script.

dependenciesRequired ​
public readonly dependencies: DependencyRequest[];

Dependencies required to run the script.


stepsRequired ​
public readonly steps: TaskStep[];

The task steps to execute the script.


RunsOnConfig ​

Resolved runsOn/runsOnGroup config for a job.

Exactly one of the two fields is set.

Initializer ​

import { RunsOnConfig } from 'projen'

const runsOnConfig: RunsOnConfig = { ... }

Properties ​

NameTypeDescription
runsOn
string[]Github Runner selection labels.
runsOnGroup
GroupRunnerOptions
Github Runner Group selection options.

runsOnOptional ​
public readonly runsOn: string[];
  • Type: string[]
  • Default: not set if runsOnGroup is used

Github Runner selection labels.


runsOnGroupOptional ​
public readonly runsOnGroup: GroupRunnerOptions;

Github Runner Group selection options.


RunsOnOptions ​

Options for selecting the GitHub Runner that a job runs on.

Initializer ​

import { RunsOnOptions } from 'projen'

const runsOnOptions: RunsOnOptions = { ... }

Properties ​

NameTypeDescription
runsOn
string[]Github Runner selection labels.
runsOnGroup
GroupRunnerOptions
Github Runner Group selection options.

runsOnOptional ​
public readonly runsOn: string[];
  • Type: string[]
  • Default: ["ubuntu-latest"]

Github Runner selection labels.


runsOnGroupOptional ​
public readonly runsOnGroup: GroupRunnerOptions;

Github Runner Group selection options.


SampleDirOptions ​

SampleDir options.

Initializer ​

import { SampleDirOptions } from 'projen'

const sampleDirOptions: SampleDirOptions = { ... }

Properties ​

NameTypeDescription
files
{[ key: string ]: string}The files to render into the directory.
sourceDir
stringAbsolute path to a directory to copy files from (does not need to be text files).

filesOptional ​
public readonly files: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

The files to render into the directory.

These files get added after any files from source if that option is specified (replacing if names overlap).


sourceDirOptional ​
public readonly sourceDir: string;
  • Type: string

Absolute path to a directory to copy files from (does not need to be text files).

If your project is typescript-based and has configured testdir to be a subdirectory of src, sample files should outside of the src directory otherwise they may not be copied. For example:

new SampleDir(this, 'public', { source: path.join(__dirname, '..', 'sample-assets') });

SampleFileOptions ​

Options for the SampleFile object.

Initializer ​

import { SampleFileOptions } from 'projen'

const sampleFileOptions: SampleFileOptions = { ... }

Properties ​

NameTypeDescription
contents
stringThe contents of the file to write.
sourcePath
stringAbsolute path to a file to copy the contents from (does not need to be a text file).

contentsOptional ​
public readonly contents: string;
  • Type: string

The contents of the file to write.


sourcePathOptional ​
public readonly sourcePath: string;
  • Type: string

Absolute path to a file to copy the contents from (does not need to be a text file).

If your project is Typescript-based and has configured testdir to be a subdirectory of src, sample files should outside of the src directory, otherwise they may not be copied. For example:

new SampleFile(this, 'assets/icon.png', { sourcePath: path.join(__dirname, '..', 'sample-assets', 'icon.png') });

SampleReadmeProps ​

SampleReadme Properties.

Initializer ​

import { SampleReadmeProps } from 'projen'

const sampleReadmeProps: SampleReadmeProps = { ... }

Properties ​

NameTypeDescription
contents
stringThe contents.
filename
stringThe name of the README.md file.

contentsOptional ​
public readonly contents: string;
  • Type: string
  • Default: "# replace this"

The contents.


filenameOptional ​
public readonly filename: string;
  • Type: string
  • Default: "README.md"

The name of the README.md file.


Example

"readme.md"

SnapshotOptions ​

Options for the Snapshot synthesis.

Initializer ​

import { SnapshotOptions } from 'projen'

const snapshotOptions: SnapshotOptions = { ... }

Properties ​

NameTypeDescription
parseJson
booleanParse .json files as a JS object for improved inspection. This will fail if the contents are invalid JSON.

parseJsonOptional ​
public readonly parseJson: boolean;
  • Type: boolean
  • Default: true parse .json files into an object

Parse .json files as a JS object for improved inspection. This will fail if the contents are invalid JSON.


SourceCodeOptions ​

Options for SourceCodeFile.

Initializer ​

import { SourceCodeOptions } from 'projen'

const sourceCodeOptions: SourceCodeOptions = { ... }

Properties ​

NameTypeDescription
executable
booleanWhether the generated file should be marked as executable.
indent
numberIndentation size.
readonly
booleanWhether the generated file should be readonly.

executableOptional ​
public readonly executable: boolean;
  • Type: boolean
  • Default: false

Whether the generated file should be marked as executable.


indentOptional ​
public readonly indent: number;
  • Type: number
  • Default: 2

Indentation size.


readonlyOptional ​
public readonly readonly: boolean;
  • Type: boolean
  • Default: true

Whether the generated file should be readonly.


TaskCommonOptions ​

Initializer ​

import { TaskCommonOptions } from 'projen'

const taskCommonOptions: TaskCommonOptions = { ... }

Properties ​

NameTypeDescription
condition
stringA shell command which determines if the this task should be executed.
cwd
stringThe working directory for all steps in this task (unless overridden by the step).
description
stringThe description of this build command.
env
{[ key: string ]: string}Defines environment variables for the execution of this task.
requiredEnv
string[]A set of environment variables that must be defined in order to execute this task.
shell
TaskShell
The shell used to run this task's commands, including its condition and $(...) environment evaluation. Use {@link TaskShell} to pick a built-in or an explicit invocation. Set at project, task or step level; the nearest declared level wins.

conditionOptional ​
public readonly condition: string;
  • Type: string

A shell command which determines if the this task should be executed.

If the program exits with a zero exit code, steps will be executed. A non-zero code means that task will be skipped.


cwdOptional ​
public readonly cwd: string;
  • Type: string
  • Default: process.cwd()

The working directory for all steps in this task (unless overridden by the step).


descriptionOptional ​
public readonly description: string;
  • Type: string
  • Default: the task name

The description of this build command.


envOptional ​
public readonly env: {[ key: string ]: string};
  • Type: {[ key: string ]: string}
  • Default: {}

Defines environment variables for the execution of this task.

Values in this map will be evaluated in a shell, so you can do stuff like $(echo "foo").


requiredEnvOptional ​
public readonly requiredEnv: string[];
  • Type: string[]

A set of environment variables that must be defined in order to execute this task.

Task execution will fail if one of these is not defined.


shellOptional ​
public readonly shell: TaskShell;
  • Type: TaskShell
  • Default: inherited from the task/project, otherwise the built-in projen shell

The shell used to run this task's commands, including its condition and $(...) environment evaluation. Use {@link TaskShell} to pick a built-in or an explicit invocation. Set at project, task or step level; the nearest declared level wins.


TaskOptions ​

Initializer ​

import { TaskOptions } from 'projen'

const taskOptions: TaskOptions = { ... }

Properties ​

NameTypeDescription
condition
stringA shell command which determines if the this task should be executed.
cwd
stringThe working directory for all steps in this task (unless overridden by the step).
description
stringThe description of this build command.
env
{[ key: string ]: string}Defines environment variables for the execution of this task.
requiredEnv
string[]A set of environment variables that must be defined in order to execute this task.
shell
TaskShell
The shell used to run this task's commands, including its condition and $(...) environment evaluation. Use {@link TaskShell} to pick a built-in or an explicit invocation. Set at project, task or step level; the nearest declared level wins.
args
string[]Should the provided exec shell command receive fixed args.
exec
stringShell command to execute as the first command of the task.
execArgs
string[]Shell command to execute as the first command of the task, provided as a list of the program followed by its arguments (an "argv").
receiveArgs
booleanShould the provided exec shell command receive args passed to the task.
steps
TaskStep[]
List of task steps to run.

conditionOptional ​
public readonly condition: string;
  • Type: string

A shell command which determines if the this task should be executed.

If the program exits with a zero exit code, steps will be executed. A non-zero code means that task will be skipped.


cwdOptional ​
public readonly cwd: string;
  • Type: string
  • Default: process.cwd()

The working directory for all steps in this task (unless overridden by the step).


descriptionOptional ​
public readonly description: string;
  • Type: string
  • Default: the task name

The description of this build command.


envOptional ​
public readonly env: {[ key: string ]: string};
  • Type: {[ key: string ]: string}
  • Default: {}

Defines environment variables for the execution of this task.

Values in this map will be evaluated in a shell, so you can do stuff like $(echo "foo").


requiredEnvOptional ​
public readonly requiredEnv: string[];
  • Type: string[]

A set of environment variables that must be defined in order to execute this task.

Task execution will fail if one of these is not defined.


shellOptional ​
public readonly shell: TaskShell;
  • Type: TaskShell
  • Default: inherited from the task/project, otherwise the built-in projen shell

The shell used to run this task's commands, including its condition and $(...) environment evaluation. Use {@link TaskShell} to pick a built-in or an explicit invocation. Set at project, task or step level; the nearest declared level wins.


argsOptional ​
public readonly args: string[];
  • Type: string[]
  • Default: no arguments are passed to the step

Should the provided exec shell command receive fixed args.

[{@link TaskStepOptions.args }]({@link TaskStepOptions.args })


execOptional ​
public readonly exec: string;
  • Type: string
  • Default: add steps using task.exec(command) or task.spawn(subtask)

Shell command to execute as the first command of the task.

A single shell string, so only pass trusted input: an interpolated value is interpreted by the shell too. Use execArgs for arguments you did not write literally.

Mutually exclusive with execArgs.


execArgsOptional ​
public readonly execArgs: string[];
  • Type: string[]
  • Default: add steps using task.execArgs(args), task.exec(command) or task.spawn(subtask)

Shell command to execute as the first command of the task, provided as a list of the program followed by its arguments (an "argv").

A convenient alternative to exec: arguments with spaces or special characters are passed through as-is, with no quoting needed. The elements are not run through a shell, so environment variables ($FOO) are not expanded and other shell features are unavailable.

[TaskStep.execArgs * Mutually exclusive with exec.](TaskStep.execArgs * Mutually exclusive with exec.)


receiveArgsOptional ​
public readonly receiveArgs: boolean;
  • Type: boolean
  • Default: false

Should the provided exec shell command receive args passed to the task.

[{@link TaskStepOptions.receiveArgs }]({@link TaskStepOptions.receiveArgs })


stepsOptional ​
public readonly steps: TaskStep[];

List of task steps to run.


TasksManifest ​

Schema for tasks.json.

Initializer ​

import { TasksManifest } from 'projen'

const tasksManifest: TasksManifest = { ... }

Properties ​

NameTypeDescription
env
{[ key: string ]: string}Environment for all tasks.
manifestVersion
numberThe version of the tasks manifest schema.
shell
string | string[]The default task shell, in tasks.json form: a keyword ("projen" or "system") or an invocation argument list. See {@link TaskCommonOptions.shell}.
tasks
{[ key: string ]: TaskSpec}
All tasks available for this project.

envOptional ​
public readonly env: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Environment for all tasks.


manifestVersionOptional ​
public readonly manifestVersion: number;
  • Type: number
  • Default: the manifest is treated as a legacy (unversioned) manifest

The version of the tasks manifest schema.

Used by the task runtime to detect manifests produced by a newer version of projen. Manifests generated by older versions of projen omit this field and are treated as "legacy" for backwards compatibility.


shellOptional ​
public readonly shell: string | string[];
  • Type: string | string[]

The default task shell, in tasks.json form: a keyword ("projen" or "system") or an invocation argument list. See {@link TaskCommonOptions.shell}.


tasksOptional ​
public readonly tasks: {[ key: string ]: TaskSpec};

All tasks available for this project.


TaskSpec ​

Specification of a single task.

The tasks.json (manifest) form of a task. {@link TaskCommonOptions} is the form used to define one; they differ only in the rendered shell field.

Initializer ​

import { TaskSpec } from 'projen'

const taskSpec: TaskSpec = { ... }

Properties ​

NameTypeDescription
name
stringTask name.
condition
stringA shell command which determines if the this task should be executed.
cwd
stringThe working directory for all steps in this task (unless overridden by the step).
description
stringThe description of this build command.
env
{[ key: string ]: string}Defines environment variables for the execution of this task.
requiredEnv
string[]A set of environment variables that must be defined in order to execute this task.
shell
string | string[]The task shell in tasks.json form: a keyword ("projen" or "system") or an invocation argument list.
steps
TaskStep[]
Task steps.

nameRequired ​
public readonly name: string;
  • Type: string

Task name.


conditionOptional ​
public readonly condition: string;
  • Type: string

A shell command which determines if the this task should be executed.

If the program exits with a zero exit code, steps will be executed. A non-zero code means that task will be skipped.


cwdOptional ​
public readonly cwd: string;
  • Type: string
  • Default: process.cwd()

The working directory for all steps in this task (unless overridden by the step).


descriptionOptional ​
public readonly description: string;
  • Type: string
  • Default: the task name

The description of this build command.


envOptional ​
public readonly env: {[ key: string ]: string};
  • Type: {[ key: string ]: string}
  • Default: {}

Defines environment variables for the execution of this task.

Values in this map will be evaluated in a shell, so you can do stuff like $(echo "foo").


requiredEnvOptional ​
public readonly requiredEnv: string[];
  • Type: string[]

A set of environment variables that must be defined in order to execute this task.

Task execution will fail if one of these is not defined.


shellOptional ​
public readonly shell: string | string[];
  • Type: string | string[]
  • Default: the built-in projen shell

The task shell in tasks.json form: a keyword ("projen" or "system") or an invocation argument list.


stepsOptional ​
public readonly steps: TaskStep[];

Task steps.


TaskStep ​

A single step within a task.

The step could either be the execution of a shell command or execution of a sub-task, by name.

The tasks.json (manifest) form of a step. {@link TaskStepOptions} is the form used to define steps (via task.exec() etc.); they differ only in the rendered shell field.

Initializer ​

import { TaskStep } from 'projen'

const taskStep: TaskStep = { ... }

Properties ​

NameTypeDescription
args
string[]A list of fixed arguments always passed to the step.
builtin
stringThe name of a built-in task to execute.
condition
stringA shell command which determines if the this step should be executed.
cwd
stringThe working directory for this step.
env
{[ key: string ]: string}Defines environment variables for the execution of this step (exec and builtin only).
exec
stringShell command to execute.
execArgs
string[]Shell command to execute, provided as a list of the program followed by its arguments (an "argv").
name
stringStep name.
outputEnv
stringCapture this step's standard output and expose it to later steps as an environment variable with this name.
receiveArgs
booleanShould this step receive args passed to the task.
say
stringPrint a message.
shell
string | string[]The step shell in tasks.json form: a keyword ("projen" or "system") or an invocation argument list.
spawn
stringSubtask to execute.

argsOptional ​
public readonly args: string[];
  • Type: string[]
  • Default: no arguments are passed to the step

A list of fixed arguments always passed to the step.

[{@link TaskStepOptions.args }]({@link TaskStepOptions.args })


builtinOptional ​
public readonly builtin: string;
  • Type: string
  • Default: do not execute a builtin task

The name of a built-in task to execute.

Built-in tasks are node.js programs baked into the projen module and as component runtime helpers.

The name is a path relative to the projen lib/ directory (without the .task.js extension). For example, if your built in builtin task is under src/release/resolve-version.task.ts, then this would be release/resolve-version.


conditionOptional ​
public readonly condition: string;
  • Type: string

A shell command which determines if the this step should be executed.

If the program exits with a zero exit code, the step will be executed. A non-zero code means the step will be skipped (subsequent task steps will still be evaluated/executed).


cwdOptional ​
public readonly cwd: string;
  • Type: string
  • Default: determined by the task

The working directory for this step.


envOptional ​
public readonly env: {[ key: string ]: string};
  • Type: {[ key: string ]: string}
  • Default: no environment variables defined in step

Defines environment variables for the execution of this step (exec and builtin only).

[{@link TaskStepOptions.env }]({@link TaskStepOptions.env })


execOptional ​
public readonly exec: string;
  • Type: string
  • Default: don't execute a shell command

Shell command to execute.

A single shell string, so only pass trusted input: an interpolated value is interpreted by the shell too. Use execArgs for arguments you did not write literally.


execArgsOptional ​
public readonly execArgs: string[];
  • Type: string[]
  • Default: don't execute a shell command

Shell command to execute, provided as a list of the program followed by its arguments (an "argv").

Often more convenient than exec: each element is passed to the program as-is, so arguments with spaces or special characters don't need quoting. Fixed (args) or received (receiveArgs) arguments are inserted wherever a $@ element appears, or appended at the end if there is none.

The elements are not run through a shell, so environment variables ($FOO) are not expanded and other shell features are unavailable. Use exec if you need them.

Mutually exclusive with exec.


Example

{ execArgs: ["echo", "hello world"] }
nameOptional ​
public readonly name: string;
  • Type: string
  • Default: no name

Step name.


outputEnvOptional ​
public readonly outputEnv: string;
  • Type: string
  • Default: stdout is not captured

Capture this step's standard output and expose it to later steps as an environment variable with this name.

[{@link TaskStepOptions.outputEnv }]({@link TaskStepOptions.outputEnv })


receiveArgsOptional ​
public readonly receiveArgs: boolean;
  • Type: boolean
  • Default: false

Should this step receive args passed to the task.

[{@link TaskStepOptions.receiveArgs }]({@link TaskStepOptions.receiveArgs })


sayOptional ​
public readonly say: string;
  • Type: string
  • Default: don't say anything

Print a message.


shellOptional ​
public readonly shell: string | string[];
  • Type: string | string[]
  • Default: the task's (or project's) shell

The step shell in tasks.json form: a keyword ("projen" or "system") or an invocation argument list.


spawnOptional ​
public readonly spawn: string;
  • Type: string
  • Default: don't spawn a subtask

Subtask to execute.


TaskStepOptions ​

Options for task steps.

Initializer ​

import { TaskStepOptions } from 'projen'

const taskStepOptions: TaskStepOptions = { ... }

Properties ​

NameTypeDescription
args
string[]A list of fixed arguments always passed to the step.
condition
stringA shell command which determines if the this step should be executed.
cwd
stringThe working directory for this step.
env
{[ key: string ]: string}Defines environment variables for the execution of this step (exec and builtin only).
name
stringStep name.
outputEnv
stringCapture this step's (trimmed) stdout into an environment variable of this name, visible to all later steps of the task run.
receiveArgs
booleanShould this step receive args passed to the task.
shell
TaskShell
The shell used to run this step, overriding the task/project shell.

argsOptional ​
public readonly args: string[];
  • Type: string[]
  • Default: no arguments are passed to the step

A list of fixed arguments always passed to the step.

Useful to re-use existing tasks without having to re-define the whole task.
Fixed args are always passed to the step, even if receiveArgs is false and are always passed before any args the task is called with.

If the step executes a shell commands, args are passed through at the end of the exec shell command.
The position of the args can be changed by including the marker $@ inside the command string.

If the step spawns a subtask, args are passed to the subtask. The subtask must define steps receiving args for this to have any effect.

If the step calls a builtin script, args are passed to the script. It is up to the script to use or discard the arguments.


Example

task.spawn("deploy", { args: ["--force"] });
conditionOptional ​
public readonly condition: string;
  • Type: string

A shell command which determines if the this step should be executed.

If the program exits with a zero exit code, the step will be executed. A non-zero code means the step will be skipped (subsequent task steps will still be evaluated/executed).


cwdOptional ​
public readonly cwd: string;
  • Type: string
  • Default: determined by the task

The working directory for this step.


envOptional ​
public readonly env: {[ key: string ]: string};
  • Type: {[ key: string ]: string}
  • Default: no environment variables defined in step

Defines environment variables for the execution of this step (exec and builtin only).

Values in this map can be simple, literal values or shell expressions that will be evaluated at runtime e.g. $(echo "foo").


Example

{ "foo": "bar", "boo": "$(echo baz)" }
nameOptional ​
public readonly name: string;
  • Type: string
  • Default: no name

Step name.


outputEnvOptional ​
public readonly outputEnv: string;
  • Type: string
  • Default: stdout is not captured

Capture this step's (trimmed) stdout into an environment variable of this name, visible to all later steps of the task run.

For spawn steps the spawned subtask's combined stdout is captured.

Set only when the step runs (a skipped step leaves it unset) and always overwrites. The step's output still streams live.


receiveArgsOptional ​
public readonly receiveArgs: boolean;
  • Type: boolean
  • Default: false

Should this step receive args passed to the task.

If true, args are passed through at the end of the exec shell command.
The position of the args can be changed by including the marker $@ inside the command string.

If the marker is explicitly double-quoted ("$@") arguments will be wrapped in double quotes, approximating the whitespace preserving behavior of bash variable expansion.

If the step spawns a subtask, args are passed to the subtask. The subtask must define steps receiving args for this to have any effect.


Example

task.exec("echo Hello $@ World!", { receiveArgs: true });
shellOptional ​
public readonly shell: TaskShell;
  • Type: TaskShell
  • Default: the task's (or project's) shell

The shell used to run this step, overriding the task/project shell.

[{@link TaskCommonOptions.shell }]({@link TaskCommonOptions.shell })


TextFileOptions ​

Options for TextFile.

Initializer ​

import { TextFileOptions } from 'projen'

const textFileOptions: TextFileOptions = { ... }

Properties ​

NameTypeDescription
committed
booleanIndicates whether this file should be committed to git or ignored.
editGitignore
booleanUpdate the project's .gitignore file.
executable
booleanWhether the generated file should be marked as executable.
marker
booleanAdds the projen marker to the file.
readonly
booleanWhether the generated file should be readonly.
lines
string[]The contents of the text file.

committedOptional ​
public readonly committed: boolean;
  • Type: boolean
  • Default: true

Indicates whether this file should be committed to git or ignored.

By default, all generated files are committed and anti-tamper is used to protect against manual modifications.


editGitignoreOptional ​
public readonly editGitignore: boolean;
  • Type: boolean
  • Default: true

Update the project's .gitignore file.


executableOptional ​
public readonly executable: boolean;
  • Type: boolean
  • Default: false

Whether the generated file should be marked as executable.


markerOptional ​
public readonly marker: boolean;
  • Type: boolean
  • Default: marker will be included as long as the project is not ejected

Adds the projen marker to the file.


readonlyOptional ​
public readonly readonly: boolean;
  • Type: boolean
  • Default: true

Whether the generated file should be readonly.


linesOptional ​
public readonly lines: string[];
  • Type: string[]
  • Default: [] empty file

The contents of the text file.

You can use addLine() to append lines.


TomlFileOptions ​

Options for TomlFile.

Initializer ​

import { TomlFileOptions } from 'projen'

const tomlFileOptions: TomlFileOptions = { ... }

Properties ​

NameTypeDescription
committed
booleanIndicates whether this file should be committed to git or ignored.
editGitignore
booleanUpdate the project's .gitignore file.
executable
booleanWhether the generated file should be marked as executable.
marker
booleanAdds the projen marker to the file.
readonly
booleanWhether the generated file should be readonly.
obj
anyThe object that will be serialized. You can modify the object's contents before synthesis.
omitEmpty
booleanOmits empty objects and arrays.

committedOptional ​
public readonly committed: boolean;
  • Type: boolean
  • Default: true

Indicates whether this file should be committed to git or ignored.

By default, all generated files are committed and anti-tamper is used to protect against manual modifications.


editGitignoreOptional ​
public readonly editGitignore: boolean;
  • Type: boolean
  • Default: true

Update the project's .gitignore file.


executableOptional ​
public readonly executable: boolean;
  • Type: boolean
  • Default: false

Whether the generated file should be marked as executable.


markerOptional ​
public readonly marker: boolean;
  • Type: boolean
  • Default: marker will be included as long as the project is not ejected

Adds the projen marker to the file.


readonlyOptional ​
public readonly readonly: boolean;
  • Type: boolean
  • Default: true

Whether the generated file should be readonly.


objOptional ​
public readonly obj: any;
  • Type: any
  • Default: {} an empty object (use file.obj to mutate).

The object that will be serialized. You can modify the object's contents before synthesis.

Serialization of the object is similar to JSON.stringify with few enhancements:

  • values that are functions will be called during synthesis and the result will be serialized - this allow to have lazy values.
  • Set will be converted to array
  • Map will be converted to a plain object ({ key: value, ... }})
  • RegExp without flags will be converted to string representation of the source

omitEmptyOptional ​
public readonly omitEmpty: boolean;
  • Type: boolean
  • Default: false

Omits empty objects and arrays.


VersionBranchOptions ​

Options to pass to modifyBranchEnvironment.

Initializer ​

import { VersionBranchOptions } from 'projen'

const versionBranchOptions: VersionBranchOptions = { ... }

Properties ​

NameTypeDescription
majorVersion
numberThe major versions released from this branch.
minMajorVersion
numberThe minimum major version to release.
minorVersion
numberThe minor versions released from this branch.
prerelease
stringBump the version as a pre-release tag.
tagPrefix
stringAutomatically add the given prefix to release tags. Useful if you are releasing on multiple branches with overlapping version numbers.

majorVersionOptional ​
public readonly majorVersion: number;
  • Type: number

The major versions released from this branch.


minMajorVersionOptional ​
public readonly minMajorVersion: number;
  • Type: number

The minimum major version to release.


minorVersionOptional ​
public readonly minorVersion: number;
  • Type: number

The minor versions released from this branch.


prereleaseOptional ​
public readonly prerelease: string;
  • Type: string
  • Default: normal releases

Bump the version as a pre-release tag.


tagPrefixOptional ​
public readonly tagPrefix: string;
  • Type: string
  • Default: no prefix

Automatically add the given prefix to release tags. Useful if you are releasing on multiple branches with overlapping version numbers.

Note: this prefix is used to detect the latest tagged version when bumping, so if you change this on a project with an existing version history, you may need to manually tag your latest release with the new prefix.


VersionOptions ​

Options for Version.

Initializer ​

import { VersionOptions } from 'projen'

const versionOptions: VersionOptions = { ... }

Properties ​

NameTypeDescription
artifactsDirectory
stringThe name of the directory into which changelog.md and version.txt files are emitted.
versionInputFile
stringA name of a .json file to set the version field in after a bump.
bumpPackage
stringThe commit-and-tag-version compatible package used to bump the package version, as a dependency string.
nextVersionCommand
stringA shell command to control the next version to release.
releasableCommits
ReleasableCommits
Find commits that should be considered releasable Used to decide if a release is required.
tagPrefix
stringThe tag prefix corresponding to this version.
versionrcOptions
{[ key: string ]: any}Custom configuration for versionrc file used by standard-release.

artifactsDirectoryRequired ​
public readonly artifactsDirectory: string;
  • Type: string

The name of the directory into which changelog.md and version.txt files are emitted.


versionInputFileRequired ​
public readonly versionInputFile: string;
  • Type: string

A name of a .json file to set the version field in after a bump.


Example

"package.json"
bumpPackageOptional ​
public readonly bumpPackage: string;
  • Type: string
  • Default: "commit-and-tag-version@13"

The commit-and-tag-version compatible package used to bump the package version, as a dependency string.

This can be any compatible package version, including the deprecated standard-version@9.


nextVersionCommandOptional ​
public readonly nextVersionCommand: string;
  • Type: string
  • Default: The next version will be determined based on the commit history and project settings.

A shell command to control the next version to release.

If present, this shell command will be run before the bump is executed, and it determines what version to release. It will be executed in the following environment:

  • Working directory: the project directory.
  • $VERSION: the current version. Looks like 1.2.3.
  • $LATEST_TAG: the most recent tag. Looks like prefix-v1.2.3, or may be unset.
  • $SUGGESTED_BUMP: the suggested bump action based on commits. One of major|minor|patch|none.

The command should print one of the following to stdout:

  • Nothing: the next version number will be determined based on commit history.
  • x.y.z: the next version number will be x.y.z.
  • major|minor|patch: the next version number will be the current version number with the indicated component bumped.

releasableCommitsOptional ​
public readonly releasableCommits: ReleasableCommits;

Find commits that should be considered releasable Used to decide if a release is required.


tagPrefixOptional ​
public readonly tagPrefix: string;
  • Type: string

The tag prefix corresponding to this version.


versionrcOptionsOptional ​
public readonly versionrcOptions: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

Custom configuration for versionrc file used by standard-release.


XmlFileOptions ​

Options for XmlFile.

Initializer ​

import { XmlFileOptions } from 'projen'

const xmlFileOptions: XmlFileOptions = { ... }

Properties ​

NameTypeDescription
committed
booleanIndicates whether this file should be committed to git or ignored.
editGitignore
booleanUpdate the project's .gitignore file.
executable
booleanWhether the generated file should be marked as executable.
marker
booleanAdds the projen marker to the file.
readonly
booleanWhether the generated file should be readonly.
obj
anyThe object that will be serialized. You can modify the object's contents before synthesis.
omitEmpty
booleanOmits empty objects and arrays.

committedOptional ​
public readonly committed: boolean;
  • Type: boolean
  • Default: true

Indicates whether this file should be committed to git or ignored.

By default, all generated files are committed and anti-tamper is used to protect against manual modifications.


editGitignoreOptional ​
public readonly editGitignore: boolean;
  • Type: boolean
  • Default: true

Update the project's .gitignore file.


executableOptional ​
public readonly executable: boolean;
  • Type: boolean
  • Default: false

Whether the generated file should be marked as executable.


markerOptional ​
public readonly marker: boolean;
  • Type: boolean
  • Default: marker will be included as long as the project is not ejected

Adds the projen marker to the file.


readonlyOptional ​
public readonly readonly: boolean;
  • Type: boolean
  • Default: true

Whether the generated file should be readonly.


objOptional ​
public readonly obj: any;
  • Type: any
  • Default: {} an empty object (use file.obj to mutate).

The object that will be serialized. You can modify the object's contents before synthesis.

Serialization of the object is similar to JSON.stringify with few enhancements:

  • values that are functions will be called during synthesis and the result will be serialized - this allow to have lazy values.
  • Set will be converted to array
  • Map will be converted to a plain object ({ key: value, ... }})
  • RegExp without flags will be converted to string representation of the source

omitEmptyOptional ​
public readonly omitEmpty: boolean;
  • Type: boolean
  • Default: false

Omits empty objects and arrays.


YamlFileOptions ​

Options for JsonFile.

Initializer ​

import { YamlFileOptions } from 'projen'

const yamlFileOptions: YamlFileOptions = { ... }

Properties ​

NameTypeDescription
committed
booleanIndicates whether this file should be committed to git or ignored.
editGitignore
booleanUpdate the project's .gitignore file.
executable
booleanWhether the generated file should be marked as executable.
marker
booleanAdds the projen marker to the file.
readonly
booleanWhether the generated file should be readonly.
obj
anyThe object that will be serialized. You can modify the object's contents before synthesis.
omitEmpty
booleanOmits empty objects and arrays.
lineWidth
numberMaximum line width (set to 0 to disable folding).

committedOptional ​
public readonly committed: boolean;
  • Type: boolean
  • Default: true

Indicates whether this file should be committed to git or ignored.

By default, all generated files are committed and anti-tamper is used to protect against manual modifications.


editGitignoreOptional ​
public readonly editGitignore: boolean;
  • Type: boolean
  • Default: true

Update the project's .gitignore file.


executableOptional ​
public readonly executable: boolean;
  • Type: boolean
  • Default: false

Whether the generated file should be marked as executable.


markerOptional ​
public readonly marker: boolean;
  • Type: boolean
  • Default: marker will be included as long as the project is not ejected

Adds the projen marker to the file.


readonlyOptional ​
public readonly readonly: boolean;
  • Type: boolean
  • Default: true

Whether the generated file should be readonly.


objOptional ​
public readonly obj: any;
  • Type: any
  • Default: {} an empty object (use file.obj to mutate).

The object that will be serialized. You can modify the object's contents before synthesis.

Serialization of the object is similar to JSON.stringify with few enhancements:

  • values that are functions will be called during synthesis and the result will be serialized - this allow to have lazy values.
  • Set will be converted to array
  • Map will be converted to a plain object ({ key: value, ... }})
  • RegExp without flags will be converted to string representation of the source

omitEmptyOptional ​
public readonly omitEmpty: boolean;
  • Type: boolean
  • Default: false

Omits empty objects and arrays.


lineWidthOptional ​
public readonly lineWidth: number;
  • Type: number
  • Default: 0

Maximum line width (set to 0 to disable folding).


Classes ​

DevEnvironmentDockerImage ​

Options for specifying the Docker image of the container.

Static Functions ​

NameDescription
fromFile
The relative path of a Dockerfile that defines the container contents.
fromImage
A publicly available Docker image.

fromFile ​
import { DevEnvironmentDockerImage } from 'projen'

DevEnvironmentDockerImage.fromFile(dockerFile: string)

The relative path of a Dockerfile that defines the container contents.

Example

'.gitpod.Docker'
dockerFileRequired ​
  • Type: string

a relative path.


fromImage ​
import { DevEnvironmentDockerImage } from 'projen'

DevEnvironmentDockerImage.fromImage(image: string)

A publicly available Docker image.

Example

'ubuntu:latest'
imageRequired ​
  • Type: string

a Docker image.


Properties ​

NameTypeDescription
dockerFile
stringThe relative path of a Dockerfile that defines the container contents.
image
stringA publicly available Docker image.

dockerFileOptional ​
public readonly dockerFile: string;
  • Type: string

The relative path of a Dockerfile that defines the container contents.


imageOptional ​
public readonly image: string;
  • Type: string

A publicly available Docker image.


DockerComposeService ​

A docker-compose service.

Initializers ​

import { DockerComposeService } from 'projen'

new DockerComposeService(serviceName: string, serviceDescription: DockerComposeServiceDescription)
NameTypeDescription
serviceName
stringThe name of the docker compose service.
serviceDescription
DockerComposeServiceDescription
No description.

serviceNameRequired ​
  • Type: string

The name of the docker compose service.


serviceDescriptionRequired ​

Methods ​

NameDescription
addDependsOn
Make the service depend on another service.
addEnvironment
Add an environment variable.
addLabel
Add a label.
addNetwork
Add a network to the service.
addPort
Add a port mapping.
addVolume
Add a volume to the service.

addDependsOn ​
public addDependsOn(serviceName: IDockerComposeServiceName): void

Make the service depend on another service.

serviceNameRequired ​

addEnvironment ​
public addEnvironment(name: string, value: string): void

Add an environment variable.

nameRequired ​
  • Type: string

environment variable name.


valueRequired ​
  • Type: string

value of the environment variable.


addLabel ​
public addLabel(name: string, value: string): void

Add a label.

nameRequired ​
  • Type: string

environment variable name.


valueRequired ​
  • Type: string

value of the environment variable.


addNetwork ​
public addNetwork(network: IDockerComposeNetworkBinding): void

Add a network to the service.

networkRequired ​

addPort ​
public addPort(publishedPort: number, targetPort: number, options?: DockerComposePortMappingOptions): void

Add a port mapping.

publishedPortRequired ​
  • Type: number

Published port number.


targetPortRequired ​
  • Type: number

Container's port number.


optionsOptional ​

Port mapping options.


addVolume ​
public addVolume(volume: IDockerComposeVolumeBinding): void

Add a volume to the service.

volumeRequired ​

Properties ​

NameTypeDescription
dependsOn
IDockerComposeServiceName[]
Other services that this service depends on.
environment
{[ key: string ]: string}Environment variables.
labels
{[ key: string ]: string}Attached labels.
networks
IDockerComposeNetworkBinding[]
Networks mounted in the container.
ports
DockerComposeServicePort[]
Published ports.
serviceName
stringName of the service.
volumes
IDockerComposeVolumeBinding[]
Volumes mounted in the container.
command
string[]Command to run in the container.
entrypoint
string[]Entrypoint to run in the container.
image
stringDocker image.
imageBuild
DockerComposeBuild
Docker image build instructions.
platform
stringTarget platform.
privileged
booleanRun in privileged mode.

dependsOnRequired ​
public readonly dependsOn: IDockerComposeServiceName[];

Other services that this service depends on.


environmentRequired ​
public readonly environment: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Environment variables.


labelsRequired ​
public readonly labels: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Attached labels.


networksRequired ​
public readonly networks: IDockerComposeNetworkBinding[];

Networks mounted in the container.


portsRequired ​
public readonly ports: DockerComposeServicePort[];

Published ports.


serviceNameRequired ​
public readonly serviceName: string;
  • Type: string

Name of the service.


volumesRequired ​
public readonly volumes: IDockerComposeVolumeBinding[];

Volumes mounted in the container.


commandOptional ​
public readonly command: string[];
  • Type: string[]

Command to run in the container.


entrypointOptional ​
public readonly entrypoint: string[];
  • Type: string[]

Entrypoint to run in the container.


imageOptional ​
public readonly image: string;
  • Type: string

Docker image.


imageBuildOptional ​
public readonly imageBuild: DockerComposeBuild;

Docker image build instructions.


platformOptional ​
public readonly platform: string;
  • Type: string

Target platform.


privilegedOptional ​
public readonly privileged: boolean;
  • Type: boolean

Run in privileged mode.


JsonPatch ​

Utility for applying RFC-6902 JSON-Patch to a document.

Use the the JsonPatch.apply(doc, ...ops) function to apply a set of operations to a JSON document and return the result.

Operations can be created using the factory methods JsonPatch.add(), JsonPatch.remove(), etc.

Example

const output = JsonPatch.apply(input,
JsonPatch.replace('/world/hi/there', 'goodbye'),
JsonPatch.add('/world/foo/', 'boom'),
JsonPatch.remove('/hello'));

Static Functions ​

NameDescription
add
Adds a value to an object or inserts it into an array.
apply
Applies a set of JSON-Patch (RFC-6902) operations to document and returns the result.
copy
Copies a value from one location to another within the JSON document.
escapePath
Escapes a json pointer path.
move
Moves a value from one location to the other.
remove
Removes a value from an object or array.
replace
Replaces a value.
test
Tests that the specified value is set in the document.

add ​
import { JsonPatch } from 'projen'

JsonPatch.add(path: string, value: any)

Adds a value to an object or inserts it into an array.

In the case of an array, the value is inserted before the given index. The - character can be used instead of an index to insert at the end of an array.

Example

JsonPatch.add('/biscuits/1', { "name": "Ginger Nut" })
pathRequired ​
  • Type: string

valueRequired ​
  • Type: any

apply ​
import { JsonPatch } from 'projen'

JsonPatch.apply(document: any, ops: ...JsonPatch[])

Applies a set of JSON-Patch (RFC-6902) operations to document and returns the result.

documentRequired ​
  • Type: any

The document to patch.


opsRequired ​

The operations to apply.


copy ​
import { JsonPatch } from 'projen'

JsonPatch.copy(from: string, path: string)

Copies a value from one location to another within the JSON document.

Both from and path are JSON Pointers.

Example

JsonPatch.copy('/biscuits/0', '/best_biscuit')
fromRequired ​
  • Type: string

pathRequired ​
  • Type: string

escapePath ​
import { JsonPatch } from 'projen'

JsonPatch.escapePath(path: string)

Escapes a json pointer path.

pathRequired ​
  • Type: string

The raw pointer.


move ​
import { JsonPatch } from 'projen'

JsonPatch.move(from: string, path: string)

Moves a value from one location to the other.

Both from and path are JSON Pointers.

Example

JsonPatch.move('/biscuits', '/cookies')
fromRequired ​
  • Type: string

pathRequired ​
  • Type: string

remove ​
import { JsonPatch } from 'projen'

JsonPatch.remove(path: string)

Removes a value from an object or array.

Example

JsonPatch.remove('/biscuits/0')
pathRequired ​
  • Type: string

replace ​
import { JsonPatch } from 'projen'

JsonPatch.replace(path: string, value: any)

Replaces a value.

Equivalent to a “remove” followed by an “add”.

Example

JsonPatch.replace('/biscuits/0/name', 'Chocolate Digestive')
pathRequired ​
  • Type: string

valueRequired ​
  • Type: any

test ​
import { JsonPatch } from 'projen'

JsonPatch.test(path: string, value: any, failureBehavior?: TestFailureBehavior)

Tests that the specified value is set in the document.

If the test fails, then the patch as a whole should not apply.

Example

JsonPatch.test('/best_biscuit/name', 'Choco Leibniz')
pathRequired ​
  • Type: string

valueRequired ​
  • Type: any

failureBehaviorOptional ​

Projects ​

Programmatic API for projen.

Static Functions ​

NameDescription
createProject
Creates a new project with defaults.

createProject ​
import { Projects } from 'projen'

Projects.createProject(options: CreateProjectOptions)

Creates a new project with defaults.

This function creates the project type in-process (with in VM) and calls .synth() on it (if options.synth is not false).

At the moment, it also generates a .projenrc.js file with the same code that was just executed. In the future, this will also be done by the project type, so we can easily support multiple languages of projenrc.

An environment variable (PROJEN_CREATE_PROJECT=true) is set within the VM so that custom project types can detect whether the current synthesis is the result of a new project creation (and take additional steps accordingly)

optionsRequired ​

ReleasableCommits ​

Find commits that should be considered releasable to decide if a release is required.

This setting only controls whether a release is triggered, yes or no. The paths used here are independent of the code that controls what commits are inspected to determine the version number.

Static Functions ​

NameDescription
everyCommit
Release every commit.
exec
Use an arbitrary shell command to find releasable commits since the latest tag.
featuresAndFixes
Release only features and fixes.
ofType
Limit commits by their conventional commit type.

everyCommit ​
import { ReleasableCommits } from 'projen'

ReleasableCommits.everyCommit(path?: string)

Release every commit.

This will only not release if the most recent commit is tagged with the latest matching tag.

pathOptional ​
  • Type: string

Consider only commits that are enough to explain how the files that match the specified paths came to be.

This path is relative to the current working dir of the bump task, i.e. to only consider commits of a subproject use ".".


exec ​
import { ReleasableCommits } from 'projen'

ReleasableCommits.exec(cmd: string)

Use an arbitrary shell command to find releasable commits since the latest tag.

A new release will be initiated, if the number of returned commits is greater than zero. Must return a newline separate list of commits that should considered releasable. $LATEST_TAG is available as an environment variable (set to the actual latest tag for the given prefix).

Example

"git log --oneline $LATEST_TAG..HEAD -- ."
cmdRequired ​
  • Type: string

featuresAndFixes ​
import { ReleasableCommits } from 'projen'

ReleasableCommits.featuresAndFixes(path?: string)

Release only features and fixes.

Shorthand for ReleasableCommits.onlyOfType(['feat', 'fix']).

pathOptional ​
  • Type: string

Consider only commits that are enough to explain how the files that match the specified paths came to be.

This path is relative to the current working dir of the bump task, i.e. to only consider commits of a subproject use ".".


ofType ​
import { ReleasableCommits } from 'projen'

ReleasableCommits.ofType(types: string[], path?: string)

Limit commits by their conventional commit type.

This will only release commit that match one of the provided types. Commits are required to follow the conventional commit spec and will be ignored otherwise.

typesRequired ​
  • Type: string[]

List of conventional commit types that should be released.


pathOptional ​
  • Type: string

Consider only commits that are enough to explain how the files that match the specified paths came to be.

This path is relative to the current working dir of the bump task, i.e. to only consider commits of a subproject use ".".


Properties ​

NameTypeDescription
cmd
stringNo description.

cmdRequired ​
public readonly cmd: string;
  • Type: string

Task ​

A task that can be performed on the project.

Modeled as a series of shell commands and subtasks.

Initializers ​

import { Task } from 'projen'

new Task(name: string, props?: TaskOptions)
NameTypeDescription
name
stringNo description.
props
TaskOptions
No description.

nameRequired ​
  • Type: string

propsOptional ​

Methods ​

NameDescription
addCondition
Add a command to execute which determines if the task should be skipped.
addSteps
Adds steps to this task.
builtin
Execute a builtin task.
env
Adds an environment variable to this task.
exec
Executes a shell command.
execArgs
Executes a command provided as a list of the program followed by its arguments (an "argv").
insertStep
Insert one or more steps at a given index.
lock
Forbid additional changes to this task.
prependExec
Adds a command at the beginning of the task.
prependSay
Says something at the beginning of the task.
prependSpawn
Adds a spawn instruction at the beginning of the task.
prependSteps
Adds steps at the beginning of this task.
removeStep
No description.
reset
Reset the task so it no longer has any commands.
say
Say something.
spawn
Spawns a sub-task.
updateStep
No description.

addCondition ​
public addCondition(condition: ...string[]): void

Add a command to execute which determines if the task should be skipped.

If a condition already exists, the new condition will be appended with && delimiter.

[{@link Task.condition }]({@link Task.condition })

conditionRequired ​
  • Type: ...string[]

The command to execute.


addSteps ​
public addSteps(steps: ...TaskStep[]): void

Adds steps to this task.

This is a generic method that accepts any task step (exec, spawn, say, builtin).

stepsRequired ​

The steps to add.


builtin ​
public builtin(name: string): void

Execute a builtin task.

Builtin tasks are programs bundled as part of projen itself and used as helpers for various components.

In the future we should support built-in tasks from external modules.

nameRequired ​
  • Type: string

The name of the builtin task to execute (e.g. release/resolve-version).


env ​
public env(name: string, value: string): void

Adds an environment variable to this task.

nameRequired ​
  • Type: string

The name of the variable.


valueRequired ​
  • Type: string

The value.

If the value is surrounded by $(), we will evaluate it within a subshell and use the result as the value of the environment variable.


exec ​
public exec(command: string, options?: TaskStepOptions): void

Executes a shell command.

commandRequired ​
  • Type: string

Shell command.


optionsOptional ​

Options.


execArgs ​
public execArgs(command: string[], options?: TaskStepOptions): void

Executes a command provided as a list of the program followed by its arguments (an "argv").

A convenient alternative to Task.exec: arguments with spaces or special characters are passed through as-is, with no quoting needed. The elements are not run through a shell, so environment variables ($FOO) are not expanded and other shell features are unavailable.

Example

task.execArgs(["echo", "hello world"]);
commandRequired ​
  • Type: string[]

The program followed by its arguments.


optionsOptional ​

Options.


insertStep ​
public insertStep(index: number, steps: ...TaskStep[]): void

Insert one or more steps at a given index.

indexRequired ​
  • Type: number

Steps will be inserted before this index.

May be negative to count backwards from the end, or may be == steps().length to insert at the end.


stepsRequired ​

The steps to insert.


lock ​
public lock(): void

Forbid additional changes to this task.

prependExec ​
public prependExec(command: string, options?: TaskStepOptions): void

Adds a command at the beginning of the task.

commandRequired ​
  • Type: string

The command to add.


optionsOptional ​

prependSay ​
public prependSay(message: string, options?: TaskStepOptions): void

Says something at the beginning of the task.

messageRequired ​
  • Type: string

Your message.


optionsOptional ​

prependSpawn ​
public prependSpawn(subtask: Task, options?: TaskStepOptions): void

Adds a spawn instruction at the beginning of the task.

subtaskRequired ​

The subtask to execute.


optionsOptional ​

prependSteps ​
public prependSteps(steps: ...TaskStep[]): void

Adds steps at the beginning of this task.

stepsRequired ​

The steps to add.


removeStep ​
public removeStep(index: number): void
indexRequired ​
  • Type: number

The index of the step to remove.


reset ​
public reset(command?: string, options?: TaskStepOptions): void

Reset the task so it no longer has any commands.

commandOptional ​
  • Type: string

the first command to add to the task after it was cleared.


optionsOptional ​

say ​
public say(message: string, options?: TaskStepOptions): void

Say something.

messageRequired ​
  • Type: string

Your message.


optionsOptional ​

Options.


spawn ​
public spawn(subtask: Task, options?: TaskStepOptions): void

Spawns a sub-task.

subtaskRequired ​

The subtask to execute.


optionsOptional ​

updateStep ​
public updateStep(index: number, step: TaskStep): void
indexRequired ​
  • Type: number

The index of the step to edit.


stepRequired ​

The new step to replace the old one entirely, it is not merged with the old step.


Properties ​

NameTypeDescription
envVars
{[ key: string ]: string}Returns all environment variables in the task level.
name
stringTask name.
steps
TaskStep[]
Returns an immutable copy of all the step specifications of the task.
condition
stringA command to execute which determines if the task should be skipped.
cwd
stringReturns the working directory for this task.
description
stringReturns the description of this task.
shell
TaskShell
The shell used to run this task's commands, or undefined when inheriting the built-in default shell.

envVarsRequired ​
public readonly envVars: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Returns all environment variables in the task level.


nameRequired ​
public readonly name: string;
  • Type: string

Task name.


stepsRequired ​
public readonly steps: TaskStep[];

Returns an immutable copy of all the step specifications of the task.


conditionOptional ​
public readonly condition: string;
  • Type: string

A command to execute which determines if the task should be skipped.

If it returns a zero exit code, the task will not be executed.


cwdOptional ​
public readonly cwd: string;
  • Type: string

Returns the working directory for this task.

Sets the working directory for this task.


descriptionOptional ​
public readonly description: string;
  • Type: string

Returns the description of this task.

Sets the description of this task.


shellOptional ​
public readonly shell: TaskShell;

The shell used to run this task's commands, or undefined when inheriting the built-in default shell.

Sets the shell used to run this task's commands.

[{@link TaskCommonOptions.shell }]({@link TaskCommonOptions.shell })


TaskShell ​

The shell used to run a task's commands - including its condition and any $(...) environment-variable evaluation.

Choose one of the built-in shells, or provide an explicit shell invocation:

  • {@link TaskShell.projen} (the default) - the built-in cross-platform shell.
  • {@link TaskShell.system} - the operating system's native shell.
  • {@link TaskShell.bash} / {@link TaskShell.sh} - common POSIX shells.
  • {@link TaskShell.command} - an arbitrary shell invocation given as an explicit argument list, e.g. TaskShell.command(["npx", "-c"]).

A shell can be set at the project (tasks), task and step level, and the nearest declared level wins (it is a scalar override, not merged).

Static Functions ​

NameDescription
bash
Runs commands through bash -c.
command
An arbitrary shell invocation, given as an explicit argument list.
projen
The built-in cross-platform shell (the default).
sh
Runs commands through sh -c.
system
The operating system's native shell (/bin/sh on POSIX, cmd.exe on Windows).

bash ​
import { TaskShell } from 'projen'

TaskShell.bash()

Runs commands through bash -c.

command ​
import { TaskShell } from 'projen'

TaskShell.command(command: string[])

An arbitrary shell invocation, given as an explicit argument list.

The task command is appended as the final argument, so the invocation must accept the command as its last argument (e.g. bash -c, sh -c, npx -c, yarn exec).

Example

TaskShell.command(["npx", "-c"]);
commandRequired ​
  • Type: string[]

The shell program followed by its arguments.

Must not be empty.


projen ​
import { TaskShell } from 'projen'

TaskShell.projen()

The built-in cross-platform shell (the default).

It interprets POSIX-style task syntax (mkdir -p, &&, $VAR, ...) identically on every platform, including Windows.

sh ​
import { TaskShell } from 'projen'

TaskShell.sh()

Runs commands through sh -c.

system ​
import { TaskShell } from 'projen'

TaskShell.system()

The operating system's native shell (/bin/sh on POSIX, cmd.exe on Windows).

Use this to opt out of the cross-platform shell and run commands through whatever shell the host provides.

Steps given as an argv (execArgs) are spawned without a shell, so on Windows they cannot run .cmd/.bat shims such as npm-installed CLIs.

Testing ​

A Testing static class with a .synth helper for getting a snapshots of construct outputs. Useful for snapshot testing with Jest.

Example

`expect(Testing.synth(someProject)).toMatchSnapshot()`

Static Functions ​

NameDescription
synth
Produces a simple JS object that represents the contents of the projects with field names being file paths.

synth ​
import { Testing } from 'projen'

Testing.synth(project: Project, options?: SnapshotOptions)

Produces a simple JS object that represents the contents of the projects with field names being file paths.

projectRequired ​

the project to produce a snapshot for.


optionsOptional ​

Protocols ​

ICompareString ​

Methods ​

NameDescription
compare
No description.

compare ​
public compare(a: string, b: string): number
aRequired ​
  • Type: string

The first string.


bRequired ​
  • Type: string

The second string.


IDevEnvironment ​

  • Implemented By: projen.vscode.DevContainer, Gitpod, projen.vscode.IDevContainerEnvironment, IDevEnvironment

Abstract interface for container-based development environments, such as Gitpod and GitHub Codespaces.

Methods ​

NameDescription
addDockerImage
Add a custom Docker image or Dockerfile for the container.
addPorts
Adds ports that should be exposed (forwarded) from the container.
addTasks
Adds tasks to run when the container starts.
addVscodeExtensions
Adds a list of VSCode extensions that should be automatically installed in the container.

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

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

portsRequired ​
  • Type: ...string[]

The new ports.


addTasks ​
public addTasks(tasks: ...Task[]): void

Adds tasks to run when the container starts.

tasksRequired ​

The new tasks.


addVscodeExtensions ​
public addVscodeExtensions(extensions: ...string[]): void

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

extensionsRequired ​
  • Type: ...string[]

The extension IDs.


IDockerComposeNetworkBinding ​

Network binding information.

Methods ​

NameDescription
bind
Binds the requested network to the docker-compose network configuration and provide mounting instructions for synthesis.

bind ​
public bind(networkConfig: IDockerComposeNetworkConfig): string

Binds the requested network to the docker-compose network configuration and provide mounting instructions for synthesis.

networkConfigRequired ​

the network configuration.


IDockerComposeNetworkConfig ​

Storage for network configuration.

Methods ​

NameDescription
addNetworkConfiguration
Add network configuration to the repository.

addNetworkConfiguration ​
public addNetworkConfiguration(networkName: string, configuration: DockerComposeNetworkConfig): void

Add network configuration to the repository.

networkNameRequired ​
  • Type: string

configurationRequired ​

IDockerComposeServiceName ​

An interface providing the name of a docker compose service.

Properties ​

NameTypeDescription
serviceName
stringThe name of the docker compose service.

serviceNameRequired ​
public readonly serviceName: string;
  • Type: string

The name of the docker compose service.


IDockerComposeVolumeBinding ​

Volume binding information.

Methods ​

NameDescription
bind
Binds the requested volume to the docker-compose volume configuration and provide mounting instructions for synthesis.

bind ​
public bind(volumeConfig: IDockerComposeVolumeConfig): DockerComposeVolumeMount

Binds the requested volume to the docker-compose volume configuration and provide mounting instructions for synthesis.

volumeConfigRequired ​

the volume configuration.


IDockerComposeVolumeConfig ​

Storage for volume configuration.

Methods ​

NameDescription
addVolumeConfiguration
Add volume configuration to the repository.

addVolumeConfiguration ​
public addVolumeConfiguration(volumeName: string, configuration: DockerComposeVolumeConfig): void

Add volume configuration to the repository.

volumeNameRequired ​
  • Type: string

configurationRequired ​

IResolvable ​

Methods ​

NameDescription
toJSON
Resolves and returns content.

toJSON ​
public toJSON(): any

Resolves and returns content.

IResolver ​

API for resolving tokens when synthesizing file content.

Methods ​

NameDescription
resolve
Given a value (object/string/array/whatever, looks up any functions inside the object and returns an object where all functions are called.

resolve ​
public resolve(value: any, options?: ResolveOptions): any

Given a value (object/string/array/whatever, looks up any functions inside the object and returns an object where all functions are called.

valueRequired ​
  • Type: any

The value to resolve.


optionsOptional ​

IScriptRunner ​

A script runner that can produce the configuration to execute a file of a particular type.

Methods ​

NameDescription
configFor
Produce the configuration to run the given entrypoint.

configFor ​
public configFor(entrypoint: string): RunScriptConfig

Produce the configuration to run the given entrypoint.

entrypointRequired ​
  • Type: string

Enums ​

AiAgent ​

Supported AI coding assistants and their instruction file locations.

Members ​

NameDescription
GITHUB_COPILOT
GitHub Copilot - .github/copilot-instructions.md.
CURSOR
Cursor IDE - .cursor/rules/project.md.
CLAUDE
Claude Code - CLAUDE.md.
AMAZON_Q
Amazon Q - .amazonq/rules/project.md.
KIRO
Kiro - .kiro/steering/project.md.
CODEX
OpenAI Codex - AGENTS.md.

GITHUB_COPILOT ​

GitHub Copilot - .github/copilot-instructions.md.


CURSOR ​

Cursor IDE - .cursor/rules/project.md.


CLAUDE ​

Claude Code - CLAUDE.md.


AMAZON_Q ​

Amazon Q - .amazonq/rules/project.md.


KIRO ​

Kiro - .kiro/steering/project.md.


CODEX ​

OpenAI Codex - AGENTS.md.


DependencyType ​

Type of dependency.

Members ​

NameDescription
RUNTIME
The dependency is required for the program/library during runtime.
PEER
The dependency is required at runtime but expected to be installed by the consumer.
BUNDLED
The dependency is bundled and shipped with the module, so consumers are not required to install it.
BUILD
The dependency is required to run the build task.
TEST
The dependency is required to run the test task.
DEVENV
The dependency is required for development (e.g. IDE plugins).
OVERRIDE
Transient dependency that needs to be overwritten.
OPTIONAL
An optional dependency that may be used at runtime if available, but is not required.

RUNTIME ​

The dependency is required for the program/library during runtime.


PEER ​

The dependency is required at runtime but expected to be installed by the consumer.


BUNDLED ​

The dependency is bundled and shipped with the module, so consumers are not required to install it.


BUILD ​

The dependency is required to run the build task.


TEST ​

The dependency is required to run the test task.


DEVENV ​

The dependency is required for development (e.g. IDE plugins).


OVERRIDE ​

Transient dependency that needs to be overwritten.

Available for Node packages


OPTIONAL ​

An optional dependency that may be used at runtime if available, but is not required.

It is expected to be installed by the consumer.


DockerComposeProtocol ​

Network protocol for port mapping.

Members ​

NameDescription
TCP
TCP protocol.
UDP
UDP protocol.

TCP ​

TCP protocol.


UDP ​

UDP protocol.


EndOfLine ​

The end of line characters supported by git.

Members ​

NameDescription
AUTO
Maintain existing (mixed values within one file are normalised by looking at what's used after the first line).
CRLF
Carriage Return + Line Feed characters (\r\n), common on Windows.
LF
Line Feed only (\n), common on Linux and macOS as well as inside git repos.
NONE
Disable and do not configure the end of line character.

AUTO ​

Maintain existing (mixed values within one file are normalised by looking at what's used after the first line).


CRLF ​

Carriage Return + Line Feed characters (\r\n), common on Windows.


LF ​

Line Feed only (\n), common on Linux and macOS as well as inside git repos.


NONE ​

Disable and do not configure the end of line character.


GitpodOnOpen ​

What to do when a service on a port is detected.

Members ​

NameDescription
OPEN_BROWSER
Open a new browser tab.
OPEN_PREVIEW
Open a preview on the right side of the IDE.
NOTIFY
Show a notification asking the user what to do (default).
IGNORE
Do nothing.

OPEN_BROWSER ​

Open a new browser tab.


OPEN_PREVIEW ​

Open a preview on the right side of the IDE.


NOTIFY ​

Show a notification asking the user what to do (default).


IGNORE ​

Do nothing.


GitpodOpenIn ​

Configure where in the IDE the terminal should be opened.

Members ​

NameDescription
BOTTOM
the bottom panel (default).
LEFT
the left panel.
RIGHT
the right panel.
MAIN
the main editor area.

BOTTOM ​

the bottom panel (default).


LEFT ​

the left panel.


RIGHT ​

the right panel.


MAIN ​

the main editor area.


GitpodOpenMode ​

Configure how the terminal should be opened relative to the previous task.

Members ​

NameDescription
TAB_AFTER
Opens in the same tab group right after the previous tab.
TAB_BEFORE
Opens in the same tab group left before the previous tab.
SPLIT_RIGHT
Splits and adds the terminal to the right.
SPLIT_LEFT
Splits and adds the terminal to the left.
SPLIT_TOP
Splits and adds the terminal to the top.
SPLIT_BOTTOM
Splits and adds the terminal to the bottom.

TAB_AFTER ​

Opens in the same tab group right after the previous tab.


TAB_BEFORE ​

Opens in the same tab group left before the previous tab.


SPLIT_RIGHT ​

Splits and adds the terminal to the right.


SPLIT_LEFT ​

Splits and adds the terminal to the left.


SPLIT_TOP ​

Splits and adds the terminal to the top.


SPLIT_BOTTOM ​

Splits and adds the terminal to the bottom.


GitpodPortVisibility ​

Whether the port visibility should be private or public.

Members ​

NameDescription
PUBLIC
Allows everyone with the port URL to access the port (default).
PRIVATE
Only allows users with workspace access to access the port.

PUBLIC ​

Allows everyone with the port URL to access the port (default).


PRIVATE ​

Only allows users with workspace access to access the port.


InitProjectOptionHints ​

Choices for how to display commented out options in projenrc files.

Does not apply to projenrc.json files.

Members ​

NameDescription
ALL
Display all possible options (grouped by which interface they belong to).
FEATURED
Display only featured options, in alphabetical order.
NONE
Display no extra options.

ALL ​

Display all possible options (grouped by which interface they belong to).


Display only featured options, in alphabetical order.


NONE ​

Display no extra options.


LogLevel ​

Logging verbosity.

Members ​

NameDescription
OFF
No description.
ERROR
No description.
WARN
No description.
INFO
No description.
DEBUG
No description.
VERBOSE
No description.

OFF ​

ERROR ​

WARN ​

INFO ​

DEBUG ​

VERBOSE ​

RenovatebotMinimumReleaseAgeBehaviour ​

Behaviour when a release timestamp is missing for minimumReleaseAge.

https://docs.renovatebot.com/configuration-options/#minimumreleaseagebehaviour

Members ​

NameDescription
TIMESTAMP_REQUIRED
A release without a timestamp is not treated as stable.
TIMESTAMP_OPTIONAL
A release without a timestamp is treated as stable.

TIMESTAMP_REQUIRED ​

A release without a timestamp is not treated as stable.


TIMESTAMP_OPTIONAL ​

A release without a timestamp is treated as stable.


RenovatebotScheduleInterval ​

How often to check for new versions and raise pull requests for version updates.

https://docs.renovatebot.com/presets-schedule/

Members ​

NameDescription
ANY_TIME
Run at any time.
EARLY_MONDAYS
Weekly schedule on early monday mornings.
DAILY
Schedule daily.
MONTHLY
Schedule monthly.
QUARTERLY
Schedule quarterly.
WEEKENDS
Schedule for weekends.
WEEKDAYS
Schedule for weekdays.

ANY_TIME ​

Run at any time.


EARLY_MONDAYS ​

Weekly schedule on early monday mornings.


DAILY ​

Schedule daily.


MONTHLY ​

Schedule monthly.


QUARTERLY ​

Schedule quarterly.


WEEKENDS ​

Schedule for weekends.


WEEKDAYS ​

Schedule for weekdays.


TestFailureBehavior ​

Members ​

NameDescription
SKIP
Skip the current patch operation and continue with the next operation.
FAIL_SYNTHESIS
Fail the whole file synthesis.

SKIP ​

Skip the current patch operation and continue with the next operation.


FAIL_SYNTHESIS ​

Fail the whole file synthesis.