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. |
scope
Required
- Type: constructs.IConstruct
id
Optional
- 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.
x
Required
- Type: any
Any object.
isComponent
import { Component } from 'projen'
Component.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
|
| No description. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
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. |
project
Required
- 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.
spec
Required
- 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
).
type
Required
- Type: DependencyType
The type of the dependency.
metadata
Optional
- 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.
name
Required
- Type: string
The name of the dependency.
type
Optional
- 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.
name
Required
- Type: string
The name of the dependency to check (without the version).
type
Required
- Type: DependencyType
The dependency type.
expectedRange
Required
- 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.
name
Required
- Type: string
The name of the module to remove (without the version).
type
Optional
- 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.
name
Required
- Type: string
The name of the dependency.
type
Optional
- 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.
x
Required
- Type: any
Any object.
isComponent
import { Dependencies } from 'projen'
Dependencies.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- 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" }
.
spec
Required
- Type: string
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
|
| No description. |
|
| A copy of all dependencies recorded for this project. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: Project
all
Required
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_FILE
Required
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. |
project
Required
- Type: Project
props
Optional
- 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.
serviceName
Required
- Type: string
name of the service.
description
Required
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.
x
Required
- Type: any
Any object.
isComponent
import { DockerCompose } from 'projen'
DockerCompose.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- 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.
sourcePath
Required
- Type: string
Host path name.
targetPath
Required
- 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.
volumeName
Required
- Type: string
Name of the volume.
targetPath
Required
- Type: string
Target path.
options
Optional
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.
networkName
Required
- Type: string
Name of the network.
options
Optional
network configuration.
portMapping
import { DockerCompose } from 'projen'
DockerCompose.portMapping(publishedPort: number, targetPort: number, options?: DockerComposePortMappingOptions)
Create a port mapping.
publishedPort
Required
- Type: number
Published port number.
targetPort
Required
- Type: number
Container's port number.
options
Optional
Port mapping options.
serviceName
import { DockerCompose } from 'projen'
DockerCompose.serviceName(serviceName: string)
Depends on a service name.
serviceName
Required
- Type: string
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
|
| No description. |
|
| The Docker Compose file. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: Project
file
Required
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. |
scope
Required
- Type: constructs.IConstruct
filePath
Required
- Type: string
options
Optional
- 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.
x
Required
- Type: any
Any object.
isComponent
import { FileBase } from 'projen'
FileBase.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- 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. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: Project
absolutePath
Required
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
path
Required
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changed
Optional
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.
marker
Optional
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.
executable
Required
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonly
Required
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. |
scope
Required
- Type: constructs.IConstruct
options
Optional
- 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. |
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.
glob
Required
- Type: string
Glob pattern to match files in the repo.
attributes
Required
- 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.
glob
Required
- Type: string
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.
x
Required
- Type: any
Any object.
isComponent
import { GitAttributesFile } from 'projen'
GitAttributesFile.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- 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. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: Project
absolutePath
Required
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
path
Required
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changed
Optional
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.
marker
Optional
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.
executable
Required
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonly
Required
public readonly readonly: boolean;
- Type: boolean
Indicates if the file should be read-only or read-write.
endOfLine
Required
public readonly endOfLine: EndOfLine;
- Type: EndOfLine
The default end of line character for text files.
hasLfsPatterns
Required
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. |
project
Required
- Type: Project
options
Optional
- 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.
options
Required
- Type: GitpodTask
The task parameters.
addDockerImage
public addDockerImage(image: DevEnvironmentDockerImage): void
Add a custom Docker image or Dockerfile for the container.
image
Required
The Docker image.
addPorts
public addPorts(ports: ...string[]): void
Add ports that should be exposed (forwarded) from the container.
ports
Required
- Type: ...string[]
The new ports.
addPrebuilds
public addPrebuilds(config: GitpodPrebuilds): void
Add a prebuilds configuration for the Gitpod App.
config
Required
- 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.
tasks
Required
- 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=='
extensions
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { Gitpod } from 'projen'
Gitpod.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
|
| No description. |
| any | Direct access to the gitpod configuration (escape hatch). |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: Project
config
Required
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. |
project
Required
- Type: Project
The project to tie this file to.
filePath
Required
- Type: string
the relative path in the project to put the file.
options
Optional
- 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.
patterns
Required
- Type: ...string[]
Ignore patterns.
exclude
public exclude(patterns: ...string[]): void
Ignore the files that match these patterns.
patterns
Required
- Type: ...string[]
The patterns to match.
include
public include(patterns: ...string[]): void
Always include the specified file patterns.
patterns
Required
- 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.
patterns
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { IgnoreFile } from 'projen'
IgnoreFile.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- 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. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: Project
absolutePath
Required
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
path
Required
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changed
Optional
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.
marker
Optional
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.
executable
Required
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonly
Required
public readonly readonly: boolean;
- Type: boolean
Indicates if the file should be read-only or read-write.
filterCommentLines
Required
public readonly filterCommentLines: boolean;
- Type: boolean
filterEmptyLines
Required
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. |
project
Required
- Type: Project
filePath
Required
- Type: string
options
Required
- 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)
.
path
Required
- 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"
]
...
}
...
path
Required
- 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.
value
Required
- 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"]
...
}
...
path
Required
- 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.
values
Required
- Type: ...any[]
The values to add.
Could be primitive or complex.