API Reference
Submodules
The following submodules are available:
- awscdk
- build
- cdk
- cdk8s
- cdktf
- circleci
- github
- github.workflows
- gitlab
- java
- javascript
- javascript.biome_config
- python
- release
- typescript
- vscode
- web
Constructs
Component
Represents a project component.
Initializers
import { Component } from 'projen'
new Component(scope: IConstruct, id?: string)
| Name | Type | Description |
|---|---|---|
| constructs.IConstruct | No description. |
| string | No description. |
scopeRequired
- Type: constructs.IConstruct
idOptional
- Type: string
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: 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)
| Name | Type | Description |
|---|---|---|
| | The parent project. |
projectRequired
- Type: Project
The parent project.
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| Adds a dependency to this project. |
| Returns a dependency by name. |
| Checks if an existing dependency satisfies a dependency requirement. |
| Removes a dependency. |
| Returns a dependency by name. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
addDependency
public addDependency(spec: string, type: DependencyType, metadata?: {[ key: string ]: any}): Dependency
Adds a dependency to this project.
specRequired
- Type: string
The dependency spec in the format MODULE[@VERSION] where MODULE is the package-manager-specific module name and VERSION is an optional semantic version requirement (e.g. ^3.4.0).
typeRequired
- Type: DependencyType
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
- Type: DependencyType
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
- Type: DependencyType
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
- Type: DependencyType
The dependency type.
This is only required if there the dependency is defined for multiple types.
tryGetDependency
public tryGetDependency(name: string, type?: DependencyType): Dependency
Returns a dependency by name.
Returns undefined if there is no dependency defined by that name or if
type is not provided and there is more then one dependency type for this
dependency.
nameRequired
- Type: string
The name of the dependency.
typeOptional
- Type: DependencyType
The dependency type.
If this dependency is defined only for a single type, this argument can be omitted.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| | 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;
- Type: Project
allRequired
public readonly all: Dependency[];
- Type: Dependency[]
A copy of all dependencies recorded for this project.
The list is sorted by type->name->version
Constants
| Name | Type | Description |
|---|---|---|
| string | The 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)
| Name | Type | Description |
|---|---|---|
| | No description. |
| | No description. |
projectRequired
- Type: Project
propsOptional
- Type: DockerComposeProps
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| Add a service to the docker-compose file. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
addService
public addService(serviceName: string, description: DockerComposeServiceDescription): DockerComposeService
Add a service to the docker-compose file.
serviceNameRequired
- Type: string
name of the service.
descriptionRequired
a service description.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| Create a bind volume that binds a host path to the target path in the container. |
| Create a named volume and mount it to the target path. |
| Create a named network and mount it to the target path. |
| Create a port mapping. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| | The Docker Compose file. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: Project
fileRequired
public readonly file: YamlFile;
- Type: YamlFile
The Docker Compose file.
FileBase
Initializers
import { FileBase } from 'projen'
new FileBase(scope: IConstruct, filePath: string, options?: FileBaseOptions)
| Name | Type | Description |
|---|---|---|
| constructs.IConstruct | No description. |
| string | No description. |
| | No description. |
scopeRequired
- Type: constructs.IConstruct
filePathRequired
- Type: string
optionsOptional
- Type: FileBaseOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Writes the file to the project's output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Writes the file to the project's output directory.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The absolute path of this file. |
| string | The file path, relative to the project's outdir. |
| boolean | Indicates if the file has been changed during synthesis. |
| string | The projen marker, used to identify files as projen-generated. |
| boolean | Indicates if the file should be marked as executable. |
| boolean | Indicates 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;
- Type: Project
absolutePathRequired
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
pathRequired
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changedOptional
public readonly changed: boolean;
- Type: boolean
Indicates if the file has been changed during synthesis.
This property is
only available in postSynthesize() hooks. If this is undefined, the
file has not been synthesized yet.
markerOptional
public readonly marker: string;
- Type: string
The projen marker, used to identify files as projen-generated.
Value is undefined if the project is being ejected.
executableRequired
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonlyRequired
public readonly readonly: boolean;
- Type: boolean
Indicates if the file should be read-only or read-write.
GitAttributesFile
Assign attributes to file names in a git repository.
Initializers
import { GitAttributesFile } from 'projen'
new GitAttributesFile(scope: IConstruct, options?: GitAttributesFileOptions)
| Name | Type | Description |
|---|---|---|
| constructs.IConstruct | No description. |
| | No description. |
scopeRequired
- Type: constructs.IConstruct
optionsOptional
- Type: GitAttributesFileOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Writes the file to the project's output directory. |
| Maps a set of attributes to a set of files. |
| Add attributes necessary to mark these files as stored in LFS. |
| Removes attributes from a set of files. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Writes the file to the project's output directory.
addAttributes
public addAttributes(glob: string, attributes: ...string[]): void
Maps a set of attributes to a set of files.
globRequired
- Type: string
Glob pattern to match files in the repo.
attributesRequired
- Type: ...string[]
Attributes to assign to these files.
addLfsPattern
public addLfsPattern(glob: string): void
Add attributes necessary to mark these files as stored in LFS.
globRequired
- Type: string
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
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The absolute path of this file. |
| string | The file path, relative to the project's outdir. |
| boolean | Indicates if the file has been changed during synthesis. |
| string | The projen marker, used to identify files as projen-generated. |
| boolean | Indicates if the file should be marked as executable. |
| boolean | Indicates if the file should be read-only or read-write. |
| | The default end of line character for text files. |
| boolean | Whether the current gitattributes file has any LFS patterns. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: Project
absolutePathRequired
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
pathRequired
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changedOptional
public readonly changed: boolean;
- Type: boolean
Indicates if the file has been changed during synthesis.
This property is
only available in postSynthesize() hooks. If this is undefined, the
file has not been synthesized yet.
markerOptional
public readonly marker: string;
- Type: string
The projen marker, used to identify files as projen-generated.
Value is undefined if the project is being ejected.
executableRequired
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonlyRequired
public readonly readonly: boolean;
- Type: boolean
Indicates if the file should be read-only or read-write.
endOfLineRequired
public readonly endOfLine: EndOfLine;
- Type: 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
- Implements: IDevEnvironment
The Gitpod component which emits .gitpod.yml.
Initializers
import { Gitpod } from 'projen'
new Gitpod(project: Project, options?: GitpodOptions)
| Name | Type | Description |
|---|---|---|
| | No description. |
| | No description. |
projectRequired
- Type: Project
optionsOptional
- Type: GitpodOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| Add a task with more granular options. |
| Add a custom Docker image or Dockerfile for the container. |
| Add ports that should be exposed (forwarded) from the container. |
| Add a prebuilds configuration for the Gitpod App. |
| Add tasks to run when gitpod starts. |
| Add a list of VSCode extensions that should be automatically installed in the container. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
addCustomTask
public addCustomTask(options: GitpodTask): void
Add a task with more granular options.
By default, all tasks will be run in parallel. To run tasks in sequence,
create a new Task and set the other tasks as subtasks.
optionsRequired
- Type: GitpodTask
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
- Type: GitpodPrebuilds
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
- Type: ...Task[]
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.
Example
'scala-lang.scala@0.3.9:O5XmjwY5Gz+0oDZAmqneJw=='
extensionsRequired
- Type: ...string[]
The extension IDs.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| any | Direct access to the gitpod configuration (escape hatch). |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: 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)
| Name | Type | Description |
|---|---|---|
| | The project to tie this file to. |
| string | - the relative path in the project to put the file. |
| | No description. |
projectRequired
- Type: Project
The project to tie this file to.
filePathRequired
- Type: string
the relative path in the project to put the file.
optionsOptional
- Type: IgnoreFileOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Writes the file to the project's output directory. |
| Add ignore patterns. |
| Ignore the files that match these patterns. |
| Always include the specified file patterns. |
| Removes patterns previously added from the ignore file. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Writes the file to the project's output directory.
addPatterns
public addPatterns(patterns: ...string[]): void
Add ignore patterns.
Files that match this pattern will be ignored. If the
pattern starts with a negation mark !, files that match will not be
ignored.
Comment lines (start with #) and blank lines ("") are filtered by default
but can be included using options specified when instantiating the component.
patternsRequired
- Type: ...string[]
Ignore patterns.
exclude
public exclude(patterns: ...string[]): void
Ignore the files that match these patterns.
patternsRequired
- Type: ...string[]
The patterns to match.
include
public include(patterns: ...string[]): void
Always include the specified file patterns.
patternsRequired
- Type: ...string[]
Patterns to include in git commits.
removePatterns
public removePatterns(patterns: ...string[]): void
Removes patterns previously added from the ignore file.
If addPattern() is called after this, the pattern will be added again.
patternsRequired
- Type: ...string[]
patters to remove.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The absolute path of this file. |
| string | The file path, relative to the project's outdir. |
| boolean | Indicates if the file has been changed during synthesis. |
| string | The projen marker, used to identify files as projen-generated. |
| boolean | Indicates if the file should be marked as executable. |
| boolean | Indicates if the file should be read-only or read-write. |
| boolean | No description. |
| boolean | No description. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: Project
absolutePathRequired
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
pathRequired
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changedOptional
public readonly changed: boolean;
- Type: boolean
Indicates if the file has been changed during synthesis.
This property is
only available in postSynthesize() hooks. If this is undefined, the
file has not been synthesized yet.
markerOptional
public readonly marker: string;
- Type: string
The projen marker, used to identify files as projen-generated.
Value is undefined if the project is being ejected.
executableRequired
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonlyRequired
public readonly readonly: boolean;
- Type: boolean
Indicates if the file should be read-only or read-write.
filterCommentLinesRequired
public readonly filterCommentLines: boolean;
- Type: boolean
filterEmptyLinesRequired
public readonly filterEmptyLines: boolean;
- Type: boolean
IniFile
Represents an INI file.
Initializers
import { IniFile } from 'projen'
new IniFile(project: Project, filePath: string, options: IniFileOptions)
| Name | Type | Description |
|---|---|---|
| | No description. |
| string | No description. |
| | No description. |
projectRequired
- Type: Project
filePathRequired
- Type: string
optionsRequired
- Type: IniFileOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Writes the file to the project's output directory. |
| Syntactic sugar for addOverride(path, undefined). |
| Adds an override to the synthesized object file. |
| Adds to an array in the synthesized object file. |
| Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Writes the file to the project's output directory.
addDeletionOverride
public addDeletionOverride(path: string): void
Syntactic sugar for addOverride(path, undefined).
pathRequired
- Type: string
The path of the value to delete.
addOverride
public addOverride(path: string, value: any): void
Adds an override to the synthesized object file.
If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal . in the property name, prefix with a \. In most
programming languages you will need to write this as "\\." because the
\ itself will need to be escaped.
For example,
project.tsconfig.file.addOverride('compilerOptions.alwaysStrict', true);
project.tsconfig.file.addOverride('compilerOptions.lib', ['dom', 'dom.iterable', 'esnext']);
would add the overrides
"compilerOptions": {
"alwaysStrict": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
]
...
}
...
pathRequired
- Type: string
The path of the property, you can use dot notation to override values in complex types.
Any intermediate keys will be created as needed.
valueRequired
- Type: any
The value.
Could be primitive or complex.
addToArray
public addToArray(path: string, values: ...any[]): void
Adds to an array in the synthesized object file.
If the array is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal . in the property name, prefix with a \. In most
programming languages you will need to write this as "\\." because the
\ itself will need to be escaped.
For example, with the following object file
"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["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
- Type: ...JsonPatch[]
The patch operations to apply.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The absolute path of this file. |
| string | The file path, relative to the project's outdir. |
| boolean | Indicates if the file has been changed during synthesis. |
| string | The projen marker, used to identify files as projen-generated. |
| boolean | Indicates if the file should be marked as executable. |
| boolean | Indicates if the file should be read-only or read-write. |
| boolean | Indicates 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;
- Type: Project
absolutePathRequired
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
pathRequired
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changedOptional
public readonly changed: boolean;
- Type: boolean
Indicates if the file has been changed during synthesis.
This property is
only available in postSynthesize() hooks. If this is undefined, the
file has not been synthesized yet.
markerOptional
public readonly marker: string;
- Type: string
The projen marker, used to identify files as projen-generated.
Value is undefined if the project is being ejected.
executableRequired
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonlyRequired
public readonly readonly: boolean;
- Type: boolean
Indicates if the file should be read-only or read-write.
omitEmptyRequired
public readonly omitEmpty: boolean;
- Type: boolean
Indicates if empty objects and arrays are omitted from the output object.
JsonFile
Represents a JSON file.
Initializers
import { JsonFile } from 'projen'
new JsonFile(scope: IConstruct, filePath: string, options: JsonFileOptions)
| Name | Type | Description |
|---|---|---|
| constructs.IConstruct | No description. |
| string | No description. |
| | No description. |
scopeRequired
- Type: constructs.IConstruct
filePathRequired
- Type: string
optionsRequired
- Type: JsonFileOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Writes the file to the project's output directory. |
| Syntactic sugar for addOverride(path, undefined). |
| Adds an override to the synthesized object file. |
| Adds to an array in the synthesized object file. |
| Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Writes the file to the project's output directory.
addDeletionOverride
public addDeletionOverride(path: string): void
Syntactic sugar for addOverride(path, undefined).
pathRequired
- Type: string
The path of the value to delete.
addOverride
public addOverride(path: string, value: any): void
Adds an override to the synthesized object file.
If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal . in the property name, prefix with a \. In most
programming languages you will need to write this as "\\." because the
\ itself will need to be escaped.
For example,
project.tsconfig.file.addOverride('compilerOptions.alwaysStrict', true);
project.tsconfig.file.addOverride('compilerOptions.lib', ['dom', 'dom.iterable', 'esnext']);
would add the overrides
"compilerOptions": {
"alwaysStrict": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
]
...
}
...
pathRequired
- Type: string
The path of the property, you can use dot notation to override values in complex types.
Any intermediate keys will be created as needed.
valueRequired
- Type: any
The value.
Could be primitive or complex.
addToArray
public addToArray(path: string, values: ...any[]): void
Adds to an array in the synthesized object file.
If the array is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal . in the property name, prefix with a \. In most
programming languages you will need to write this as "\\." because the
\ itself will need to be escaped.
For example, with the following object file
"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["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
- Type: ...JsonPatch[]
The patch operations to apply.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The absolute path of this file. |
| string | The file path, relative to the project's outdir. |
| boolean | Indicates if the file has been changed during synthesis. |
| string | The projen marker, used to identify files as projen-generated. |
| boolean | Indicates if the file should be marked as executable. |
| boolean | Indicates if the file should be read-only or read-write. |
| boolean | Indicates if empty objects and arrays are omitted from the output object. |
| boolean | No description. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: Project
absolutePathRequired
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
pathRequired
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changedOptional
public readonly changed: boolean;
- Type: boolean
Indicates if the file has been changed during synthesis.
This property is
only available in postSynthesize() hooks. If this is undefined, the
file has not been synthesized yet.
markerOptional
public readonly marker: string;
- Type: string
The projen marker, used to identify files as projen-generated.
Value is undefined if the project is being ejected.
executableRequired
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonlyRequired
public readonly readonly: boolean;
- Type: boolean
Indicates if the file should be read-only or read-write.
omitEmptyRequired
public readonly omitEmpty: boolean;
- Type: boolean
Indicates if empty objects and arrays are omitted from the output object.
supportsCommentsRequired
public readonly supportsComments: boolean;
- Type: boolean
License
Initializers
import { License } from 'projen'
new License(project: Project, options: LicenseOptions)
| Name | Type | Description |
|---|---|---|
| | No description. |
| | No description. |
projectRequired
- Type: Project
optionsRequired
- Type: LicenseOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Writes the file to the project's output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Writes the file to the project's output directory.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The absolute path of this file. |
| string | The file path, relative to the project's outdir. |
| boolean | Indicates if the file has been changed during synthesis. |
| string | The projen marker, used to identify files as projen-generated. |
| boolean | Indicates if the file should be marked as executable. |
| boolean | Indicates 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;
- Type: Project
absolutePathRequired
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
pathRequired
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changedOptional
public readonly changed: boolean;
- Type: boolean
Indicates if the file has been changed during synthesis.
This property is
only available in postSynthesize() hooks. If this is undefined, the
file has not been synthesized yet.
markerOptional
public readonly marker: string;
- Type: string
The projen marker, used to identify files as projen-generated.
Value is undefined if the project is being ejected.
executableRequired
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonlyRequired
public readonly readonly: boolean;
- Type: boolean
Indicates if the file should be read-only or read-write.
Logger
Project-level logging utilities.
Initializers
import { Logger } from 'projen'
new Logger(scope: IConstruct, options?: LoggerOptions)
| Name | Type | Description |
|---|---|---|
| constructs.IConstruct | No description. |
| | No description. |
scopeRequired
- Type: constructs.IConstruct
optionsOptional
- Type: LoggerOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| Log a message to stderr with DEBUG severity. |
| Log a message to stderr with ERROR severity. |
| Log a message to stderr with INFO severity. |
| Log a message to stderr with a given logging level. |
| Log a message to stderr with VERBOSE severity. |
| Log a message to stderr with WARN severity. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
debug
public debug(text: ...any[]): void
Log a message to stderr with DEBUG severity.
textRequired
- Type: ...any[]
strings or objects to print.
error
public error(text: ...any[]): void
Log a message to stderr with ERROR severity.
textRequired
- Type: ...any[]
strings or objects to print.
info
public info(text: ...any[]): void
Log a message to stderr with INFO severity.
textRequired
- Type: ...any[]
strings or objects to print.
log
public log(level: LogLevel, text: ...any[]): void
Log a message to stderr with a given logging level.
The message will be
printed as long as logger.level is set to the message's severity or higher.
levelRequired
- Type: LogLevel
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
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: Project
Makefile
Minimal Makefile.
Initializers
import { Makefile } from 'projen'
new Makefile(project: Project, filePath: string, options?: MakefileOptions)
| Name | Type | Description |
|---|---|---|
| | No description. |
| string | No description. |
| | No description. |
projectRequired
- Type: Project
filePathRequired
- Type: string
optionsOptional
- Type: MakefileOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Writes the file to the project's output directory. |
| Add a target to all. |
| Add multiple targets to all. |
| Add a rule to the Makefile. |
| Add multiple rules to the Makefile. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Writes the file to the project's output directory.
addAll
public addAll(target: string): Makefile
Add a target to all.
targetRequired
- Type: string
addAlls
public addAlls(targets: ...string[]): Makefile
Add multiple targets to all.
targetsRequired
- Type: ...string[]
addRule
public addRule(rule: Rule): Makefile
Add a rule to the Makefile.
ruleRequired
- Type: Rule
addRules
public addRules(rules: ...Rule[]): Makefile
Add multiple rules to the Makefile.
rulesRequired
- Type: ...Rule[]
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The absolute path of this file. |
| string | The file path, relative to the project's outdir. |
| boolean | Indicates if the file has been changed during synthesis. |
| string | The projen marker, used to identify files as projen-generated. |
| boolean | Indicates if the file should be marked as executable. |
| boolean | Indicates if the file should be read-only or read-write. |
| | List of rule definitions. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: Project
absolutePathRequired
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
pathRequired
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changedOptional
public readonly changed: boolean;
- Type: boolean
Indicates if the file has been changed during synthesis.
This property is
only available in postSynthesize() hooks. If this is undefined, the
file has not been synthesized yet.
markerOptional
public readonly marker: string;
- Type: string
The projen marker, used to identify files as projen-generated.
Value is undefined if the project is being ejected.
executableRequired
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonlyRequired
public readonly readonly: boolean;
- Type: boolean
Indicates if the file should be read-only or read-write.
rulesRequired
public readonly rules: Rule[];
- Type: Rule[]
List of rule definitions.
ObjectFile
Represents an Object file.
Initializers
import { ObjectFile } from 'projen'
new ObjectFile(scope: IConstruct, filePath: string, options: ObjectFileOptions)
| Name | Type | Description |
|---|---|---|
| constructs.IConstruct | No description. |
| string | No description. |
| | No description. |
scopeRequired
- Type: constructs.IConstruct
filePathRequired
- Type: string
optionsRequired
- Type: ObjectFileOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Writes the file to the project's output directory. |
| Syntactic sugar for addOverride(path, undefined). |
| Adds an override to the synthesized object file. |
| Adds to an array in the synthesized object file. |
| Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Writes the file to the project's output directory.
addDeletionOverride
public addDeletionOverride(path: string): void
Syntactic sugar for addOverride(path, undefined).
pathRequired
- Type: string
The path of the value to delete.
addOverride
public addOverride(path: string, value: any): void
Adds an override to the synthesized object file.
If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal . in the property name, prefix with a \. In most
programming languages you will need to write this as "\\." because the
\ itself will need to be escaped.
For example,
project.tsconfig.file.addOverride('compilerOptions.alwaysStrict', true);
project.tsconfig.file.addOverride('compilerOptions.lib', ['dom', 'dom.iterable', 'esnext']);
would add the overrides
"compilerOptions": {
"alwaysStrict": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
]
...
}
...
pathRequired
- Type: string
The path of the property, you can use dot notation to override values in complex types.
Any intermediate keys will be created as needed.
valueRequired
- Type: any
The value.
Could be primitive or complex.
addToArray
public addToArray(path: string, values: ...any[]): void
Adds to an array in the synthesized object file.
If the array is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal . in the property name, prefix with a \. In most
programming languages you will need to write this as "\\." because the
\ itself will need to be escaped.
For example, with the following object file
"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["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
- Type: ...JsonPatch[]
The patch operations to apply.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The absolute path of this file. |
| string | The file path, relative to the project's outdir. |
| boolean | Indicates if the file has been changed during synthesis. |
| string | The projen marker, used to identify files as projen-generated. |
| boolean | Indicates if the file should be marked as executable. |
| boolean | Indicates if the file should be read-only or read-write. |
| boolean | Indicates 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;
- Type: Project
absolutePathRequired
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
pathRequired
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changedOptional
public readonly changed: boolean;
- Type: boolean
Indicates if the file has been changed during synthesis.
This property is
only available in postSynthesize() hooks. If this is undefined, the
file has not been synthesized yet.
markerOptional
public readonly marker: string;
- Type: string
The projen marker, used to identify files as projen-generated.
Value is undefined if the project is being ejected.
executableRequired
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonlyRequired
public readonly readonly: boolean;
- Type: boolean
Indicates if the file should be read-only or read-write.
omitEmptyRequired
public readonly omitEmpty: boolean;
- Type: boolean
Indicates if empty objects and arrays are omitted from the output object.
Project
Base project.
Initializers
import { Project } from 'projen'
new Project(options: ProjectOptions)
| Name | Type | Description |
|---|---|---|
| | No description. |
optionsRequired
- Type: ProjectOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Exclude the matching files from pre-synth cleanup. |
| Adds a .gitignore pattern. |
| Exclude these files from the bundled package. |
| Adds a new task to this project. |
| Prints a "tip" message during synthesis. |
| Consider a set of files as "generated". |
| Called after all components are synthesized. |
| Called before all components are synthesized. |
| Removes a task from a project. |
| Returns the shell command to execute in order to run a task. |
| Synthesize all project files into outdir. |
| Finds a file at the specified relative path within this project and all its subprojects. |
| Finds a json file by name. |
| Finds an object file (like JsonFile, YamlFile, etc.) by name. |
| Finds a file at the specified relative path within this project and removes it. |
toString
public toString(): string
Returns a string representation of this construct.
addExcludeFromCleanup
public addExcludeFromCleanup(globs: ...string[]): void
Exclude the matching files from pre-synth cleanup.
Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.
globsRequired
- Type: ...string[]
The glob patterns to match.
addGitIgnore
public addGitIgnore(pattern: string): void
Adds a .gitignore pattern.
patternRequired
- Type: string
The glob pattern to ignore.
addPackageIgnore
public addPackageIgnore(_pattern: string): void
Exclude these files from the bundled package.
Implemented by project types based on the
packaging mechanism. For example, NodeProject delegates this to .npmignore.
_patternRequired
- Type: string
The glob pattern to exclude.
addTask
public addTask(name: string, props?: TaskOptions): Task
Adds a new task to this project.
This will fail if the project already has a task with this name.
nameRequired
- Type: string
The task name to add.
propsOptional
- Type: TaskOptions
Task properties.
addTip
addTippublic addTip(message: string): void
Prints a "tip" message during synthesis.
messageRequired
- Type: string
The message.
annotateGenerated
public annotateGenerated(_glob: string): void
Consider a set of files as "generated".
This method is implemented by derived classes and used for example, to add git attributes to tell GitHub that certain files are generated.
_globRequired
- Type: string
the glob pattern to match (could be a file path).
postSynthesize
public postSynthesize(): void
Called after all components are synthesized.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before all components are synthesized.
removeTask
public removeTask(name: string): Task
Removes a task from a project.
nameRequired
- Type: string
The name of the task to remove.
runTaskCommand
public runTaskCommand(task: Task): string
Returns the shell command to execute in order to run a task.
By default, this is npx projen@<version> <task>
taskRequired
- Type: Task
The task for which the command is required.
synth
public synth(): void
Synthesize all project files into outdir.
- Call "this.preSynthesize()"
- Delete all generated files
- Synthesize all subprojects
- Synthesize all components of this project
- Call "postSynthesize()" for all components of this project
- Call "this.postSynthesize()"
tryFindFile
public tryFindFile(filePath: string): FileBase
Finds a file at the specified relative path within this project and all its subprojects.
filePathRequired
- Type: string
The file path.
If this path is relative, it will be resolved from the root of this project.
tryFindJsonFile
tryFindJsonFilepublic tryFindJsonFile(filePath: string): JsonFile
Finds a json file by name.
filePathRequired
- Type: string
The file path.
tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile
Finds an object file (like JsonFile, YamlFile, etc.) by name.
filePathRequired
- Type: string
The file path.
tryRemoveFile
public tryRemoveFile(filePath: string): FileBase
Finds a file at the specified relative path within this project and removes it.
filePathRequired
- Type: string
The file path.
If this path is relative, it will be resolved from the root of this project.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| Test whether the given construct is a project. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| boolean | Whether to commit the managed files by default. |
| | No description. |
| | Returns all the components within this project. |
| | Project dependencies. |
| boolean | Whether or not the project is being ejected. |
| | All files in this project. |
| | The .gitattributes file for this repository. |
| | .gitignore. |
| | Logging utilities. |
| string | Project name. |
| string | Absolute output directory of this project. |
| | No description. |
| | No description. |
| | No description. |
| | Manages the build process of the project. |
| string | The command to use in order to run the projen CLI. |
| | The root project. |
| | Returns all the subprojects within this project. |
| | Project tasks. |
| | No description. |
| | This is the "default" task, the one that executes "projen". |
| | The options used when this project is bootstrapped via projen new. |
| | A parent project. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
buildTaskRequired
public readonly buildTask: Task;
- Type: Task
commitGeneratedRequired
public readonly commitGenerated: boolean;
- Type: boolean
Whether to commit the managed files by default.
compileTaskRequired
public readonly compileTask: Task;
- Type: Task
componentsRequired
public readonly components: Component[];
- Type: Component[]
Returns all the components within this project.
depsRequired
public readonly deps: Dependencies;
- Type: Dependencies
Project dependencies.
ejectedRequired
public readonly ejected: boolean;
- Type: boolean
Whether or not the project is being ejected.
filesRequired
public readonly files: FileBase[];
- Type: FileBase[]
All files in this project.
gitattributesRequired
public readonly gitattributes: GitAttributesFile;
- Type: GitAttributesFile
The .gitattributes file for this repository.
gitignoreRequired
public readonly gitignore: IgnoreFile;
- Type: IgnoreFile
.gitignore.
loggerRequired
public readonly logger: Logger;
- Type: 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;
- Type: Task
postCompileTaskRequired
public readonly postCompileTask: Task;
- Type: Task
preCompileTaskRequired
public readonly preCompileTask: Task;
- Type: Task
projectBuildRequired
public readonly projectBuild: ProjectBuild;
- Type: 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;
- Type: Project
The root project.
subprojectsRequired
public readonly subprojects: Project[];
- Type: Project[]
Returns all the subprojects within this project.
tasksRequired
public readonly tasks: Tasks;
- Type: Tasks
Project tasks.
testTaskRequired
public readonly testTask: Task;
- Type: Task
defaultTaskOptional
public readonly defaultTask: Task;
- Type: Task
This is the "default" task, the one that executes "projen".
Undefined if the project is being ejected.
initProjectOptional
public readonly initProject: InitProject;
- Type: 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;
- Type: Project
A parent project.
If undefined, this is the root project.
Constants
| Name | Type | Description |
|---|---|---|
| string | The 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:
- default
- pre-compile
- compile
- post-compile
- test
- package
Initializers
import { ProjectBuild } from 'projen'
new ProjectBuild(project: Project)
| Name | Type | Description |
|---|---|---|
| | No description. |
projectRequired
- Type: Project
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| | The task responsible for a full release build. |
| | Compiles the code. |
| | The "package" task. |
| | Post-compile task. |
| | Pre-compile task. |
| | Tests the code. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: Project
buildTaskRequired
public readonly buildTask: Task;
- Type: Task
The task responsible for a full release build.
compileTaskRequired
public readonly compileTask: Task;
- Type: Task
Compiles the code.
By default for node.js projects this task is empty.
packageTaskRequired
public readonly packageTask: Task;
- Type: Task
The "package" task.
postCompileTaskRequired
public readonly postCompileTask: Task;
- Type: Task
Post-compile task.
preCompileTaskRequired
public readonly preCompileTask: Task;
- Type: Task
Pre-compile task.
testTaskRequired
public readonly testTask: Task;
- Type: Task
Tests the code.
ProjectTree
Initializers
import { ProjectTree } from 'projen'
new ProjectTree(project: Project)
| Name | Type | Description |
|---|---|---|
| | No description. |
projectRequired
- Type: Project
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| | No description. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: Project
fileRequired
public readonly file: JsonFile;
- Type: JsonFile
Projenrc
Initializers
import { Projenrc } from 'projen'
new Projenrc(project: Project, options?: ProjenrcJsonOptions)
| Name | Type | Description |
|---|---|---|
| | No description. |
| | No description. |
projectRequired
- Type: Project
optionsOptional
- Type: ProjenrcJsonOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
toStringpublic toString(): string
Returns a string representation of this construct.
postSynthesize
postSynthesizepublic postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
preSynthesizepublic preSynthesize(): void
Called before synthesis.
synthesize
synthesizepublic synthesize(): void
Synthesizes files to the project output directory.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| Returns the Projenrc instance associated with a project or undefined if there is no Projenrc. |
isConstruct
isConstructimport { Projenrc } from 'projen'
Projenrc.isConstruct(x: any)
Checks if x is a construct.
Use this method instead of instanceof to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct in each copy of the constructs library
is seen as a different class, and an instance of one class will not test as
instanceof the other class. npm install will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof will behave
unpredictably. It is safest to avoid using instanceof, and using
this type-testing method instead.
xRequired
- Type: any
Any object.
isComponent
isComponentimport { Projenrc } from 'projen'
Projenrc.isComponent(x: any)
Test whether the given construct is a component.
xRequired
- Type: any
of
ofimport { Projenrc } from 'projen'
Projenrc.of(project: Project)
Returns the Projenrc instance associated with a project or undefined if there is no Projenrc.
projectRequired
- Type: Project
The project.
Properties
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The path of the projenrc file. |
nodeRequired
node- Deprecated: use
ProjenrcJson
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
project- Deprecated: use
ProjenrcJson
public readonly project: Project;
- Type: Project
filePathRequired
filePath- Deprecated: use
ProjenrcJson
public readonly filePath: string;
- Type: string
The path of the projenrc file.
ProjenrcFile
A component representing the projen runtime configuration.
Initializers
import { ProjenrcFile } from 'projen'
new ProjenrcFile(scope: IConstruct, id?: string)
| Name | Type | Description |
|---|---|---|
| constructs.IConstruct | No description. |
| string | No description. |
scopeRequired
- Type: constructs.IConstruct
idOptional
- Type: string
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| 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
- Type: Project
The project.
Properties
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The path of the projenrc file. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: 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)
| Name | Type | Description |
|---|---|---|
| | No description. |
| | No description. |
projectRequired
- Type: Project
optionsOptional
- Type: ProjenrcJsonOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| 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
- Type: Project
The project.
Properties
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The path of the projenrc file. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: Project
filePathRequired
public readonly filePath: string;
- Type: string
The path of the projenrc file.
Renovatebot
Defines renovatebot configuration for projen project.
Ignores the versions controlled by Projen.
Initializers
import { Renovatebot } from 'projen'
new Renovatebot(project: Project, options?: RenovatebotOptions)
| Name | Type | Description |
|---|---|---|
| | No description. |
| | No description. |
projectRequired
- Type: Project
optionsOptional
- Type: RenovatebotOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| | The file holding the renovatebot configuration. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: Project
fileRequired
public readonly file: JsonFile;
- Type: 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)
| Name | Type | Description |
|---|---|---|
| | Parent project to add files to. |
| string | directory to add files to. |
| | options for which files to create. |
projectRequired
- Type: Project
Parent project to add files to.
dirRequired
- Type: string
directory to add files to.
If directory already exists, nothing is added.
optionsRequired
- Type: SampleDirOptions
options for which files to create.
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: 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)
| Name | Type | Description |
|---|---|---|
| | - the project to tie this file to. |
| string | - the relative path in the project to put the file. |
| | - the options for the file. |
projectRequired
- Type: Project
the project to tie this file to.
filePathRequired
- Type: string
the relative path in the project to put the file.
optionsRequired
- Type: SampleFileOptions
the options for the file.
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: 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)
| Name | Type | Description |
|---|---|---|
| | No description. |
| | No description. |
projectRequired
- Type: Project
propsOptional
- Type: SampleReadmeProps
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: Project
SourceCode
Represents a source file.
Initializers
import { SourceCode } from 'projen'
new SourceCode(project: Project, filePath: string, options?: SourceCodeOptions)
| Name | Type | Description |
|---|---|---|
| | No description. |
| string | No description. |
| | No description. |
projectRequired
- Type: Project
filePathRequired
- Type: string
optionsOptional
- Type: SourceCodeOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| Decreases the indentation level and closes a code block. |
| Emit a line of code. |
| Opens a code block and increases the indentation level. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
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
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | No description. |
| string | No description. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: Project
filePathRequired
public readonly filePath: string;
- Type: string
markerOptional
public readonly marker: string;
- Type: string
Tasks
Defines 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)
| Name | Type | Description |
|---|---|---|
| | No description. |
projectRequired
- Type: Project
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| Adds global environment. |
| Adds a task to a project. |
| Removes a task from a project. |
| Finds a task by name. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
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
- Type: TaskOptions
Task options.
removeTask
public removeTask(name: string): Task
Removes a task from a project.
nameRequired
- Type: string
The name of the task to remove.
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
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| | All tasks. |
| {[ key: string ]: string} | Returns a copy of the currently global environment for this project. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: Project
allRequired
public readonly all: Task[];
- Type: 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.
TextFile
A text file.
Initializers
import { TextFile } from 'projen'
new TextFile(scope: IConstruct, filePath: string, options?: TextFileOptions)
| Name | Type | Description |
|---|---|---|
| constructs.IConstruct | No description. |
| string | File path. |
| | Options. |
scopeRequired
- Type: constructs.IConstruct
filePathRequired
- Type: string
File path.
optionsOptional
- Type: TextFileOptions
Options.
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Writes the file to the project's output directory. |
| Adds a line to the text file. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Writes the file to the project's output directory.
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
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The absolute path of this file. |
| string | The file path, relative to the project's outdir. |
| boolean | Indicates if the file has been changed during synthesis. |
| string | The projen marker, used to identify files as projen-generated. |
| boolean | Indicates if the file should be marked as executable. |
| boolean | Indicates 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;
- Type: Project
absolutePathRequired
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
pathRequired
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changedOptional
public readonly changed: boolean;
- Type: boolean
Indicates if the file has been changed during synthesis.
This property is
only available in postSynthesize() hooks. If this is undefined, the
file has not been synthesized yet.
markerOptional
public readonly marker: string;
- Type: string
The projen marker, used to identify files as projen-generated.
Value is undefined if the project is being ejected.
executableRequired
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonlyRequired
public readonly readonly: boolean;
- Type: boolean
Indicates if the file should be read-only or read-write.
TomlFile
Represents a TOML file.
Initializers
import { TomlFile } from 'projen'
new TomlFile(project: Project, filePath: string, options: TomlFileOptions)
| Name | Type | Description |
|---|---|---|
| | No description. |
| string | No description. |
| | No description. |
projectRequired
- Type: Project
filePathRequired
- Type: string
optionsRequired
- Type: TomlFileOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Writes the file to the project's output directory. |
| Syntactic sugar for addOverride(path, undefined). |
| Adds an override to the synthesized object file. |
| Adds to an array in the synthesized object file. |
| Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Writes the file to the project's output directory.
addDeletionOverride
public addDeletionOverride(path: string): void
Syntactic sugar for addOverride(path, undefined).
pathRequired
- Type: string
The path of the value to delete.
addOverride
public addOverride(path: string, value: any): void
Adds an override to the synthesized object file.
If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal . in the property name, prefix with a \. In most
programming languages you will need to write this as "\\." because the
\ itself will need to be escaped.
For example,
project.tsconfig.file.addOverride('compilerOptions.alwaysStrict', true);
project.tsconfig.file.addOverride('compilerOptions.lib', ['dom', 'dom.iterable', 'esnext']);
would add the overrides
"compilerOptions": {
"alwaysStrict": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
]
...
}
...
pathRequired
- Type: string
The path of the property, you can use dot notation to override values in complex types.
Any intermediate keys will be created as needed.
valueRequired
- Type: any
The value.
Could be primitive or complex.
addToArray
public addToArray(path: string, values: ...any[]): void
Adds to an array in the synthesized object file.
If the array is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal . in the property name, prefix with a \. In most
programming languages you will need to write this as "\\." because the
\ itself will need to be escaped.
For example, with the following object file
"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["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
- Type: ...JsonPatch[]
The patch operations to apply.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The absolute path of this file. |
| string | The file path, relative to the project's outdir. |
| boolean | Indicates if the file has been changed during synthesis. |
| string | The projen marker, used to identify files as projen-generated. |
| boolean | Indicates if the file should be marked as executable. |
| boolean | Indicates if the file should be read-only or read-write. |
| boolean | Indicates 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;
- Type: Project
absolutePathRequired
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
pathRequired
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changedOptional
public readonly changed: boolean;
- Type: boolean
Indicates if the file has been changed during synthesis.
This property is
only available in postSynthesize() hooks. If this is undefined, the
file has not been synthesized yet.
markerOptional
public readonly marker: string;
- Type: string
The projen marker, used to identify files as projen-generated.
Value is undefined if the project is being ejected.
executableRequired
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonlyRequired
public readonly readonly: boolean;
- Type: boolean
Indicates if the file should be read-only or read-write.
omitEmptyRequired
public readonly omitEmpty: boolean;
- Type: boolean
Indicates if empty objects and arrays are omitted from the output object.
Version
Initializers
import { Version } from 'projen'
new Version(scope: IConstruct, options: VersionOptions)
| Name | Type | Description |
|---|---|---|
| constructs.IConstruct | No description. |
| | No description. |
scopeRequired
- Type: constructs.IConstruct
optionsRequired
- Type: VersionOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| Return the environment variables to modify the bump command for release branches. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
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
- Type: VersionBranchOptions
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The package used to bump package versions, as a dependency string. |
| | No description. |
| string | The name of the changelog file (under artifactsDirectory). |
| string | The name of the file that contains the release tag (under artifactsDirectory). |
| | No description. |
| string | The name of the file that contains the version (under artifactsDirectory). |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: 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;
- Type: Task
changelogFileNameRequired
public readonly changelogFileName: string;
- Type: string
The name of the changelog file (under artifactsDirectory).
releaseTagFileNameRequired
public readonly releaseTagFileName: string;
- Type: string
The name of the file that contains the release tag (under artifactsDirectory).
unbumpTaskRequired
public readonly unbumpTask: Task;
- Type: Task
versionFileNameRequired
public readonly versionFileName: string;
- Type: string
The name of the file that contains the version (under artifactsDirectory).
Constants
| Name | Type | Description |
|---|---|---|
| string | No description. |
STANDARD_VERSIONRequired
STANDARD_VERSION- Deprecated: use
version.bumpPackageon the component instance instead
public readonly STANDARD_VERSION: string;
- Type: string
XmlFile
Represents an XML file.
Objects passed in will be synthesized using the npm "xml" library.
Initializers
import { XmlFile } from 'projen'
new XmlFile(project: Project, filePath: string, options?: XmlFileOptions)
| Name | Type | Description |
|---|---|---|
| | No description. |
| string | No description. |
| | No description. |
projectRequired
- Type: Project
filePathRequired
- Type: string
optionsOptional
- Type: XmlFileOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Writes the file to the project's output directory. |
| Syntactic sugar for addOverride(path, undefined). |
| Adds an override to the synthesized object file. |
| Adds to an array in the synthesized object file. |
| Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Writes the file to the project's output directory.
addDeletionOverride
public addDeletionOverride(path: string): void
Syntactic sugar for addOverride(path, undefined).
pathRequired
- Type: string
The path of the value to delete.
addOverride
public addOverride(path: string, value: any): void
Adds an override to the synthesized object file.
If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal . in the property name, prefix with a \. In most
programming languages you will need to write this as "\\." because the
\ itself will need to be escaped.
For example,
project.tsconfig.file.addOverride('compilerOptions.alwaysStrict', true);
project.tsconfig.file.addOverride('compilerOptions.lib', ['dom', 'dom.iterable', 'esnext']);
would add the overrides
"compilerOptions": {
"alwaysStrict": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
]
...
}
...
pathRequired
- Type: string
The path of the property, you can use dot notation to override values in complex types.
Any intermediate keys will be created as needed.
valueRequired
- Type: any
The value.
Could be primitive or complex.
addToArray
public addToArray(path: string, values: ...any[]): void
Adds to an array in the synthesized object file.
If the array is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal . in the property name, prefix with a \. In most
programming languages you will need to write this as "\\." because the
\ itself will need to be escaped.
For example, with the following object file
"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["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
- Type: ...JsonPatch[]
The patch operations to apply.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The absolute path of this file. |
| string | The file path, relative to the project's outdir. |
| boolean | Indicates if the file has been changed during synthesis. |
| string | The projen marker, used to identify files as projen-generated. |
| boolean | Indicates if the file should be marked as executable. |
| boolean | Indicates if the file should be read-only or read-write. |
| boolean | Indicates 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;
- Type: Project
absolutePathRequired
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
pathRequired
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changedOptional
public readonly changed: boolean;
- Type: boolean
Indicates if the file has been changed during synthesis.
This property is
only available in postSynthesize() hooks. If this is undefined, the
file has not been synthesized yet.
markerOptional
public readonly marker: string;
- Type: string
The projen marker, used to identify files as projen-generated.
Value is undefined if the project is being ejected.
executableRequired
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonlyRequired
public readonly readonly: boolean;
- Type: boolean
Indicates if the file should be read-only or read-write.
omitEmptyRequired
public readonly omitEmpty: boolean;
- Type: boolean
Indicates if empty objects and arrays are omitted from the output object.
YamlFile
Represents a YAML file.
Initializers
import { YamlFile } from 'projen'
new YamlFile(scope: IConstruct, filePath: string, options: YamlFileOptions)
| Name | Type | Description |
|---|---|---|
| constructs.IConstruct | No description. |
| string | No description. |
| | No description. |
scopeRequired
- Type: constructs.IConstruct
filePathRequired
- Type: string
optionsRequired
- Type: YamlFileOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Writes the file to the project's output directory. |
| Syntactic sugar for addOverride(path, undefined). |
| Adds an override to the synthesized object file. |
| Adds to an array in the synthesized object file. |
| Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Writes the file to the project's output directory.
addDeletionOverride
public addDeletionOverride(path: string): void
Syntactic sugar for addOverride(path, undefined).
pathRequired
- Type: string
The path of the value to delete.
addOverride
public addOverride(path: string, value: any): void
Adds an override to the synthesized object file.
If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal . in the property name, prefix with a \. In most
programming languages you will need to write this as "\\." because the
\ itself will need to be escaped.
For example,
project.tsconfig.file.addOverride('compilerOptions.alwaysStrict', true);
project.tsconfig.file.addOverride('compilerOptions.lib', ['dom', 'dom.iterable', 'esnext']);
would add the overrides
"compilerOptions": {
"alwaysStrict": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
]
...
}
...
pathRequired
- Type: string
The path of the property, you can use dot notation to override values in complex types.
Any intermediate keys will be created as needed.
valueRequired
- Type: any
The value.
Could be primitive or complex.
addToArray
public addToArray(path: string, values: ...any[]): void
Adds to an array in the synthesized object file.
If the array is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal . in the property name, prefix with a \. In most
programming languages you will need to write this as "\\." because the
\ itself will need to be escaped.
For example, with the following object file
"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["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
- Type: ...JsonPatch[]
The patch operations to apply.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| 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
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| | No description. |
| string | The absolute path of this file. |
| string | The file path, relative to the project's outdir. |
| boolean | Indicates if the file has been changed during synthesis. |
| string | The projen marker, used to identify files as projen-generated. |
| boolean | Indicates if the file should be marked as executable. |
| boolean | Indicates if the file should be read-only or read-write. |
| boolean | Indicates if empty objects and arrays are omitted from the output object. |
| number | Maximum line width (set to 0 to disable folding). |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: Project
absolutePathRequired
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
pathRequired
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changedOptional
public readonly changed: boolean;
- Type: boolean
Indicates if the file has been changed during synthesis.
This property is
only available in postSynthesize() hooks. If this is undefined, the
file has not been synthesized yet.
markerOptional
public readonly marker: string;
- Type: string
The projen marker, used to identify files as projen-generated.
Value is undefined if the project is being ejected.
executableRequired
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonlyRequired
public readonly readonly: boolean;
- Type: boolean
Indicates if the file should be read-only or read-write.
omitEmptyRequired
public readonly omitEmpty: boolean;
- Type: boolean
Indicates if empty objects and arrays are omitted from the output object.
lineWidthRequired
public readonly lineWidth: number;
- Type: number
Maximum line width (set to 0 to disable folding).
Structs
CreateProjectOptions
Initializer
import { CreateProjectOptions } from 'projen'
const createProjectOptions: CreateProjectOptions = { ... }
Properties
| Name | Type | Description |
|---|---|---|
| string | Directory that the project will be generated in. |
| string | Fully-qualified name of the project type (usually formatted as projen.module.ProjectType). |
| {[ key: string ]: any} | Project options. |
| | Should we render commented-out default options in the projenrc file? |
| boolean | Should we execute post synthesis hooks? |
| boolean | Should 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;
- Type: InitProjectOptionHints
- Default: InitProjectOptionHints.FEATURED
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
| Name | Type | Description |
|---|---|---|
| string | The package manager name of the dependency (e.g. leftpad for npm). |
| string | Semantic version version requirement. |
| | Which type of dependency this is (runtime, build-time, etc). |
| {[ 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;
- 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
| Name | Type | Description |
|---|---|---|
| string | The package manager name of the dependency (e.g. leftpad for npm). |
| string | Semantic 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.
DepsManifest
Initializer
import { DepsManifest } from 'projen'
const depsManifest: DepsManifest = { ... }
Properties
| Name | Type | Description |
|---|---|---|
| | All dependencies of this module. |
dependenciesRequired
public readonly dependencies: Dependency[];
- Type: 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
| Name | Type | Description |
|---|---|---|
| | A Docker image or Dockerfile for the container. |
| string[] | An array of ports that should be exposed from the container. |
| | An array of tasks that should be run when the container starts. |
| 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[];
- Type: 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
| Name | Type | Description |
|---|---|---|
| string | Docker build context directory. |
| {[ key: string ]: string} | Build args. |
| string | A 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
| Name | Type | Description |
|---|---|---|
| boolean | Set to true to indicate that standalone containers can attach to this network, in addition to services. |
| boolean | Set to true to indicate that the network is a bridge network. |
| string | Driver to use for the network. |
| object | Options for the configured driver. |
| boolean | Set to true to indicate that the network is externally created. |
| boolean | Set to true to indicate that you want to create an externally isolated overlay network. |
| | Specify custom IPAM config. |
| string[] | Attach labels to the network. |
| string | Name of the network for when the network name isn't going to work in YAML. |
| boolean | Set 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;
- Type: DockerComposeNetworkIpamConfig
- Default: unset
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
| Name | Type | Description |
|---|---|---|
| | A list with zero or more config blocks specifying custom IPAM configuration. |
| string | Driver to use for custom IPAM config. |
configOptional
public readonly config: DockerComposeNetworkIpamSubnetConfig[];
- Type: DockerComposeNetworkIpamSubnetConfig[]
- Default: value is not provided
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
| Name | Type | Description |
|---|---|---|
| string | Subnet 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
| Name | Type | Description |
|---|---|---|
| | Port mapping protocol. |
protocolOptional
public readonly protocol: DockerComposeProtocol;
- Type: DockerComposeProtocol
- Default: DockerComposeProtocol.TCP
Port mapping protocol.
DockerComposeProps
Props for DockerCompose.
Initializer
import { DockerComposeProps } from 'projen'
const dockerComposeProps: DockerComposeProps = { ... }
Properties
| Name | Type | Description |
|---|---|---|
| string | A name to add to the docker-compose.yml filename. |
| string | Docker Compose schema version do be used. |
| | 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
schemaVersion- Deprecated: - The top level
versionfield is obsolete per the Compose Specification. {@link https://github.com/compose-spec/compose-spec/blob/master/spec.md#version-and-name-top-level-elements Compose Specification}
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};
- Type: {[ key: string ]: DockerComposeServiceDescription}
Service descriptions.
DockerComposeServiceDescription
Description of a docker-compose.yml service.
Initializer
import { DockerComposeServiceDescription } from 'projen'
const dockerComposeServiceDescription: DockerComposeServiceDescription = { ... }
Properties
| Name | Type | Description |
|---|---|---|
| string[] | Provide a command to the docker container. |
| | Names of other services this service depends on. |
| string[] | Entrypoint to run in the container. |
| {[ key: string ]: string} | Add environment variables. |
| string | Use a docker image. |
| | Build a docker image. |
| {[ key: string ]: string} | Add labels. |
| | Add some networks to the service. |
| string | Add platform. |
| | Map some ports. |
| boolean | Run in privileged mode. |
| | 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[];
- Type: IDockerComposeServiceName[]
- Default: no dependencies
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.
imageBuildOptional
public readonly imageBuild: DockerComposeBuild;
- Type: DockerComposeBuild
Build a docker image.
Note: You must specify either imageBuild or image key.
labelsOptional
public readonly labels: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- Default: no labels are provided
Add labels.
networksOptional
public readonly networks: IDockerComposeNetworkBinding[];
- Type: 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[];
- Type: DockerComposeServicePort[]
- Default: no ports are mapped
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[];
- Type: 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 = { ... }