API Reference
Submodules
The following submodules are available:
- awscdk
- build
- cdk
- cdk8s
- cdktf
- circleci
- github
- github.workflows
- gitlab
- java
- javascript
- 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. |
| 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.
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)
Name | Type | Description |
---|---|---|
| constructs.IConstruct | No description. |
scope
Required
- Type: constructs.IConstruct
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. |
| 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.
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": ["es2019"]
...
}
...
project.tsconfig.file.addToArray('compilerOptions.exclude', 'coverage');
project.tsconfig.file.addToArray('compilerOptions.lib', 'dom', 'dom.iterable', 'esnext');
would result in the following object file
"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["es2019", "dom", "dom.iterable", "esnext"]
...
}
...
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.
patch
public patch(patches: JsonPatch): void
Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information.
For example, with the following object file
"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["es2019"]
...
}
...
project.tsconfig.file.patch(JsonPatch.add("/compilerOptions/exclude/-", "coverage"));
project.tsconfig.file.patch(JsonPatch.replace("/compilerOptions/lib", ["dom", "dom.iterable", "esnext"]));
would result in the following object file
"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["dom", "dom.iterable", "esnext"]
...
}
...
patches
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { IniFile } from 'projen'
IniFile.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 | Indicates if empty objects and arrays are omitted from the output object. |
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.
omitEmpty
Required
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. |
scope
Required
- Type: constructs.IConstruct
filePath
Required
- Type: string
options
Required
- 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)
.
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": ["es2019"]
...
}
...
project.tsconfig.file.addToArray('compilerOptions.exclude', 'coverage');
project.tsconfig.file.addToArray('compilerOptions.lib', 'dom', 'dom.iterable', 'esnext');
would result in the following object file
"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["es2019", "dom", "dom.iterable", "esnext"]
...
}
...
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.
patch
public patch(patches: JsonPatch): void
Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information.
For example, with the following object file
"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["es2019"]
...
}
...
project.tsconfig.file.patch(JsonPatch.add("/compilerOptions/exclude/-", "coverage"));
project.tsconfig.file.patch(JsonPatch.replace("/compilerOptions/lib", ["dom", "dom.iterable", "esnext"]));
would result in the following object file
"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["dom", "dom.iterable", "esnext"]
...
}
...
patches
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { JsonFile } from 'projen'
JsonFile.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 | Indicates if empty objects and arrays are omitted from the output object. |
| 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.
omitEmpty
Required
public readonly omitEmpty: boolean;
- Type: boolean
Indicates if empty objects and arrays are omitted from the output object.
supportsComments
Required
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. |
project
Required
- Type: Project
options
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { License } from 'projen'
License.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.
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. |
scope
Required
- Type: constructs.IConstruct
options
Optional
- 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.
text
Required
- Type: any
strings or objects to print.
error
public error(text: any): void
Log a message to stderr with ERROR severity.
text
Required
- Type: any
strings or objects to print.
info
public info(text: any): void
Log a message to stderr with INFO severity.
text
Required
- 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.
level
Required
- Type: LogLevel
Logging verbosity.
text
Required
- Type: any
strings or objects to print.
verbose
public verbose(text: any): void
Log a message to stderr with VERBOSE severity.
text
Required
- Type: any
strings or objects to print.
warn
public warn(text: any): void
Log a message to stderr with WARN severity.
text
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { Logger } from 'projen'
Logger.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
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. |
project
Required
- Type: Project
filePath
Required
- Type: string
options
Optional
- 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.
target
Required
- Type: string
addAlls
public addAlls(targets: string): Makefile
Add multiple targets to all.
targets
Required
- Type: string
addRule
public addRule(rule: Rule): Makefile
Add a rule to the Makefile.
rule
Required
- Type: Rule
addRules
public addRules(rules: Rule): Makefile
Add multiple rules to the Makefile.
rules
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { Makefile } from 'projen'
Makefile.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. |
|
| List of rule definitions. |
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.
rules
Required
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. |
scope
Required
- Type: constructs.IConstruct
filePath
Required
- Type: string
options
Required
- 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)
.
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": ["es2019"]
...
}
...
project.tsconfig.file.addToArray('compilerOptions.exclude', 'coverage');
project.tsconfig.file.addToArray('compilerOptions.lib', 'dom', 'dom.iterable', 'esnext');
would result in the following object file
"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["es2019", "dom", "dom.iterable", "esnext"]
...
}
...
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.
patch
public patch(patches: JsonPatch): void
Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information.
For example, with the following object file
"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["es2019"]
...
}
...
project.tsconfig.file.patch(JsonPatch.add("/compilerOptions/exclude/-", "coverage"));
project.tsconfig.file.patch(JsonPatch.replace("/compilerOptions/lib", ["dom", "dom.iterable", "esnext"]));
would result in the following object file
"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["dom", "dom.iterable", "esnext"]
...
}
...
patches
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { ObjectFile } from 'projen'
ObjectFile.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 | Indicates if empty objects and arrays are omitted from the output object. |
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.
omitEmpty
Required
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. |
options
Required
- 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.
globs
Required
- Type: string
The glob patterns to match.
addGitIgnore
public addGitIgnore(pattern: string): void
Adds a .gitignore pattern.
pattern
Required
- 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
.
_pattern
Required
- 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.
name
Required
- Type: string
The task name to add.
props
Optional
- Type: TaskOptions
Task properties.
addTip
addTip
public addTip(message: string): void
Prints a "tip" message during synthesis.
message
Required
- 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.
_glob
Required
- 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.
name
Required
- 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>
task
Required
- 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.
filePath
Required
- Type: string
The file path.
If this path is relative, it will be resolved from the root of this project.
tryFindJsonFile
tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile
Finds a json file by name.
filePath
Required
- Type: string
The file path.
tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile
Finds an object file (like JsonFile, YamlFile, etc.) by name.
filePath
Required
- 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.
filePath
Required
- 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.
x
Required
- Type: any
Any object.
isProject
import { Project } from 'projen'
Project.isProject(x: any)
Test whether the given construct is a project.
x
Required
- 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.
construct
Required
- 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. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
buildTask
Required
public readonly buildTask: Task;
- Type: Task
commitGenerated
Required
public readonly commitGenerated: boolean;
- Type: boolean
Whether to commit the managed files by default.
compileTask
Required
public readonly compileTask: Task;
- Type: Task
components
Required
public readonly components: Component[];
- Type: Component[]
Returns all the components within this project.
deps
Required
public readonly deps: Dependencies;
- Type: Dependencies
Project dependencies.
ejected
Required
public readonly ejected: boolean;
- Type: boolean
Whether or not the project is being ejected.
files
Required
public readonly files: FileBase[];
- Type: FileBase[]
All files in this project.
gitattributes
Required
public readonly gitattributes: GitAttributesFile;
- Type: GitAttributesFile
The .gitattributes file for this repository.
gitignore
Required
public readonly gitignore: IgnoreFile;
- Type: IgnoreFile
.gitignore.
logger
Required
public readonly logger: Logger;
- Type: Logger
Logging utilities.
name
Required
public readonly name: string;
- Type: string
Project name.
outdir
Required
public readonly outdir: string;
- Type: string
Absolute output directory of this project.
packageTask
Required
public readonly packageTask: Task;
- Type: Task
postCompileTask
Required
public readonly postCompileTask: Task;
- Type: Task
preCompileTask
Required
public readonly preCompileTask: Task;
- Type: Task
projectBuild
Required
public readonly projectBuild: ProjectBuild;
- Type: ProjectBuild
Manages the build process of the project.
projenCommand
Required
public readonly projenCommand: string;
- Type: string
The command to use in order to run the projen CLI.
root
Required
public readonly root: Project;
- Type: Project
The root project.
subprojects
Required
public readonly subprojects: Project[];
- Type: Project[]
Returns all the subprojects within this project.
tasks
Required
public readonly tasks: Tasks;
- Type: Tasks
Project tasks.
testTask
Required
public readonly testTask: Task;
- Type: Task
defaultTask
Optional
public readonly defaultTask: Task;
- Type: Task
This is the "default" task, the one that executes "projen".
Undefined if the project is being ejected.
initProject
Optional
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.
parent
Optional
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_TASK
Required
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. |
project
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { ProjectBuild } from 'projen'
ProjectBuild.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. |
|
| The task responsible for a full release build. |
|
| Compiles the code. |
|
| The "package" task. |
|
| Post-compile task. |
|
| Pre-compile task. |
|
| Tests the code. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: Project
buildTask
Required
public readonly buildTask: Task;
- Type: Task
The task responsible for a full release build.
compileTask
Required
public readonly compileTask: Task;
- Type: Task
Compiles the code.
By default for node.js projects this task is empty.
packageTask
Required
public readonly packageTask: Task;
- Type: Task
The "package" task.
postCompileTask
Required
public readonly postCompileTask: Task;
- Type: Task
Post-compile task.
preCompileTask
Required
public readonly preCompileTask: Task;
- Type: Task
Pre-compile task.
testTask
Required
public readonly testTask: Task;
- Type: Task
Tests the code.
ProjectTree
Initializers
import { ProjectTree } from 'projen'
new ProjectTree(project: Project)
Name | Type | Description |
---|---|---|
|
| No description. |
project
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { ProjectTree } from 'projen'
ProjectTree.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. |
|
| No description. |
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: JsonFile;
- Type: JsonFile
Projenrc
Initializers
import { Projenrc } from 'projen'
new Projenrc(project: Project, options?: ProjenrcJsonOptions)
Name | Type | Description |
---|---|---|
|
| No description. |
|
| No description. |
project
Required
- Type: Project
options
Optional
- 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
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
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
isConstruct
import { Projenrc } from 'projen'
Projenrc.isConstruct(x: any)
Checks if x
is a construct.
Use this method instead of instanceof
to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs
library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct
in each copy of the constructs
library
is seen as a different class, and an instance of one class will not test as
instanceof
the other class. npm install
will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof
will behave
unpredictably. It is safest to avoid using instanceof
, and using
this type-testing method instead.
x
Required
- Type: any
Any object.
isComponent
isComponent
import { Projenrc } from 'projen'
Projenrc.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
of
of
import { Projenrc } from 'projen'
Projenrc.of(project: Project)
Returns the Projenrc
instance associated with a project or undefined
if there is no Projenrc.
project
Required
- Type: Project
The project.
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
|
| No description. |
| string | The path of the projenrc file. |
node
Required
node
- Deprecated: use
ProjenrcJson
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
project
- Deprecated: use
ProjenrcJson
public readonly project: Project;
- Type: Project
filePath
Required
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. |
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. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { ProjenrcFile } from 'projen'
ProjenrcFile.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- 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.
project
Required
- Type: Project
The project.
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
|
| No description. |
| string | The path of the projenrc file. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: Project
filePath
Required
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. |
project
Required
- Type: Project
options
Optional
- 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.
x
Required
- Type: any
Any object.
isComponent
import { ProjenrcJson } from 'projen'
ProjenrcJson.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- 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.
project
Required
- Type: Project
The project.
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
|
| No description. |
| string | The path of the projenrc file. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: Project
filePath
Required
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. |
project
Required
- Type: Project
options
Optional
- 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.
x
Required
- Type: any
Any object.
isComponent
import { Renovatebot } from 'projen'
Renovatebot.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. |
|
| The file holding the renovatebot configuration. |
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: 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. |
project
Required
- Type: Project
Parent project to add files to.
dir
Required
- Type: string
directory to add files to.
If directory already exists, nothing is added.
options
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { SampleDir } from 'projen'
SampleDir.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
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. |
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
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { SampleFile } from 'projen'
SampleFile.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
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. |
project
Required
- Type: Project
props
Optional
- 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.
x
Required
- Type: any
Any object.
isComponent
import { SampleReadme } from 'projen'
SampleReadme.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
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. |
project
Required
- Type: Project
filePath
Required
- Type: string
options
Optional
- 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.
code
Optional
- Type: string
The code after the block is closed (e.g. }
).
line
public line(code?: string): void
Emit a line of code.
code
Optional
- 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.
code
Optional
- 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.
x
Required
- Type: any
Any object.
isComponent
import { SourceCode } from 'projen'
SourceCode.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 | No description. |
| string | No description. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: Project
filePath
Required
public readonly filePath: string;
- Type: string
marker
Optional
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. |
project
Required
- 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.
name
Required
- Type: string
Environment variable name.
value
Required
- Type: string
Value.
addTask
public addTask(name: string, options?: TaskOptions): Task
Adds a task to a project.
name
Required
- Type: string
The name of the task.
options
Optional
- Type: TaskOptions
Task options.
removeTask
public removeTask(name: string): Task
Removes a task from a project.
name
Required
- 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.
name
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { Tasks } from 'projen'
Tasks.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. |
|
| All tasks. |
| {[ key: string ]: string} | Returns a copy of the currently global environment 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: Task[];
- Type: Task[]
All tasks.
env
Required
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. |
scope
Required
- Type: constructs.IConstruct
filePath
Required
- Type: string
File path.
options
Optional
- 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.
line
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { TextFile } from 'projen'
TextFile.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.
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. |
project
Required
- Type: Project
filePath
Required
- Type: string
options
Required
- 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)
.
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": ["es2019"]
...
}
...
project.tsconfig.file.addToArray('compilerOptions.exclude', 'coverage');
project.tsconfig.file.addToArray('compilerOptions.lib', 'dom', 'dom.iterable', 'esnext');
would result in the following object file
"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["es2019", "dom", "dom.iterable", "esnext"]
...
}
...
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.
patch
public patch(patches: JsonPatch): void
Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information.
For example, with the following object file
"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["es2019"]
...
}
...
project.tsconfig.file.patch(JsonPatch.add("/compilerOptions/exclude/-", "coverage"));
project.tsconfig.file.patch(JsonPatch.replace("/compilerOptions/lib", ["dom", "dom.iterable", "esnext"]));
would result in the following object file
"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["dom", "dom.iterable", "esnext"]
...
}
...
patches
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { TomlFile } from 'projen'
TomlFile.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 | Indicates if empty objects and arrays are omitted from the output object. |
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.
omitEmpty
Required
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(project: Project, options: VersionOptions)
Name | Type | Description |
---|---|---|
|
| No description. |
|
| No description. |
project
Required
- Type: Project
options
Required
- 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. |
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 { 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.
x
Required
- Type: any
Any object.
isComponent
import { Version } from 'projen'
Version.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. |
|
| 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 ). |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: Project
bumpTask
Required
public readonly bumpTask: Task;
- Type: Task
changelogFileName
Required
public readonly changelogFileName: string;
- Type: string
The name of the changelog file (under artifactsDirectory
).
releaseTagFileName
Required
public readonly releaseTagFileName: string;
- Type: string
The name of the file that contains the release tag (under artifactsDirectory
).
unbumpTask
Required
public readonly unbumpTask: Task;
- Type: Task
versionFileName
Required
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_VERSION
Required
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. |
project
Required
- Type: Project
filePath
Required
- Type: string
options
Optional
- 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)
.
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": ["es2019"]
...
}
...
project.tsconfig.file.addToArray('compilerOptions.exclude', 'coverage');
project.tsconfig.file.addToArray('compilerOptions.lib', 'dom', 'dom.iterable', 'esnext');
would result in the following object file
"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["es2019", "dom", "dom.iterable", "esnext"]
...
}
...
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.
patch
public patch(patches: JsonPatch): void
Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information.
For example, with the following object file
"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["es2019"]
...
}
...
project.tsconfig.file.patch(JsonPatch.add("/compilerOptions/exclude/-", "coverage"));
project.tsconfig.file.patch(JsonPatch.replace("/compilerOptions/lib", ["dom", "dom.iterable", "esnext"]));
would result in the following object file
"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["dom", "dom.iterable", "esnext"]
...
}
...
patches
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { XmlFile } from 'projen'
XmlFile.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 | Indicates if empty objects and arrays are omitted from the output object. |
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.
omitEmpty
Required
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. |
scope
Required
- Type: constructs.IConstruct
filePath
Required
- Type: string
options
Required
- 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)
.
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": ["es2019"]
...
}
...
project.tsconfig.file.addToArray('compilerOptions.exclude', 'coverage');
project.tsconfig.file.addToArray('compilerOptions.lib', 'dom', 'dom.iterable', 'esnext');
would result in the following object file
"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["es2019", "dom", "dom.iterable", "esnext"]
...
}
...
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.
patch
public patch(patches: JsonPatch): void
Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information.
For example, with the following object file
"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["es2019"]
...
}
...
project.tsconfig.file.patch(JsonPatch.add("/compilerOptions/exclude/-", "coverage"));
project.tsconfig.file.patch(JsonPatch.replace("/compilerOptions/lib", ["dom", "dom.iterable", "esnext"]));
would result in the following object file
"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["dom", "dom.iterable", "esnext"]
...
}
...
patches
Required
- 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.
x
Required
- Type: any
Any object.
isComponent
import { YamlFile } from 'projen'
YamlFile.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 | Indicates if empty objects and arrays are omitted from the output object. |
| number | Maximum line width (set to 0 to disable folding). |
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.
omitEmpty
Required
public readonly omitEmpty: boolean;
- Type: boolean
Indicates if empty objects and arrays are omitted from the output object.
lineWidth
Required
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. |
dir
Required
public readonly dir: string;
- Type: string
Directory that the project will be generated in.
projectFqn
Required
public readonly projectFqn: string;
- Type: string
Fully-qualified name of the project type (usually formatted as projen.module.ProjectType
).
Example
`projen.typescript.TypescriptProject`
projectOptions
Required
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.
optionHints
Optional
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.
post
Optional
public readonly post: boolean;
- Type: boolean
- Default: true
Should we execute post synthesis hooks?
(usually package manager install).
synth
Optional
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). |
name
Required
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.
version
Optional
public readonly version: string;
- Type: string
- Default: requirement is managed by the package manager (e.g. npm/yarn).
Semantic version version requirement.
type
Required
public readonly type: DependencyType;
- Type: DependencyType
Which type of dependency this is (runtime, build-time, etc).
metadata
Optional
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. |
name
Required
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.
version
Optional
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. |
dependencies
Required
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. |
dockerImage
Optional
public readonly dockerImage: DevEnvironmentDockerImage;
A Docker image or Dockerfile for the container.
ports
Optional
public readonly ports: string[];
- Type: string[]
An array of ports that should be exposed from the container.
tasks
Optional
public readonly tasks: Task[];
- Type: Task[]
An array of tasks that should be run when the container starts.
vscodeExtensions
Optional
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. |
context
Required
public readonly context: string;
- Type: string
Docker build context directory.
args
Optional
public readonly args: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- Default: none are provided
Build args.
dockerfile
Optional
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. |
attachable
Optional
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.
bridge
Optional
public readonly bridge: boolean;
- Type: boolean
- Default: unset
Set to true to indicate that the network is a bridge network.
driver
Optional
public readonly driver: string;
- Type: string
- Default: value is not provided
Driver to use for the network.
driverOpts
Optional
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
external
Optional
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.
internal
Optional
public readonly internal: boolean;
- Type: boolean
- Default: unset
Set to true to indicate that you want to create an externally isolated overlay network.
ipam
Optional
public readonly ipam: DockerComposeNetworkIpamConfig;
- Type: DockerComposeNetworkIpamConfig
- Default: unset
Specify custom IPAM config.
labels
Optional
public readonly labels: string[];
- Type: string[]
- Default: unset
Attach labels to the network.
name
Optional
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.
overlay
Optional
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. |
config
Optional
public readonly config: DockerComposeNetworkIpamSubnetConfig[];
- Type: DockerComposeNetworkIpamSubnetConfig[]
- Default: value is not provided
A list with zero or more config blocks specifying custom IPAM configuration.
driver
Optional
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. |
subnet
Optional
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. |
protocol
Optional
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. |
nameSuffix
Optional
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'
schemaVersion
Optional
public readonly schemaVersion: string;
- Type: string
- Default: 3.3
Docker Compose schema version do be used.
services
Optional
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. |
|
| Mount some volumes into the service. |
command
Optional
public readonly command: string[];
- Type: string[]
- Default: use the container's default command
Provide a command to the docker container.
dependsOn
Optional
public readonly dependsOn: IDockerComposeServiceName[];
- Type: IDockerComposeServiceName[]
- Default: no dependencies
Names of other services this service depends on.
entrypoint
Optional
public readonly entrypoint: string[];
- Type: string[]
Entrypoint to run in the container.
environment
Optional
public readonly environment: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- Default: no environment variables are provided
Add environment variables.
image
Optional
public readonly image: string;
- Type: string
Use a docker image.
Note: You must specify either build
or image
key.
imageBuild
Optional
public readonly imageBuild: DockerComposeBuild;
- Type: DockerComposeBuild
Build a docker image.
Note: You must specify either imageBuild
or image
key.
labels
Optional
public readonly labels: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- Default: no labels are provided
Add labels.
networks
Optional
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)
platform
Optional
public readonly platform: string;
- Type: string
- Default: no platform is provided
Add platform.
ports
Optional
public readonly ports: DockerComposeServicePort[];
- Type: DockerComposeServicePort[]
- Default: no ports are mapped
Map some ports.
volumes
Optional
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 = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | Port mapping mode. |
|
| Network protocol. |
| number | Published port number. |
| number | Target port number. |
mode
Required
public readonly mode: string;
- Type: string
Port mapping mode.
protocol
Required
public readonly protocol: DockerComposeProtocol;
- Type: DockerComposeProtocol
Network protocol.
published
Required
public readonly published: number;
- Type: number
Published port number.
target
Required
public readonly target: number;
- Type: number
Target port number.
DockerComposeVolumeConfig
Volume configuration.
Initializer
import { DockerComposeVolumeConfig } from 'projen'
const dockerComposeVolumeConfig: DockerComposeVolumeConfig = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | Driver to use for the volume. |
| {[ key: string ]: string} | Options to provide to the driver. |
| boolean | Set to true to indicate that the volume is externally created. |
| string | Name of the volume for when the volume name isn't going to work in YAML. |
driver
Optional
public readonly driver: string;
- Type: string
- Default: value is not provided
Driver to use for the volume.
driverOpts
Optional
public readonly driverOpts: {[ key: string ]: string};
- Type: {[ key: string ]: string}
Options to provide to the driver.
external
Optional
public readonly external: boolean;
- Type: boolean
- Default: unset, indicating that docker-compose creates the volume
Set to true to indicate that the volume is externally created.
name
Optional
public readonly name: string;
- Type: string
- Default: unset, indicating that docker-compose creates volumes as usual
Name of the volume for when the volume name isn't going to work in YAML.
DockerComposeVolumeMount
Service volume mounting information.
Initializer
import { DockerComposeVolumeMount } from 'projen'
const dockerComposeVolumeMount: DockerComposeVolumeMount = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | Volume source. |
| string | Volume target. |
| string | Type of volume. |
source
Required
public readonly source: string;
- Type: string
Volume source.
target
Required
public readonly target: string;
- Type: string
Volume target.
type
Required
public readonly type: string;
- Type: string
Type of volume.
FileBaseOptions
Initializer
import { FileBaseOptions } from 'projen'
const fileBaseOptions: FileBaseOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | Indicates whether this file should be committed to git or ignored. |
| boolean | Update the project's .gitignore file. |
| boolean | Whether the generated file should be marked as executable. |
| boolean | Adds the projen marker to the file. |
| boolean | Whether the generated file should be readonly. |
committed
Optional
public readonly committed: boolean;
- Type: boolean
- Default: true
Indicates whether this file should be committed to git or ignored.
By default, all generated files are committed and anti-tamper is used to protect against manual modifications.
editGitignore
Optional
public readonly editGitignore: boolean;
- Type: boolean
- Default: true
Update the project's .gitignore file.
executable
Optional
public readonly executable: boolean;
- Type: boolean
- Default: false
Whether the generated file should be marked as executable.
marker
Optional
public readonly marker: boolean;
- Type: boolean
- Default: marker will be included as long as the project is not ejected
Adds the projen marker to the file.
readonly
Optional
public readonly readonly: boolean;
- Type: boolean
- Default: true
Whether the generated file should be readonly.
GitOptions
Git configuration options.
Initializer
import { GitOptions } from 'projen'
const gitOptions: GitOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string[] | File patterns to mark as stored in Git LFS. |
lfsPatterns
Optional
public readonly lfsPatterns: string[];
- Type: string[]
- Default: No files stored in LFS
File patterns to mark as stored in Git LFS.
GitpodOptions
Constructor options for the Gitpod component.
By default, Gitpod uses the 'gitpod/workspace-full' docker image.
[https://github.com/gitpod-io/workspace-images/blob/master/full/Dockerfile
By default, all tasks will be run in parallel. To run the tasks in sequence, create a new task and specify the other tasks as subtasks.](https://github.com/gitpod-io/workspace-images/blob/master/full/Dockerfile
By default, all tasks will be run in parallel. To run the tasks in sequence, create a new task and specify the other tasks as subtasks.)
Initializer
import { GitpodOptions } from 'projen'
const gitpodOptions: GitpodOptions = { ... }
Properties
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. |
|
| Optional Gitpod's Github App integration for prebuilds If this is not set and Gitpod's Github App is installed, then Gitpod will apply these defaults: https://www.gitpod.io/docs/prebuilds/#configure-the-github-app. |
dockerImage
Optional
public readonly dockerImage: DevEnvironmentDockerImage;
A Docker image or Dockerfile for the container.
ports
Optional
public readonly ports: string[];
- Type: string[]
An array of ports that should be exposed from the container.
tasks
Optional
public readonly tasks: Task[];
- Type: Task[]
An array of tasks that should be run when the container starts.
vscodeExtensions
Optional
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.
prebuilds
Optional
public readonly prebuilds: GitpodPrebuilds;
- Type: GitpodPrebuilds
- Default: undefined
Optional Gitpod's Github App integration for prebuilds If this is not set and Gitpod's Github App is installed, then Gitpod will apply these defaults: https://www.gitpod.io/docs/prebuilds/#configure-the-github-app.
GitpodPort
Options for an exposed port on Gitpod.
Initializer
import { GitpodPort } from 'projen'
const gitpodPort: GitpodPort = { ... }
Properties
Name | Type | Description |
---|---|---|
|
| What to do when a service on a port is detected. |
| string | A port that should be exposed (forwarded) from the container. |
|
| Whether the port visibility should be private or public. |
onOpen
Optional
public readonly onOpen: GitpodOnOpen;
- Type: GitpodOnOpen
- Default: GitpodOnOpen.NOTIFY
What to do when a service on a port is detected.
port
Optional
public readonly port: string;
- Type: string
A port that should be exposed (forwarded) from the container.
Example
"8080"
visibility
Optional
public readonly visibility: GitpodPortVisibility;
- Type: GitpodPortVisibility
- Default: GitpodPortVisibility.PUBLIC
Whether the port visibility should be private or public.
GitpodPrebuilds
Configure the Gitpod App for prebuilds.
Currently only GitHub is supported.
Initializer
import { GitpodPrebuilds } from 'projen'
const gitpodPrebuilds: GitpodPrebuilds = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | Add a "Review in Gitpod" button to the pull request's description. |
| boolean | Add a check to pull requests. |
| boolean | Add a "Review in Gitpod" button as a comment to pull requests. |
| boolean | Add a label once the prebuild is ready to pull requests. |
| boolean | Enable for all branches in this repo. |
| boolean | Enable for the master/default branch. |
| boolean | Enable for pull requests coming from this repo. |
| boolean | Enable for pull requests coming from forks. |
addBadge
Optional
public readonly addBadge: boolean;
- Type: boolean
- Default: false
Add a "Review in Gitpod" button to the pull request's description.
addCheck
Optional
public readonly addCheck: boolean;
- Type: boolean
- Default: true
Add a check to pull requests.
addComment
Optional
public readonly addComment: boolean;
- Type: boolean
- Default: false
Add a "Review in Gitpod" button as a comment to pull requests.
addLabel
Optional
public readonly addLabel: boolean;
- Type: boolean
- Default: false
Add a label once the prebuild is ready to pull requests.
branches
Optional
public readonly branches: boolean;
- Type: boolean
- Default: false
Enable for all branches in this repo.
master
Optional
public readonly master: boolean;
- Type: boolean
- Default: true
Enable for the master/default branch.
pullRequests
Optional
public readonly pullRequests: boolean;
- Type: boolean
- Default: true
Enable for pull requests coming from this repo.
pullRequestsFromForks
Optional
public readonly pullRequestsFromForks: boolean;
- Type: boolean
- Default: false
Enable for pull requests coming from forks.
GitpodTask
Configure options for a task to be run when opening a Gitpod workspace (e.g. running tests, or starting a dev server).
Start Mode | Execution Fresh Workspace | before && init && command Restart Workspace | before && command Snapshot | before && command Prebuild | before && init && prebuild
Initializer
import { GitpodTask } from 'projen'
const gitpodTask: GitpodTask = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | Required. |
| string | In case you need to run something even before init, that is a requirement for both init and command, you can use the before property. |
| string | The init property can be used to specify shell commands that should only be executed after a workspace was freshly cloned and needs to be initialized somehow. |
| string | A name for this task. |
|
| You can configure where in the IDE the terminal should be opened. |
|
| You can configure how the terminal should be opened relative to the previous task. |
| string | The optional prebuild command will be executed during prebuilds. |
command
Required
public readonly command: string;
- Type: string
Required.
The shell command to run
before
Optional
public readonly before: string;
- Type: string
In case you need to run something even before init, that is a requirement for both init and command, you can use the before property.
init
Optional
public readonly init: string;
- Type: string
The init property can be used to specify shell commands that should only be executed after a workspace was freshly cloned and needs to be initialized somehow.
Such tasks are usually builds or downloading dependencies. Anything you only want to do once but not when you restart a workspace or start a snapshot.
name
Optional
public readonly name: string;
- Type: string
- Default: task names are omitted when blank
A name for this task.
openIn
Optional
public readonly openIn: GitpodOpenIn;
- Type: GitpodOpenIn
- Default: GitpodOpenIn.BOTTOM
You can configure where in the IDE the terminal should be opened.
openMode
Optional
public readonly openMode: GitpodOpenMode;
- Type: GitpodOpenMode
- Default: GitpodOpenMode.TAB_AFTER
You can configure how the terminal should be opened relative to the previous task.
prebuild
Optional
public readonly prebuild: string;
- Type: string
The optional prebuild command will be executed during prebuilds.
It is meant to run additional long running processes that could be useful, e.g. running test suites.
GroupRunnerOptions
Initializer
import { GroupRunnerOptions } from 'projen'
const groupRunnerOptions: GroupRunnerOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | No description. |
| string[] | No description. |
group
Required
public readonly group: string;
- Type: string
labels
Optional
public readonly labels: string[];
- Type: string[]
IgnoreFileOptions
Initializer
import { IgnoreFileOptions } from 'projen'
const ignoreFileOptions: IgnoreFileOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | Filter out comment lines? |
| boolean | Filter out blank/empty lines? |
| string[] | Patterns to add to the ignore file. |
filterCommentLines
Optional
public readonly filterCommentLines: boolean;
- Type: boolean
- Default: true
Filter out comment lines?
filterEmptyLines
Optional
public readonly filterEmptyLines: boolean;
- Type: boolean
- Default: true
Filter out blank/empty lines?
ignorePatterns
Optional
public readonly ignorePatterns: string[];
- Type: string[]
- Default: []
Patterns to add to the ignore file.
IniFileOptions
Options for IniFile
.
Initializer
import { IniFileOptions } from 'projen'
const iniFileOptions: IniFileOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | Indicates whether this file should be committed to git or ignored. |
| boolean | Update the project's .gitignore file. |
| boolean | Whether the generated file should be marked as executable. |
| boolean | Adds the projen marker to the file. |
| boolean | Whether the generated file should be readonly. |
| any | The object that will be serialized. You can modify the object's contents before synthesis. |
| boolean | Omits empty objects and arrays. |
committed
Optional
public readonly committed: boolean;
- Type: boolean
- Default: true
Indicates whether this file should be committed to git or ignored.
By default, all generated files are committed and anti-tamper is used to protect against manual modifications.
editGitignore
Optional
public readonly editGitignore: boolean;
- Type: boolean
- Default: true
Update the project's .gitignore file.
executable
Optional
public readonly executable: boolean;
- Type: boolean
- Default: false
Whether the generated file should be marked as executable.
marker
Optional
public readonly marker: boolean;
- Type: boolean
- Default: marker will be included as long as the project is not ejected
Adds the projen marker to the file.
readonly
Optional
public readonly readonly: boolean;
- Type: boolean
- Default: true
Whether the generated file should be readonly.
obj
Optional
public readonly obj: any;
- Type: any
- Default: {} an empty object (use
file.obj
to mutate).
The object that will be serialized. You can modify the object's contents before synthesis.
Serialization of the object is similar to JSON.stringify with few enhancements:
- values that are functions will be called during synthesis and the result will be serialized - this allow to have lazy values.
Set
will be converted to arrayMap
will be converted to a plain object ({ key: value, ... }})RegExp
without flags will be converted to string representation of the source
omitEmpty
Optional
public readonly omitEmpty: boolean;
- Type: boolean
- Default: false
Omits empty objects and arrays.
InitProject
Information passed from projen new
to the project object when the project is first created.
It is used to generate projenrc files in various languages.
Initializer
import { InitProject } from 'projen'
const initProject: InitProject = { ... }
Properties
Name | Type | Description |
---|---|---|
| {[ key: string ]: any} | Initial arguments passed to projen new . |
|
| Include commented out options. |
| string | The JSII FQN of the project type. |
|
| Project metadata. |
args
Required
public readonly args: {[ key: string ]: any};
- Type: {[ key: string ]: any}
Initial arguments passed to projen new
.
comments
Required
public readonly comments: InitProjectOptionHints;
- Type: InitProjectOptionHints
- Default: InitProjectOptionHints.FEATURED
Include commented out options.
Does not apply to projenrc.json files.
fqn
Required
public readonly fqn: string;
- Type: string
The JSII FQN of the project type.
type
Required
public readonly type: ProjectType;
- Type: ProjectType
Project metadata.
JsonFileOptions
Options for JsonFile
.
Initializer
import { JsonFileOptions } from 'projen'
const jsonFileOptions: JsonFileOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | Indicates whether this file should be committed to git or ignored. |
| boolean | Update the project's .gitignore file. |
| boolean | Whether the generated file should be marked as executable. |
| boolean | Adds the projen marker to the file. |
| boolean | Whether the generated file should be readonly. |
| any | The object that will be serialized. You can modify the object's contents before synthesis. |
| boolean | Omits empty objects and arrays. |
| boolean | Allow the use of comments in this file. |
| boolean | Adds a newline at the end of the file. |
committed
Optional
public readonly committed: boolean;
- Type: boolean
- Default: true
Indicates whether this file should be committed to git or ignored.
By default, all generated files are committed and anti-tamper is used to protect against manual modifications.
editGitignore
Optional
public readonly editGitignore: boolean;
- Type: boolean
- Default: true
Update the project's .gitignore file.
executable
Optional
public readonly executable: boolean;
- Type: boolean
- Default: false
Whether the generated file should be marked as executable.
marker
Optional
public readonly marker: boolean;
- Type: boolean
- Default: marker will be included as long as the project is not ejected
Adds the projen marker to the file.
readonly
Optional
public readonly readonly: boolean;
- Type: boolean
- Default: true
Whether the generated file should be readonly.
obj
Optional
public readonly obj: any;
- Type: any
- Default: {} an empty object (use
file.obj
to mutate).
The object that will be serialized. You can modify the object's contents before synthesis.
Serialization of the object is similar to JSON.stringify with few enhancements:
- values that are functions will be called during synthesis and the result will be serialized - this allow to have lazy values.
Set
will be converted to arrayMap
will be converted to a plain object ({ key: value, ... }})RegExp
without flags will be converted to string representation of the source
omitEmpty
Optional
public readonly omitEmpty: boolean;
- Type: boolean
- Default: false
Omits empty objects and arrays.
allowComments
Optional
public readonly allowComments: boolean;
- Type: boolean
- Default: false for .json files, true for .json5 and .jsonc files
Allow the use of comments in this file.
newline
Optional
public readonly newline: boolean;
- Type: boolean
- Default: true
Adds a newline at the end of the file.
LicenseOptions
Initializer
import { LicenseOptions } from 'projen'
const licenseOptions: LicenseOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | License type (SPDX). |
| string | Copyright owner. |
| string | Period of license (e.g. "1998-2023"). |
spdx
Required
public readonly spdx: string;
- Type: string
License type (SPDX).
[https://github.com/projen/projen/tree/main/license-text for list of supported licenses](https://github.com/projen/projen/tree/main/license-text for list of supported licenses)
copyrightOwner
Optional
public readonly copyrightOwner: string;
- Type: string
- Default:
Copyright owner.
If the license text has $copyright_owner, this option must be specified.
copyrightPeriod
Optional
public readonly copyrightPeriod: string;
- Type: string
- Default: current year (e.g. "2020")
Period of license (e.g. "1998-2023").
The string $copyright_period
will be substituted with this string.
LoggerOptions
Options for logging utilities.
Initializer
import { LoggerOptions } from 'projen'
const loggerOptions: LoggerOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
|
| The logging verbosity. |
| boolean | Include a prefix for all logging messages with the project name. |
level
Optional
public readonly level: LogLevel;
- Type: LogLevel
- Default: LogLevel.INFO
The logging verbosity.
The levels available (in increasing verbosity) are OFF, ERROR, WARN, INFO, DEBUG, and VERBOSE.
usePrefix
Optional
public readonly usePrefix: boolean;
- Type: boolean
- Default: false
Include a prefix for all logging messages with the project name.
MakefileOptions
Options for Makefiles.
Initializer
import { MakefileOptions } from 'projen'
const makefileOptions: MakefileOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | Indicates whether this file should be committed to git or ignored. |
| boolean | Update the project's .gitignore file. |
| boolean | Whether the generated file should be marked as executable. |
| boolean | Adds the projen marker to the file. |
| boolean | Whether the generated file should be readonly. |
| string[] | List of targets to build when Make is invoked without specifying any targets. |
|
| Rules to include in the Makefile. |
committed
Optional
public readonly committed: boolean;
- Type: boolean
- Default: true
Indicates whether this file should be committed to git or ignored.
By default, all generated files are committed and anti-tamper is used to protect against manual modifications.
editGitignore
Optional
public readonly editGitignore: boolean;
- Type: boolean
- Default: true
Update the project's .gitignore file.
executable
Optional
public readonly executable: boolean;
- Type: boolean
- Default: false
Whether the generated file should be marked as executable.
marker
Optional
public readonly marker: boolean;
- Type: boolean
- Default: marker will be included as long as the project is not ejected
Adds the projen marker to the file.
readonly
Optional
public readonly readonly: boolean;
- Type: boolean
- Default: true
Whether the generated file should be readonly.
all
Optional
public readonly all: string[];
- Type: string[]
- Default: []
List of targets to build when Make is invoked without specifying any targets.
rules
Optional
public readonly rules: Rule[];
- Type: Rule[]
- Default: []
Rules to include in the Makefile.
ObjectFileOptions
Options for ObjectFile
.
Initializer
import { ObjectFileOptions } from 'projen'
const objectFileOptions: ObjectFileOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | Indicates whether this file should be committed to git or ignored. |
| boolean | Update the project's .gitignore file. |
| boolean | Whether the generated file should be marked as executable. |
| boolean | Adds the projen marker to the file. |
| boolean | Whether the generated file should be readonly. |
| any | The object that will be serialized. You can modify the object's contents before synthesis. |
| boolean | Omits empty objects and arrays. |
committed
Optional
public readonly committed: boolean;
- Type: boolean
- Default: true
Indicates whether this file should be committed to git or ignored.
By default, all generated files are committed and anti-tamper is used to protect against manual modifications.
editGitignore
Optional
public readonly editGitignore: boolean;
- Type: boolean
- Default: true
Update the project's .gitignore file.
executable
Optional
public readonly executable: boolean;
- Type: boolean
- Default: false
Whether the generated file should be marked as executable.
marker
Optional
public readonly marker: boolean;
- Type: boolean
- Default: marker will be included as long as the project is not ejected
Adds the projen marker to the file.
readonly
Optional
public readonly readonly: boolean;
- Type: boolean
- Default: true
Whether the generated file should be readonly.
obj
Optional
public readonly obj: any;
- Type: any
- Default: {} an empty object (use
file.obj
to mutate).
The object that will be serialized. You can modify the object's contents before synthesis.
Serialization of the object is similar to JSON.stringify with few enhancements:
- values that are functions will be called during synthesis and the result will be serialized - this allow to have lazy values.
Set
will be converted to arrayMap
will be converted to a plain object ({ key: value, ... }})RegExp
without flags will be converted to string representation of the source
omitEmpty
Optional
public readonly omitEmpty: boolean;
- Type: boolean
- Default: false
Omits empty objects and arrays.
ProjectOptions
Options for Project
.
Initializer
import { ProjectOptions } from 'projen'
const projectOptions: ProjectOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | This is the name of your project. |
| boolean | Whether to commit the managed files by default. |
|
| Configuration options for .gitignore file. |
|
| Configuration options for git. |
|
| Configure logging options such as verbosity. |
| string | The root directory of the project. |
|
| The parent project, if this project is part of a bigger project. |
| string | The shell command to use in order to run the projen CLI. |
| boolean | Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation. |
|
| Options for .projenrc.json. |
| boolean | Use renovatebot to handle dependency upgrades. |
|
| Options for renovatebot. |
name
Required
public readonly name: string;
- Type: string
- Default: $BASEDIR
This is the name of your project.
commitGenerated
Optional
public readonly commitGenerated: boolean;
- Type: boolean
- Default: true
Whether to commit the managed files by default.
gitIgnoreOptions
Optional
public readonly gitIgnoreOptions: IgnoreFileOptions;
- Type: IgnoreFileOptions
Configuration options for .gitignore file.
gitOptions
Optional
public readonly gitOptions: GitOptions;
- Type: GitOptions
Configuration options for git.
logging
Optional
public readonly logging: LoggerOptions;
- Type: LoggerOptions
- Default: {}
Configure logging options such as verbosity.
outdir
Optional
public readonly outdir: string;
- Type: string
- Default: "."
The root directory of the project.
Relative to this directory, all files are synthesized.
If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.
parent
Optional
public readonly parent: Project;
- Type: Project
The parent project, if this project is part of a bigger project.
projenCommand
Optional
public readonly projenCommand: string;
- Type: string
- Default: "npx projen"
The shell command to use in order to run the projen CLI.
Can be used to customize in special environments.
projenrcJson
Optional
public readonly projenrcJson: boolean;
- Type: boolean
- Default: false
Generate (once) .projenrc.json (in JSON). Set to false
in order to disable .projenrc.json generation.
projenrcJsonOptions
Optional
public readonly projenrcJsonOptions: ProjenrcJsonOptions;
- Type: ProjenrcJsonOptions
- Default: default options
Options for .projenrc.json.
renovatebot
Optional
public readonly renovatebot: boolean;
- Type: boolean
- Default: false
Use renovatebot to handle dependency upgrades.
renovatebotOptions
Optional
public readonly renovatebotOptions: RenovatebotOptions;
- Type: RenovatebotOptions
- Default: default options
Options for renovatebot.
ProjenrcJsonOptions
Initializer
import { ProjenrcJsonOptions } from 'projen'
const projenrcJsonOptions: ProjenrcJsonOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | The name of the projenrc file. |
filename
Optional
public readonly filename: string;
- Type: string
- Default: ".projenrc.json"
The name of the projenrc file.
ProjenrcOptions
Initializer
import { ProjenrcOptions } from 'projen'
const projenrcOptions: ProjenrcOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | The name of the projenrc file. |
filename
Optional
filename
- Deprecated: use
ProjenrcJsonOptions
public readonly filename: string;
- Type: string
- Default: ".projenrc.json"
The name of the projenrc file.
RenovatebotOptions
Options for Renovatebot.
Initializer
import { RenovatebotOptions } from 'projen'
const renovatebotOptions: RenovatebotOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string[] | You can use the ignore option to customize which dependencies are updated. |
| boolean | Ignores updates to projen . |
| string[] | List of labels to apply to the created PR's. |
| boolean | No description. |
| any | No description. |
| string[] | How often to check for new versions and raise pull requests. |
ignore
Optional
public readonly ignore: string[];
- Type: string[]
- Default: []
You can use the ignore
option to customize which dependencies are updated.
The ignore option supports just package name.
ignoreProjen
Optional
public readonly ignoreProjen: boolean;
- Type: boolean
- Default: true
Ignores updates to projen
.
This is required since projen updates may cause changes in committed files and anti-tamper checks will fail.
Projen upgrades are covered through the ProjenUpgrade
class.
labels
Optional
public readonly labels: string[];
- Type: string[]
List of labels to apply to the created PR's.
marker
Optional
public readonly marker: boolean;
- Type: boolean
overrideConfig
Optional
public readonly overrideConfig: any;
- Type: any
scheduleInterval
Optional
public readonly scheduleInterval: string[];
- Type: string[]
- Default: ["at any time"]
How often to check for new versions and raise pull requests.
Can be given in CRON or LATER format, and use multiple schedules (e.g. different for weekdays and weekends). Multiple rules are handles as OR.
Some normal scheduling values defined in enum RenovatebotScheduleInterval
.
https://docs.renovatebot.com/configuration-options/#schedule
ResolveOptions
Resolve options.
Initializer
import { ResolveOptions } from 'projen'
const resolveOptions: ResolveOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| any[] | Context arguments. |
| boolean | Omits empty arrays and objects. |
args
Optional
public readonly args: any[];
- Type: any[]
- Default: []
Context arguments.
omitEmpty
Optional
public readonly omitEmpty: boolean;
- Type: boolean
- Default: false
Omits empty arrays and objects.
Rule
A Make rule.
Initializer
import { Rule } from 'projen'
const rule: Rule = { ... }
Properties
Name | Type | Description |
---|---|---|
| string[] | Files to be created or updated by this rule. |
| boolean | Marks whether the target is phony. |
| string[] | Files that are used as inputs to create a target. |
| string[] | Commands that are run (using prerequisites as inputs) to create a target. |
targets
Required
public readonly targets: string[];
- Type: string[]
Files to be created or updated by this rule.
If the rule is phony then instead this represents the command's name(s).
phony
Optional
public readonly phony: boolean;
- Type: boolean
- Default: false
Marks whether the target is phony.
prerequisites
Optional
public readonly prerequisites: string[];
- Type: string[]
- Default: []
Files that are used as inputs to create a target.
recipe
Optional
public readonly recipe: string[];
- Type: string[]
- Default: []
Commands that are run (using prerequisites as inputs) to create a target.
SampleDirOptions
SampleDir options.
Initializer
import { SampleDirOptions } from 'projen'
const sampleDirOptions: SampleDirOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| {[ key: string ]: string} | The files to render into the directory. |
| string | Absolute path to a directory to copy files from (does not need to be text files). |
files
Optional
public readonly files: {[ key: string ]: string};
- Type: {[ key: string ]: string}
The files to render into the directory.
These files get added after
any files from source
if that option is specified (replacing if names
overlap).
sourceDir
Optional
public readonly sourceDir: string;
- Type: string
Absolute path to a directory to copy files from (does not need to be text files).
If your project is typescript-based and has configured testdir
to be a
subdirectory of src
, sample files should outside of the src
directory
otherwise they may not be copied. For example:
new SampleDir(this, 'public', { source: path.join(__dirname, '..', 'sample-assets') });
SampleFileOptions
Options for the SampleFile object.
Initializer
import { SampleFileOptions } from 'projen'
const sampleFileOptions: SampleFileOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | The contents of the file to write. |
| string | Absolute path to a file to copy the contents from (does not need to be a text file). |
contents
Optional
public readonly contents: string;
- Type: string
The contents of the file to write.
sourcePath
Optional
public readonly sourcePath: string;
- Type: string
Absolute path to a file to copy the contents from (does not need to be a text file).
If your project is Typescript-based and has configured testdir
to be a
subdirectory of src
, sample files should outside of the src
directory,
otherwise they may not be copied. For example:
new SampleFile(this, 'assets/icon.png', { source: path.join(__dirname, '..', 'sample-assets', 'icon.png') });
SampleReadmeProps
SampleReadme Properties.
Initializer
import { SampleReadmeProps } from 'projen'
const sampleReadmeProps: SampleReadmeProps = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | The contents. |
| string | The name of the README.md file. |
contents
Optional
public readonly contents: string;
- Type: string
- Default: "# replace this"
The contents.
filename
Optional
public readonly filename: string;
- Type: string
- Default: "README.md"
The name of the README.md file.
Example
"readme.md"
SnapshotOptions
Options for the Snapshot synthesis.
Initializer
import { SnapshotOptions } from 'projen'
const snapshotOptions: SnapshotOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | Parse .json files as a JS object for improved inspection. This will fail if the contents are invalid JSON. |
parseJson
Optional
public readonly parseJson: boolean;
- Type: boolean
- Default: true parse .json files into an object
Parse .json files as a JS object for improved inspection. This will fail if the contents are invalid JSON.
SourceCodeOptions
Options for SourceCodeFile
.
Initializer
import { SourceCodeOptions } from 'projen'
const sourceCodeOptions: SourceCodeOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| number | Indentation size. |
| boolean | Whether the generated file should be readonly. |
indent
Optional
public readonly indent: number;
- Type: number
- Default: 2
Indentation size.
readonly
Optional
public readonly readonly: boolean;
- Type: boolean
- Default: true
Whether the generated file should be readonly.
TaskCommonOptions
Initializer
import { TaskCommonOptions } from 'projen'
const taskCommonOptions: TaskCommonOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | A shell command which determines if the this task should be executed. |
| string | The working directory for all steps in this task (unless overridden by the step). |
| string | The description of this build command. |
| {[ key: string ]: string} | Defines environment variables for the execution of this task. |
| string[] | A set of environment variables that must be defined in order to execute this task. |
condition
Optional
public readonly condition: string;
- Type: string
A shell command which determines if the this task should be executed.
If the program exits with a zero exit code, steps will be executed. A non-zero code means that task will be skipped.
cwd
Optional
public readonly cwd: string;
- Type: string
- Default: process.cwd()
The working directory for all steps in this task (unless overridden by the step).
description
Optional
public readonly description: string;
- Type: string
- Default: the task name
The description of this build command.
env
Optional
public readonly env: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- Default: {}
Defines environment variables for the execution of this task.
Values in this map will be evaluated in a shell, so you can do stuff like $(echo "foo")
.
requiredEnv
Optional
public readonly requiredEnv: string[];
- Type: string[]
A set of environment variables that must be defined in order to execute this task.
Task execution will fail if one of these is not defined.
TaskOptions
Initializer
import { TaskOptions } from 'projen'
const taskOptions: TaskOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | A shell command which determines if the this task should be executed. |
| string | The working directory for all steps in this task (unless overridden by the step). |
| string | The description of this build command. |
| {[ key: string ]: string} | Defines environment variables for the execution of this task. |
| string[] | A set of environment variables that must be defined in order to execute this task. |
| string[] | Should the provided exec shell command receive fixed args. |
| string | Shell command to execute as the first command of the task. |
| boolean | Should the provided exec shell command receive args passed to the task. |
|
| List of task steps to run. |
condition
Optional
public readonly condition: string;
- Type: string
A shell command which determines if the this task should be executed.
If the program exits with a zero exit code, steps will be executed. A non-zero code means that task will be skipped.
cwd
Optional
public readonly cwd: string;
- Type: string
- Default: process.cwd()
The working directory for all steps in this task (unless overridden by the step).
description
Optional
public readonly description: string;
- Type: string
- Default: the task name
The description of this build command.
env
Optional
public readonly env: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- Default: {}
Defines environment variables for the execution of this task.
Values in this map will be evaluated in a shell, so you can do stuff like $(echo "foo")
.
requiredEnv
Optional
public readonly requiredEnv: string[];
- Type: string[]
A set of environment variables that must be defined in order to execute this task.
Task execution will fail if one of these is not defined.
args
Optional
public readonly args: string[];
- Type: string[]
- Default: no arguments are passed to the step
Should the provided exec
shell command receive fixed args.
[{@link TaskStepOptions.args }]({@link TaskStepOptions.args })
exec
Optional
public readonly exec: string;
- Type: string
- Default: add steps using
task.exec(command)
ortask.spawn(subtask)
Shell command to execute as the first command of the task.
receiveArgs
Optional
public readonly receiveArgs: boolean;
- Type: boolean
- Default: false
Should the provided exec
shell command receive args passed to the task.
[{@link TaskStepOptions.receiveArgs }]({@link TaskStepOptions.receiveArgs })
steps
Optional
public readonly steps: TaskStep[];
- Type: TaskStep[]
List of task steps to run.
TasksManifest
Schema for tasks.json
.
Initializer
import { TasksManifest } from 'projen'
const tasksManifest: TasksManifest = { ... }
Properties
Name | Type | Description |
---|---|---|
| {[ key: string ]: string} | Environment for all tasks. |
|
| All tasks available for this project. |
env
Optional
public readonly env: {[ key: string ]: string};
- Type: {[ key: string ]: string}
Environment for all tasks.
tasks
Optional
public readonly tasks: {[ key: string ]: TaskSpec};
- Type: {[ key: string ]: TaskSpec}
All tasks available for this project.
TaskSpec
Specification of a single task.
Initializer
import { TaskSpec } from 'projen'
const taskSpec: TaskSpec = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | A shell command which determines if the this task should be executed. |
| string | The working directory for all steps in this task (unless overridden by the step). |
| string | The description of this build command. |
| {[ key: string ]: string} | Defines environment variables for the execution of this task. |
| string[] | A set of environment variables that must be defined in order to execute this task. |
| string | Task name. |
|
| Task steps. |
condition
Optional
public readonly condition: string;
- Type: string
A shell command which determines if the this task should be executed.
If the program exits with a zero exit code, steps will be executed. A non-zero code means that task will be skipped.
cwd
Optional
public readonly cwd: string;
- Type: string
- Default: process.cwd()
The working directory for all steps in this task (unless overridden by the step).
description
Optional
public readonly description: string;
- Type: string
- Default: the task name
The description of this build command.
env
Optional
public readonly env: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- Default: {}
Defines environment variables for the execution of this task.
Values in this map will be evaluated in a shell, so you can do stuff like $(echo "foo")
.
requiredEnv
Optional
public readonly requiredEnv: string[];
- Type: string[]
A set of environment variables that must be defined in order to execute this task.
Task execution will fail if one of these is not defined.
name
Required
public readonly name: string;
- Type: string
Task name.
steps
Optional
public readonly steps: TaskStep[];
- Type: TaskStep[]
Task steps.
TaskStep
A single step within a task.
The step could either be the execution of a shell command or execution of a sub-task, by name.
Initializer
import { TaskStep } from 'projen'
const taskStep: TaskStep = { ... }
Properties
Name | Type | Description |
---|---|---|
| string[] | A list of fixed arguments always passed to the step. |
| string | A shell command which determines if the this step should be executed. |
| string | The working directory for this step. |
| {[ key: string ]: string} | Defines environment variables for the execution of this step (exec and builtin only). |
| string | Step name. |
| boolean | Should this step receive args passed to the task. |
| string | The name of a built-in task to execute. |
| string | Shell command to execute. |
| string | Print a message. |
| string | Subtask to execute. |
args
Optional
public readonly args: string[];
- Type: string[]
- Default: no arguments are passed to the step
A list of fixed arguments always passed to the step.
Useful to re-use existing tasks without having to re-define the whole task.
Fixed args are always passed to the step, even if receiveArgs
is false
and are always passed before any args the task is called with.
If the step executes a shell commands, args are passed through at the end of the exec
shell command.
The position of the args can be changed by including the marker $@
inside the command string.
If the step spawns a subtask, args are passed to the subtask. The subtask must define steps receiving args for this to have any effect.
If the step calls a builtin script, args are passed to the script. It is up to the script to use or discard the arguments.
Example
task.spawn("deploy", { args: ["--force"] });
condition
Optional
public readonly condition: string;
- Type: string
A shell command which determines if the this step should be executed.
If the program exits with a zero exit code, the step will be executed. A non-zero code means the step will be skipped (subsequent task steps will still be evaluated/executed).
cwd
Optional
public readonly cwd: string;
- Type: string
- Default: determined by the task
The working directory for this step.
env
Optional
public readonly env: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- Default: no environment variables defined in step
Defines environment variables for the execution of this step (exec
and builtin
only).
Values in this map can be simple, literal values or shell expressions that will be evaluated at runtime e.g. $(echo "foo")
.
Example
{ "foo": "bar", "boo": "$(echo baz)" }
name
Optional
public readonly name: string;
- Type: string
- Default: no name
Step name.
receiveArgs
Optional
public readonly receiveArgs: boolean;
- Type: boolean
- Default: false
Should this step receive args passed to the task.
If true
, args are passed through at the end of the exec
shell command.
The position of the args can be changed by including the marker $@
inside the command string.
If the step spawns a subtask, args are passed to the subtask. The subtask must define steps receiving args for this to have any effect.
Example
task.exec("echo Hello $@ World!", { receiveArgs: true });
builtin
Optional
public readonly builtin: string;
- Type: string
- Default: do not execute a builtin task
The name of a built-in task to execute.
Built-in tasks are node.js programs baked into the projen module and as component runtime helpers.
The name is a path relative to the projen lib/ directory (without the .task.js extension).
For example, if your built in builtin task is under src/release/resolve-version.task.ts
,
then this would be release/resolve-version
.
exec
Optional
public readonly exec: string;
- Type: string
- Default: don't execute a shell command
Shell command to execute.
say
Optional
public readonly say: string;
- Type: string
- Default: don't say anything
Print a message.
spawn
Optional
public readonly spawn: string;
- Type: string
- Default: don't spawn a subtask
Subtask to execute.
TaskStepOptions
Options for task steps.
Initializer
import { TaskStepOptions } from 'projen'
const taskStepOptions: TaskStepOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string[] | A list of fixed arguments always passed to the step. |
| string | A shell command which determines if the this step should be executed. |
| string | The working directory for this step. |
| {[ key: string ]: string} | Defines environment variables for the execution of this step (exec and builtin only). |
| string | Step name. |
| boolean | Should this step receive args passed to the task. |
args
Optional
public readonly args: string[];
- Type: string[]
- Default: no arguments are passed to the step
A list of fixed arguments always passed to the step.
Useful to re-use existing tasks without having to re-define the whole task.
Fixed args are always passed to the step, even if receiveArgs
is false
and are always passed before any args the task is called with.
If the step executes a shell commands, args are passed through at the end of the exec
shell command.
The position of the args can be changed by including the marker $@
inside the command string.
If the step spawns a subtask, args are passed to the subtask. The subtask must define steps receiving args for this to have any effect.
If the step calls a builtin script, args are passed to the script. It is up to the script to use or discard the arguments.
Example
task.spawn("deploy", { args: ["--force"] });
condition
Optional
public readonly condition: string;
- Type: string
A shell command which determines if the this step should be executed.
If the program exits with a zero exit code, the step will be executed. A non-zero code means the step will be skipped (subsequent task steps will still be evaluated/executed).
cwd
Optional
public readonly cwd: string;
- Type: string
- Default: determined by the task
The working directory for this step.
env
Optional
public readonly env: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- Default: no environment variables defined in step
Defines environment variables for the execution of this step (exec
and builtin
only).
Values in this map can be simple, literal values or shell expressions that will be evaluated at runtime e.g. $(echo "foo")
.
Example
{ "foo": "bar", "boo": "$(echo baz)" }
name
Optional
public readonly name: string;
- Type: string
- Default: no name
Step name.
receiveArgs
Optional
public readonly receiveArgs: boolean;
- Type: boolean
- Default: false
Should this step receive args passed to the task.
If true
, args are passed through at the end of the exec
shell command.
The position of the args can be changed by including the marker $@
inside the command string.
If the step spawns a subtask, args are passed to the subtask. The subtask must define steps receiving args for this to have any effect.
Example
task.exec("echo Hello $@ World!", { receiveArgs: true });
TextFileOptions
Options for TextFile
.
Initializer
import { TextFileOptions } from 'projen'
const textFileOptions: TextFileOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | Indicates whether this file should be committed to git or ignored. |
| boolean | Update the project's .gitignore file. |
| boolean | Whether the generated file should be marked as executable. |
| boolean | Adds the projen marker to the file. |
| boolean | Whether the generated file should be readonly. |
| string[] | The contents of the text file. |
committed
Optional
public readonly committed: boolean;
- Type: boolean
- Default: true
Indicates whether this file should be committed to git or ignored.
By default, all generated files are committed and anti-tamper is used to protect against manual modifications.
editGitignore
Optional
public readonly editGitignore: boolean;
- Type: boolean
- Default: true
Update the project's .gitignore file.
executable
Optional
public readonly executable: boolean;
- Type: boolean
- Default: false
Whether the generated file should be marked as executable.
marker
Optional
public readonly marker: boolean;
- Type: boolean
- Default: marker will be included as long as the project is not ejected
Adds the projen marker to the file.
readonly
Optional
public readonly readonly: boolean;
- Type: boolean
- Default: true
Whether the generated file should be readonly.
lines
Optional
public readonly lines: string[];
- Type: string[]
- Default: [] empty file
The contents of the text file.
You can use addLine()
to append lines.
TomlFileOptions
Options for TomlFile
.
Initializer
import { TomlFileOptions } from 'projen'
const tomlFileOptions: TomlFileOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | Indicates whether this file should be committed to git or ignored. |
| boolean | Update the project's .gitignore file. |
| boolean | Whether the generated file should be marked as executable. |
| boolean | Adds the projen marker to the file. |
| boolean | Whether the generated file should be readonly. |
| any | The object that will be serialized. You can modify the object's contents before synthesis. |
| boolean | Omits empty objects and arrays. |
committed
Optional
public readonly committed: boolean;
- Type: boolean
- Default: true
Indicates whether this file should be committed to git or ignored.
By default, all generated files are committed and anti-tamper is used to protect against manual modifications.
editGitignore
Optional
public readonly editGitignore: boolean;
- Type: boolean
- Default: true
Update the project's .gitignore file.
executable
Optional
public readonly executable: boolean;
- Type: boolean
- Default: false
Whether the generated file should be marked as executable.
marker
Optional
public readonly marker: boolean;
- Type: boolean
- Default: marker will be included as long as the project is not ejected
Adds the projen marker to the file.
readonly
Optional
public readonly readonly: boolean;
- Type: boolean
- Default: true
Whether the generated file should be readonly.
obj
Optional
public readonly obj: any;
- Type: any
- Default: {} an empty object (use
file.obj
to mutate).
The object that will be serialized. You can modify the object's contents before synthesis.
Serialization of the object is similar to JSON.stringify with few enhancements:
- values that are functions will be called during synthesis and the result will be serialized - this allow to have lazy values.
Set
will be converted to arrayMap
will be converted to a plain object ({ key: value, ... }})RegExp
without flags will be converted to string representation of the source
omitEmpty
Optional
public readonly omitEmpty: boolean;
- Type: boolean
- Default: false
Omits empty objects and arrays.
VersionOptions
Options for Version
.
Initializer
import { VersionOptions } from 'projen'
const versionOptions: VersionOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | The name of the directory into which changelog.md and version.txt files are emitted. |
| string | A name of a .json file to set the version field in after a bump. |
|
| Find commits that should be considered releasable Used to decide if a release is required. |
| string | The tag prefix corresponding to this version. |
| {[ key: string ]: any} | Custom configuration for versionrc file used by standard-release. |
artifactsDirectory
Required
public readonly artifactsDirectory: string;
- Type: string
The name of the directory into which changelog.md
and version.txt
files are emitted.
versionInputFile
Required
public readonly versionInputFile: string;
- Type: string
A name of a .json file to set the version
field in after a bump.
Example
"package.json"
releasableCommits
Optional
public readonly releasableCommits: ReleasableCommits;
- Type: ReleasableCommits
- Default: ReleasableCommits.everyCommit()
Find commits that should be considered releasable Used to decide if a release is required.
tagPrefix
Optional
public readonly tagPrefix: string;
- Type: string
The tag prefix corresponding to this version.
versionrcOptions
Optional
public readonly versionrcOptions: {[ key: string ]: any};
- Type: {[ key: string ]: any}
Custom configuration for versionrc file used by standard-release.
XmlFileOptions
Options for XmlFile
.
Initializer
import { XmlFileOptions } from 'projen'
const xmlFileOptions: XmlFileOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | Indicates whether this file should be committed to git or ignored. |
| boolean | Update the project's .gitignore file. |
| boolean | Whether the generated file should be marked as executable. |
| boolean | Adds the projen marker to the file. |
| boolean | Whether the generated file should be readonly. |
| any | The object that will be serialized. You can modify the object's contents before synthesis. |
| boolean | Omits empty objects and arrays. |
committed
Optional
public readonly committed: boolean;
- Type: boolean
- Default: true
Indicates whether this file should be committed to git or ignored.
By default, all generated files are committed and anti-tamper is used to protect against manual modifications.
editGitignore
Optional
public readonly editGitignore: boolean;
- Type: boolean
- Default: true
Update the project's .gitignore file.
executable
Optional
public readonly executable: boolean;
- Type: boolean
- Default: false
Whether the generated file should be marked as executable.
marker
Optional
public readonly marker: boolean;
- Type: boolean
- Default: marker will be included as long as the project is not ejected
Adds the projen marker to the file.
readonly
Optional
public readonly readonly: boolean;
- Type: boolean
- Default: true
Whether the generated file should be readonly.
obj
Optional
public readonly obj: any;
- Type: any
- Default: {} an empty object (use
file.obj
to mutate).
The object that will be serialized. You can modify the object's contents before synthesis.
Serialization of the object is similar to JSON.stringify with few enhancements:
- values that are functions will be called during synthesis and the result will be serialized - this allow to have lazy values.
Set
will be converted to arrayMap
will be converted to a plain object ({ key: value, ... }})RegExp
without flags will be converted to string representation of the source
omitEmpty
Optional
public readonly omitEmpty: boolean;
- Type: boolean
- Default: false
Omits empty objects and arrays.
YamlFileOptions
Options for JsonFile
.
Initializer
import { YamlFileOptions } from 'projen'
const yamlFileOptions: YamlFileOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | Indicates whether this file should be committed to git or ignored. |
| boolean | Update the project's .gitignore file. |
| boolean | Whether the generated file should be marked as executable. |
| boolean | Adds the projen marker to the file. |
| boolean | Whether the generated file should be readonly. |
| any | The object that will be serialized. You can modify the object's contents before synthesis. |
| boolean | Omits empty objects and arrays. |
| number | Maximum line width (set to 0 to disable folding). |
committed
Optional
public readonly committed: boolean;
- Type: boolean
- Default: true
Indicates whether this file should be committed to git or ignored.
By default, all generated files are committed and anti-tamper is used to protect against manual modifications.
editGitignore
Optional
public readonly editGitignore: boolean;
- Type: boolean
- Default: true
Update the project's .gitignore file.
executable
Optional
public readonly executable: boolean;
- Type: boolean
- Default: false
Whether the generated file should be marked as executable.
marker
Optional
public readonly marker: boolean;
- Type: boolean
- Default: marker will be included as long as the project is not ejected
Adds the projen marker to the file.
readonly
Optional
public readonly readonly: boolean;
- Type: boolean
- Default: true
Whether the generated file should be readonly.
obj
Optional
public readonly obj: any;
- Type: any
- Default: {} an empty object (use
file.obj
to mutate).
The object that will be serialized. You can modify the object's contents before synthesis.
Serialization of the object is similar to JSON.stringify with few enhancements:
- values that are functions will be called during synthesis and the result will be serialized - this allow to have lazy values.
Set
will be converted to arrayMap
will be converted to a plain object ({ key: value, ... }})RegExp
without flags will be converted to string representation of the source
omitEmpty
Optional
public readonly omitEmpty: boolean;
- Type: boolean
- Default: false
Omits empty objects and arrays.
lineWidth
Optional
public readonly lineWidth: number;
- Type: number
- Default: 0
Maximum line width (set to 0 to disable folding).
Classes
DevEnvironmentDockerImage
Options for specifying the Docker image of the container.
Static Functions
Name | Description |
---|---|
| The relative path of a Dockerfile that defines the container contents. |
| A publicly available Docker image. |
fromFile
import { DevEnvironmentDockerImage } from 'projen'
DevEnvironmentDockerImage.fromFile(dockerFile: string)
The relative path of a Dockerfile that defines the container contents.
Example
'.gitpod.Docker'
dockerFile
Required
- Type: string
a relative path.
fromImage
import { DevEnvironmentDockerImage } from 'projen'
DevEnvironmentDockerImage.fromImage(image: string)
A publicly available Docker image.
Example
'ubuntu:latest'
image
Required
- Type: string
a Docker image.
Properties
Name | Type | Description |
---|---|---|
| string | The relative path of a Dockerfile that defines the container contents. |
| string | A publicly available Docker image. |
dockerFile
Optional
public readonly dockerFile: string;
- Type: string
The relative path of a Dockerfile that defines the container contents.
image
Optional
public readonly image: string;
- Type: string
A publicly available Docker image.
DockerComposeService
- Implements: IDockerComposeServiceName
A docker-compose service.
Initializers
import { DockerComposeService } from 'projen'
new DockerComposeService(serviceName: string, serviceDescription: DockerComposeServiceDescription)
Name | Type | Description |
---|---|---|
| string | The name of the docker compose service. |
|
| No description. |
serviceName
Required
- Type: string
The name of the docker compose service.
serviceDescription
Required
Methods
Name | Description |
---|---|
| Make the service depend on another service. |
| Add an environment variable. |
| Add a label. |
| Add a network to the service. |
| Add a port mapping. |
| Add a volume to the service. |
addDependsOn
public addDependsOn(serviceName: IDockerComposeServiceName): void
Make the service depend on another service.
serviceName
Required
addEnvironment
public addEnvironment(name: string, value: string): void
Add an environment variable.
name
Required
- Type: string
environment variable name.
value
Required
- Type: string
value of the environment variable.
addLabel
public addLabel(name: string, value: string): void
Add a label.
name
Required
- Type: string
environment variable name.
value
Required
- Type: string
value of the environment variable.
addNetwork
public addNetwork(network: IDockerComposeNetworkBinding): void
Add a network to the service.
network
Required
addPort
public addPort(publishedPort: number, targetPort: number, options?: DockerComposePortMappingOptions): void
Add a port mapping.
publishedPort
Required
- Type: number
Published port number.
targetPort
Required
- Type: number
Container's port number.
options
Optional
Port mapping options.
addVolume
public addVolume(volume: IDockerComposeVolumeBinding): void
Add a volume to the service.
volume
Required
Properties
Name | Type | Description |
---|---|---|
|
| Other services that this service depends on. |
| {[ key: string ]: string} | Environment variables. |
| {[ key: string ]: string} | Attached labels. |
|
| Networks mounted in the container. |
|
| Published ports. |
| string | Name of the service. |
|
| Volumes mounted in the container. |
| string[] | Command to run in the container. |
| string[] | Entrypoint to run in the container. |
| string | Docker image. |
|
| Docker image build instructions. |
| string | Target platform. |
dependsOn
Required
public readonly dependsOn: IDockerComposeServiceName[];
- Type: IDockerComposeServiceName[]
Other services that this service depends on.
environment
Required
public readonly environment: {[ key: string ]: string};
- Type: {[ key: string ]: string}
Environment variables.
labels
Required
public readonly labels: {[ key: string ]: string};
- Type: {[ key: string ]: string}
Attached labels.
networks
Required
public readonly networks: IDockerComposeNetworkBinding[];
- Type: IDockerComposeNetworkBinding[]
Networks mounted in the container.
ports
Required
public readonly ports: DockerComposeServicePort[];
- Type: DockerComposeServicePort[]
Published ports.
serviceName
Required
public readonly serviceName: string;
- Type: string
Name of the service.
volumes
Required
public readonly volumes: IDockerComposeVolumeBinding[];
- Type: IDockerComposeVolumeBinding[]
Volumes mounted in the container.
command
Optional
public readonly command: string[];
- Type: string[]
Command to run in the container.
entrypoint
Optional
public readonly entrypoint: string[];
- Type: string[]
Entrypoint to run in the container.
image
Optional
public readonly image: string;
- Type: string
Docker image.
imageBuild
Optional
public readonly imageBuild: DockerComposeBuild;
- Type: DockerComposeBuild
Docker image build instructions.
platform
Optional
public readonly platform: string;
- Type: string
Target platform.
JsonPatch
Utility for applying RFC-6902 JSON-Patch to a document.
Use the the JsonPatch.apply(doc, ...ops)
function to apply a set of
operations to a JSON document and return the result.
Operations can be created using the factory methods JsonPatch.add()
,
JsonPatch.remove()
, etc.
Example
const output = JsonPatch.apply(input,
JsonPatch.replace('/world/hi/there', 'goodbye'),
JsonPatch.add('/world/foo/', 'boom'),
JsonPatch.remove('/hello'));
Static Functions
Name | Description |
---|---|
| Adds a value to an object or inserts it into an array. |
| Applies a set of JSON-Patch (RFC-6902) operations to document and returns the result. |
| Copies a value from one location to another within the JSON document. |
| Escapes a json pointer path. |
| Moves a value from one location to the other. |
| Removes a value from an object or array. |
| Replaces a value. |
| Tests that the specified value is set in the document. |
add
import { JsonPatch } from 'projen'
JsonPatch.add(path: string, value: any)
Adds a value to an object or inserts it into an array.
In the case of an array, the value is inserted before the given index. The - character can be used instead of an index to insert at the end of an array.
Example
JsonPatch.add('/biscuits/1', { "name": "Ginger Nut" })
path
Required
- Type: string
value
Required
- Type: any
apply
import { JsonPatch } from 'projen'
JsonPatch.apply(document: any, ops: JsonPatch)
Applies a set of JSON-Patch (RFC-6902) operations to document
and returns the result.
document
Required
- Type: any
The document to patch.
ops
Required
- Type: JsonPatch
The operations to apply.
copy
import { JsonPatch } from 'projen'
JsonPatch.copy(from: string, path: string)
Copies a value from one location to another within the JSON document.
Both from and path are JSON Pointers.
Example
JsonPatch.copy('/biscuits/0', '/best_biscuit')
from
Required
- Type: string
path
Required
- Type: string
escapePath
import { JsonPatch } from 'projen'
JsonPatch.escapePath(path: string)
Escapes a json pointer path.
path
Required
- Type: string
The raw pointer.
move
import { JsonPatch } from 'projen'
JsonPatch.move(from: string, path: string)
Moves a value from one location to the other.
Both from and path are JSON Pointers.
Example
JsonPatch.move('/biscuits', '/cookies')
from
Required
- Type: string
path
Required
- Type: string
remove
import { JsonPatch } from 'projen'
JsonPatch.remove(path: string)
Removes a value from an object or array.
Example
JsonPatch.remove('/biscuits/0')
path
Required
- Type: string
replace
import { JsonPatch } from 'projen'
JsonPatch.replace(path: string, value: any)
Replaces a value.
Equivalent to a “remove” followed by an “add”.
Example
JsonPatch.replace('/biscuits/0/name', 'Chocolate Digestive')
path
Required
- Type: string
value
Required
- Type: any
test
import { JsonPatch } from 'projen'
JsonPatch.test(path: string, value: any, failureBehavior?: TestFailureBehavior)
Tests that the specified value is set in the document.
If the test fails, then the patch as a whole should not apply.
Example
JsonPatch.test('/best_biscuit/name', 'Choco Leibniz')
path
Required
- Type: string
value
Required
- Type: any
failureBehavior
Optional
- Type: TestFailureBehavior
Projects
Programmatic API for projen.
Static Functions
Name | Description |
---|---|
| Creates a new project with defaults. |
createProject
import { Projects } from 'projen'
Projects.createProject(options: CreateProjectOptions)
Creates a new project with defaults.
This function creates the project type in-process (with in VM) and calls
.synth()
on it (if options.synth
is not false
).
At the moment, it also generates a .projenrc.js
file with the same code
that was just executed. In the future, this will also be done by the project
type, so we can easily support multiple languages of projenrc.
An environment variable (PROJEN_CREATE_PROJECT=true) is set within the VM so that custom project types can detect whether the current synthesis is the result of a new project creation (and take additional steps accordingly)
options
Required
- Type: CreateProjectOptions
ReleasableCommits
Find commits that should be considered releasable to decide if a release is required.
Static Functions
Name | Description |
---|---|
| Release every commit. |
| Use an arbitrary shell command to find releasable commits since the latest tag. |
| Release only features and fixes. |
| Limit commits by their conventional commit type. |
everyCommit
import { ReleasableCommits } from 'projen'
ReleasableCommits.everyCommit(path?: string)
Release every commit.
This will only not release if the most recent commit is tagged with the latest matching tag.
path
Optional
- Type: string
Consider only commits that are enough to explain how the files that match the specified paths came to be.
This path is relative to the current working dir of the bump
task, i.e. to only consider commits of a subproject use "."
.
exec
import { ReleasableCommits } from 'projen'
ReleasableCommits.exec(cmd: string)
Use an arbitrary shell command to find releasable commits since the latest tag.
A new release will be initiated, if the number of returned commits is greater than zero.
Must return a newline separate list of commits that should considered releasable.
$LATEST_TAG
will be replaced with the actual latest tag for the given prefix.*
Example
"git log --oneline $LATEST_TAG..HEAD -- ."
cmd
Required
- Type: string
featuresAndFixes
import { ReleasableCommits } from 'projen'
ReleasableCommits.featuresAndFixes(path?: string)
Release only features and fixes.
Shorthand for ReleasableCommits.onlyOfType(['feat', 'fix'])
.
path
Optional
- Type: string
Consider only commits that are enough to explain how the files that match the specified paths came to be.
This path is relative to the current working dir of the bump
task, i.e. to only consider commits of a subproject use "."
.
ofType
import { ReleasableCommits } from 'projen'
ReleasableCommits.ofType(types: string[], path?: string)
Limit commits by their conventional commit type.
This will only release commit that match one of the provided types. Commits are required to follow the conventional commit spec and will be ignored otherwise.
types
Required
- Type: string[]
List of conventional commit types that should be released.
path
Optional
- Type: string
Consider only commits that are enough to explain how the files that match the specified paths came to be.
This path is relative to the current working dir of the bump
task, i.e. to only consider commits of a subproject use "."
.
Properties
Name | Type | Description |
---|---|---|
| string | No description. |
cmd
Required
public readonly cmd: string;
- Type: string
Semver
Static Functions
Name | Description |
---|---|
| Accept any minor version. |
| Latest version. |
| No description. |
| Accept only an exact version. |
| Accept patches. |
caret
caret
import { Semver } from 'projen'
Semver.caret(version: string)
Accept any minor version.
= version < next major version
version
Required
- Type: string
latest
latest
import { Semver } from 'projen'
Semver.latest()
Latest version.
of
of
import { Semver } from 'projen'
Semver.of(spec: string)
spec
Required
- Type: string
pinned
pinned
import { Semver } from 'projen'
Semver.pinned(version: string)
Accept only an exact version.
version
Required
- Type: string
tilde
tilde
import { Semver } from 'projen'
Semver.tilde(version: string)
Accept patches.
= version < next minor version
version
Required
- Type: string
Properties
Name | Type | Description |
---|---|---|
| string | No description. |
| string | No description. |
| string | No description. |
spec
Required
spec
- Deprecated: This class will be removed in upcoming releases. if you wish to
specify semver requirements in
deps
,devDeps
, etc, specify them like soexpress@^2.1
.
public readonly spec: string;
- Type: string
mode
Optional
mode
- Deprecated: This class will be removed in upcoming releases. if you wish to
specify semver requirements in
deps
,devDeps
, etc, specify them like soexpress@^2.1
.
public readonly mode: string;
- Type: string
version
Optional
version
- Deprecated: This class will be removed in upcoming releases. if you wish to
specify semver requirements in
deps
,devDeps
, etc, specify them like soexpress@^2.1
.
public readonly version: string;
- Type: string
Task
A task that can be performed on the project.
Modeled as a series of shell commands and subtasks.
Initializers
import { Task } from 'projen'
new Task(name: string, props?: TaskOptions)
Name | Type | Description |
---|---|---|
| string | No description. |
|
| No description. |
name
Required
- Type: string
props
Optional
- Type: TaskOptions
Methods
Name | Description |
---|---|
| Add a command to execute which determines if the task should be skipped. |
| Execute a builtin task. |
| Adds an environment variable to this task. |
| Executes a shell command. |
| Forbid additional changes to this task. |
| Adds a command at the beginning of the task. |
| Adds a command at the beginning of the task. |
| Says something at the beginning of the task. |
| Adds a spawn instruction at the beginning of the task. |
| No description. |
| Reset the task so it no longer has any commands. |
| Say something. |
| Spawns a sub-task. |
| No description. |
addCondition
public addCondition(condition: string): void
Add a command to execute which determines if the task should be skipped.
If a condition already exists, the new condition will be appended with &&
delimiter.
[{@link Task.condition }]({@link Task.condition })
condition
Required
- Type: string
The command to execute.
builtin
public builtin(name: string): void
Execute a builtin task.
Builtin tasks are programs bundled as part of projen itself and used as helpers for various components.
In the future we should support built-in tasks from external modules.
name
Required
- Type: string
The name of the builtin task to execute (e.g. release/resolve-version
).
env
public env(name: string, value: string): void
Adds an environment variable to this task.
name
Required
- Type: string
The name of the variable.
value
Required
- Type: string
The value.
If the value is surrounded by $()
, we will
evaluate it within a subshell and use the result as the value of the
environment variable.
exec
public exec(command: string, options?: TaskStepOptions): void
Executes a shell command.
command
Required
- Type: string
Shell command.
options
Optional
- Type: TaskStepOptions
Options.
lock
public lock(): void
Forbid additional changes to this task.
prepend
prepend
public prepend(shell: string, options?: TaskStepOptions): void
Adds a command at the beginning of the task.
shell
Required
- Type: string
The command to add.
options
Optional
- Type: TaskStepOptions
prependExec
public prependExec(shell: string, options?: TaskStepOptions): void
Adds a command at the beginning of the task.
shell
Required
- Type: string
The command to add.
options
Optional
- Type: TaskStepOptions
prependSay
public prependSay(message: string, options?: TaskStepOptions): void
Says something at the beginning of the task.
message
Required
- Type: string
Your message.
options
Optional
- Type: TaskStepOptions
prependSpawn
public prependSpawn(subtask: Task, options?: TaskStepOptions): void
Adds a spawn instruction at the beginning of the task.
subtask
Required
- Type: Task
The subtask to execute.
options
Optional
- Type: TaskStepOptions
removeStep
public removeStep(index: number): void
index
Required
- Type: number
The index of the step to remove.
reset
public reset(command?: string, options?: TaskStepOptions): void
Reset the task so it no longer has any commands.
command
Optional
- Type: string
the first command to add to the task after it was cleared.
options
Optional
- Type: TaskStepOptions
say
public say(message: string, options?: TaskStepOptions): void
Say something.
message
Required
- Type: string
Your message.
options
Optional
- Type: TaskStepOptions
Options.
spawn
public spawn(subtask: Task, options?: TaskStepOptions): void
Spawns a sub-task.
subtask
Required
- Type: Task
The subtask to execute.
options
Optional
- Type: TaskStepOptions
updateStep
public updateStep(index: number, step: TaskStep): void
index
Required
- Type: number
The index of the step to edit.
step
Required
- Type: TaskStep
The new step to replace the old one entirely, it is not merged with the old step.
Properties
Name | Type | Description |
---|---|---|
| {[ key: string ]: string} | Returns all environment variables in the task level. |
| string | Task name. |
|
| Returns an immutable copy of all the step specifications of the task. |
| string | A command to execute which determines if the task should be skipped. |
| string | Returns the working directory for this task. |
| string | Returns the description of this task. |
envVars
Required
public readonly envVars: {[ key: string ]: string};
- Type: {[ key: string ]: string}
Returns all environment variables in the task level.
name
Required
public readonly name: string;
- Type: string
Task name.
steps
Required
public readonly steps: TaskStep[];
- Type: TaskStep[]
Returns an immutable copy of all the step specifications of the task.
condition
Optional
public readonly condition: string;
- Type: string
A command to execute which determines if the task should be skipped.
If it returns a zero exit code, the task will not be executed.
cwd
Optional
public readonly cwd: string;
- Type: string
Returns the working directory for this task.
Sets the working directory for this task.
description
Optional
public readonly description: string;
- Type: string
Returns the description of this task.
Sets the description of this task.
TaskRuntime
The runtime component of the tasks engine.
Initializers
import { TaskRuntime } from 'projen'
new TaskRuntime(workdir: string)
Name | Type | Description |
---|---|---|
| string | No description. |
workdir
Required
- Type: string
Methods
Name | Description |
---|---|
| Runs the task. |
| Find a task by name, or undefined if not found. |
runTask
public runTask(name: string, parents?: string[], args?: string | number[]): void
Runs the task.
name
Required
- Type: string
The task name.
parents
Optional
- Type: string[]
args
Optional
- Type: string | number[]
tryFindTask
public tryFindTask(name: string): TaskSpec
Find a task by name, or undefined
if not found.
name
Required
- Type: string
Properties
Name | Type | Description |
---|---|---|
|
| The contents of tasks.json. |
|
| The tasks in this project. |
| string | The root directory of the project and the cwd for executing tasks. |
manifest
Required
public readonly manifest: TasksManifest;
- Type: TasksManifest
The contents of tasks.json.
tasks
Required
public readonly tasks: TaskSpec[];
- Type: TaskSpec[]
The tasks in this project.
workdir
Required
public readonly workdir: string;
- Type: string
The root directory of the project and the cwd for executing tasks.
Constants
Name | Type | Description |
---|---|---|
| string | The project-relative path of the tasks manifest file. |
MANIFEST_FILE
Required
public readonly MANIFEST_FILE: string;
- Type: string
The project-relative path of the tasks manifest file.
Testing
A Testing static class with a .synth helper for getting a snapshots of construct outputs. Useful for snapshot testing with Jest.
Example
`expect(Testing.synth(someProject)).toMatchSnapshot()`
Static Functions
Name | Description |
---|---|
| Produces a simple JS object that represents the contents of the projects with field names being file paths. |
synth
import { Testing } from 'projen'
Testing.synth(project: Project, options?: SnapshotOptions)
Produces a simple JS object that represents the contents of the projects with field names being file paths.
project
Required
- Type: Project
the project to produce a snapshot for.
options
Optional
- Type: SnapshotOptions
Protocols
IDevEnvironment
- Implemented By: projen.vscode.DevContainer, Gitpod, projen.vscode.IDevContainerEnvironment, IDevEnvironment
Abstract interface for container-based development environments, such as Gitpod and GitHub Codespaces.
Methods
Name | Description |
---|---|
| Add a custom Docker image or Dockerfile for the container. |
| Adds ports that should be exposed (forwarded) from the container. |
| Adds tasks to run when the container starts. |
| Adds a list of VSCode extensions that should be automatically installed in the container. |
addDockerImage
public addDockerImage(image: DevEnvironmentDockerImage): void
Add a custom Docker image or Dockerfile for the container.
image
Required
The Docker image.
addPorts
public addPorts(ports: string): void
Adds ports that should be exposed (forwarded) from the container.
ports
Required
- Type: string
The new ports.
addTasks
public addTasks(tasks: Task): void
Adds tasks to run when the container starts.
tasks
Required
- Type: Task
The new tasks.
addVscodeExtensions
public addVscodeExtensions(extensions: string): void
Adds a list of VSCode extensions that should be automatically installed in the container.
extensions
Required
- Type: string
The extension IDs.
IDockerComposeNetworkBinding
- Implemented By: IDockerComposeNetworkBinding
Network binding information.
Methods
Name | Description |
---|---|
| Binds the requested network to the docker-compose network configuration and provide mounting instructions for synthesis. |
bind
public bind(networkConfig: IDockerComposeNetworkConfig): string
Binds the requested network to the docker-compose network configuration and provide mounting instructions for synthesis.
networkConfig
Required
the network configuration.
IDockerComposeNetworkConfig
- Implemented By: IDockerComposeNetworkConfig
Storage for network configuration.
Methods
Name | Description |
---|---|
| Add network configuration to the repository. |
addNetworkConfiguration
public addNetworkConfiguration(networkName: string, configuration: DockerComposeNetworkConfig): void
Add network configuration to the repository.
networkName
Required
- Type: string
configuration
Required
IDockerComposeServiceName
- Implemented By: DockerComposeService, IDockerComposeServiceName
An interface providing the name of a docker compose service.
Properties
Name | Type | Description |
---|---|---|
| string | The name of the docker compose service. |
serviceName
Required
public readonly serviceName: string;
- Type: string
The name of the docker compose service.
IDockerComposeVolumeBinding
- Implemented By: IDockerComposeVolumeBinding
Volume binding information.
Methods
Name | Description |
---|---|
| Binds the requested volume to the docker-compose volume configuration and provide mounting instructions for synthesis. |
bind
public bind(volumeConfig: IDockerComposeVolumeConfig): DockerComposeVolumeMount
Binds the requested volume to the docker-compose volume configuration and provide mounting instructions for synthesis.
volumeConfig
Required
the volume configuration.
IDockerComposeVolumeConfig
- Implemented By: IDockerComposeVolumeConfig
Storage for volume configuration.
Methods
Name | Description |
---|---|
| Add volume configuration to the repository. |
addVolumeConfiguration
public addVolumeConfiguration(volumeName: string, configuration: DockerComposeVolumeConfig): void
Add volume configuration to the repository.
volumeName
Required
- Type: string
configuration
Required
IResolvable
- Implemented By: IResolvable
Methods
Name | Description |
---|---|
| Resolves and returns content. |
toJSON
public toJSON(): any
Resolves and returns content.
IResolver
- Implemented By: IResolver
API for resolving tokens when synthesizing file content.
Methods
Name | Description |
---|---|
| Given a value (object/string/array/whatever, looks up any functions inside the object and returns an object where all functions are called. |
resolve
public resolve(value: any, options?: ResolveOptions): any
Given a value (object/string/array/whatever, looks up any functions inside the object and returns an object where all functions are called.
value
Required
- Type: any
The value to resolve.
options
Optional
- Type: ResolveOptions
Enums
DependencyType
Type of dependency.
Members
Name | Description |
---|---|
| The dependency is required for the program/library during runtime. |
| The dependency is required at runtime but expected to be installed by the consumer. |
| The dependency is bundled and shipped with the module, so consumers are not required to install it. |
| The dependency is required to run the build task. |
| The dependency is required to run the test task. |
| The dependency is required for development (e.g. IDE plugins). |
| Transient dependency that needs to be overwritten. |
| An optional dependency that may be used at runtime if available, but is not required. |
RUNTIME
The dependency is required for the program/library during runtime.
PEER
The dependency is required at runtime but expected to be installed by the consumer.
BUNDLED
The dependency is bundled and shipped with the module, so consumers are not required to install it.
BUILD
The dependency is required to run the build
task.
TEST
The dependency is required to run the test
task.
DEVENV
The dependency is required for development (e.g. IDE plugins).
OVERRIDE
Transient dependency that needs to be overwritten.
Available for Node packages
OPTIONAL
An optional dependency that may be used at runtime if available, but is not required.
It is expected to be installed by the consumer.
DockerComposeProtocol
Network protocol for port mapping.
Members
Name | Description |
---|---|
| TCP protocol. |
| UDP protocol. |
TCP
TCP protocol.
UDP
UDP protocol.
GitpodOnOpen
What to do when a service on a port is detected.
Members
Name | Description |
---|---|
| Open a new browser tab. |
| Open a preview on the right side of the IDE. |
| Show a notification asking the user what to do (default). |
| Do nothing. |
OPEN_BROWSER
Open a new browser tab.
OPEN_PREVIEW
Open a preview on the right side of the IDE.
NOTIFY
Show a notification asking the user what to do (default).
IGNORE
Do nothing.
GitpodOpenIn
Configure where in the IDE the terminal should be opened.
Members
Name | Description |
---|---|
| the bottom panel (default). |
| the left panel. |
| the right panel. |
| the main editor area. |
BOTTOM
the bottom panel (default).
LEFT
the left panel.
RIGHT
the right panel.
MAIN
the main editor area.
GitpodOpenMode
Configure how the terminal should be opened relative to the previous task.
Members
Name | Description |
---|---|
| Opens in the same tab group right after the previous tab. |
| Opens in the same tab group left before the previous tab. |
| Splits and adds the terminal to the right. |
| Splits and adds the terminal to the left. |
| Splits and adds the terminal to the top. |
| Splits and adds the terminal to the bottom. |
TAB_AFTER
Opens in the same tab group right after the previous tab.
TAB_BEFORE
Opens in the same tab group left before the previous tab.
SPLIT_RIGHT
Splits and adds the terminal to the right.
SPLIT_LEFT
Splits and adds the terminal to the left.
SPLIT_TOP
Splits and adds the terminal to the top.
SPLIT_BOTTOM
Splits and adds the terminal to the bottom.
GitpodPortVisibility
Whether the port visibility should be private or public.
Members
Name | Description |
---|---|
| Allows everyone with the port URL to access the port (default). |
| Only allows users with workspace access to access the port. |
PUBLIC
Allows everyone with the port URL to access the port (default).
PRIVATE
Only allows users with workspace access to access the port.
InitProjectOptionHints
Choices for how to display commented out options in projenrc files.
Does not apply to projenrc.json files.
Members
Name | Description |
---|---|
| Display all possible options (grouped by which interface they belong to). |
| Display only featured options, in alphabetical order. |
| Display no extra options. |
ALL
Display all possible options (grouped by which interface they belong to).
FEATURED
Display only featured options, in alphabetical order.
NONE
Display no extra options.
LogLevel
Logging verbosity.
Members
Name | Description |
---|---|
| No description. |
| No description. |
| No description. |
| No description. |
| No description. |
| No description. |
OFF
ERROR
WARN
INFO
DEBUG
VERBOSE
ProjectType
Which type of project this is.
Members
Name | Description |
---|---|
| This module may be a either a library or an app. |
| This is a library, intended to be published to a package manager and consumed by other projects. |
| This is an app (service, tool, website, etc). |
UNKNOWN
UNKNOWN
- Deprecated: no longer supported at the base project level
This module may be a either a library or an app.
LIB
LIB
- Deprecated: no longer supported at the base project level
This is a library, intended to be published to a package manager and consumed by other projects.
APP
APP
- Deprecated: no longer supported at the base project level
This is an app (service, tool, website, etc).
Its artifacts are intended to be deployed or published for end-user consumption.
RenovatebotScheduleInterval
How often to check for new versions and raise pull requests for version updates.
Members
Name | Description |
---|---|
| Run at any time. |
| Weekly schedule on early monday mornings. |
| Schedule daily. |
| Schedule monthly. |
| Schedule quarterly. |
| Schedule for weekends. |
| Schedule for weekdays. |
ANY_TIME
Run at any time.
EARLY_MONDAYS
Weekly schedule on early monday mornings.
DAILY
Schedule daily.
MONTHLY
Schedule monthly.
QUARTERLY
Schedule quarterly.
WEEKENDS
Schedule for weekends.
WEEKDAYS
Schedule for weekdays.
TestFailureBehavior
Members
Name | Description |
---|---|
| Skip the current patch operation and continue with the next operation. |
| Fail the whole file synthesis. |
SKIP
Skip the current patch operation and continue with the next operation.
FAIL_SYNTHESIS
Fail the whole file synthesis.