projen

API Reference

Constructs

AutoApprove

Auto approve pull requests that meet a criteria.

Initializers

import { github } from 'projen'

new github.AutoApprove(github: GitHub, options?: AutoApproveOptions)
Name Type Description
github projen.github.GitHub No description.
options projen.github.AutoApproveOptions No description.

githubRequired

optionsOptional

Methods

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

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

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

isConstruct
import { github } from 'projen'

github.AutoApprove.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { github } from 'projen'

github.AutoApprove.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.
label string No description.

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

labelRequired
public readonly label: string;

AutoDiscover

Discovers and creates integration tests and lambdas from code in the project’s source and test trees.

Initializers

import { awscdk } from 'projen'

new awscdk.AutoDiscover(project: Project, options: AutoDiscoverOptions)
Name Type Description
project Project No description.
options projen.awscdk.AutoDiscoverOptions No description.

projectRequired

optionsRequired

Methods

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

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

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

isConstruct
import { awscdk } from 'projen'

awscdk.AutoDiscover.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { awscdk } from 'projen'

awscdk.AutoDiscover.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

AutoDiscover

Automatically discovers and creates IntegrationTests from entry points found in the test tree.

Initializers

import { cdk8s } from 'projen'

new cdk8s.AutoDiscover(project: Project, options: AutoDiscoverOptions)
Name Type Description
project Project No description.
options projen.cdk8s.AutoDiscoverOptions No description.

projectRequired

optionsRequired

Methods

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

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

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

isConstruct
import { cdk8s } from 'projen'

cdk8s.AutoDiscover.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { cdk8s } from 'projen'

cdk8s.AutoDiscover.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

AutoDiscoverBase

Base class for auto-discovering and creating project subcomponents.

Initializers

import { cdk } from 'projen'

new cdk.AutoDiscoverBase(project: Project, options: AutoDiscoverBaseOptions)
Name Type Description
project Project No description.
options projen.cdk.AutoDiscoverBaseOptions No description.

projectRequired

optionsRequired

Methods

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

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

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

isConstruct
import { cdk } from 'projen'

cdk.AutoDiscoverBase.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { cdk } from 'projen'

cdk.AutoDiscoverBase.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.
entrypoints string[] Auto-discovered entry points with paths relative to the project directory.

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

entrypointsRequired
public readonly entrypoints: string[];

Auto-discovered entry points with paths relative to the project directory.


AutoMerge

Sets up mergify to merging approved pull requests.

If buildJob is specified, the specified GitHub workflow job ID is required to succeed in order for the PR to be merged.

approvedReviews specified the number of code review approvals required for the PR to be merged.

Initializers

import { github } from 'projen'

new github.AutoMerge(github: GitHub, options?: AutoMergeOptions)
Name Type Description
github projen.github.GitHub No description.
options projen.github.AutoMergeOptions No description.

githubRequired

optionsOptional

Methods

Name Description
toString Returns a string representation of this construct.
postSynthesize Called after synthesis.
preSynthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.
addConditions Adds conditions to the auto merge rule.
addConditionsLater Adds conditions that will be rendered only during synthesis.

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.

addConditions
public addConditions(conditions: string): void

Adds conditions to the auto merge rule.

conditionsRequired

The conditions to add (mergify syntax).


addConditionsLater
public addConditionsLater(later: IAddConditionsLater): void

Adds conditions that will be rendered only during synthesis.

laterRequired

The later.


Static Functions

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

isConstruct
import { github } from 'projen'

github.AutoMerge.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { github } from 'projen'

github.AutoMerge.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

AwsCdkConstructLibrary

AWS CDK construct library project.

A multi-language (jsii) construct library which vends constructs designed to use within the AWS CDK with a friendly workflow and automatic publishing to the construct catalog.

Initializers

import { awscdk } from 'projen'

new awscdk.AwsCdkConstructLibrary(options: AwsCdkConstructLibraryOptions)
Name Type Description
options projen.awscdk.AwsCdkConstructLibraryOptions No description.

optionsRequired

Methods

Name Description
toString Returns a string representation of this construct.
addExcludeFromCleanup Exclude the matching files from pre-synth cleanup.
addGitIgnore Adds a .gitignore pattern.
addPackageIgnore Exclude these files from the bundled package.
addTask Adds a new task to this project.
addTip Prints a “tip” message during synthesis.
annotateGenerated Marks the provided file(s) as being generated.
postSynthesize Called after all components are synthesized.
preSynthesize Called before all components are synthesized.
removeTask Removes a task from a project.
runTaskCommand Returns the shell command to execute in order to run a task.
synth Synthesize all project files into outdir.
tryFindFile Finds a file at the specified relative path within this project and all its subprojects.
tryFindJsonFile Finds a json file by name.
tryFindObjectFile Finds an object file (like JsonFile, YamlFile, etc.) by name.
tryRemoveFile Finds a file at the specified relative path within this project and removes it.
addBins No description.
addBundledDeps Defines bundled dependencies.
addCompileCommand DEPRECATED.
addDeps Defines normal dependencies.
addDevDeps Defines development/test dependencies.
addFields Directly set fields in package.json.
addKeywords Adds keywords to package.json (deduplicated).
addPeerDeps Defines peer dependencies.
addScripts Replaces the contents of multiple npm package.json scripts.
addTestCommand DEPRECATED.
hasScript Indicates if a script by the name name is defined.
removeScript Removes the npm script (always successful).
renderWorkflowSetup Returns the set of workflow steps which should be executed to bootstrap a workflow.
setScript Replaces the contents of an npm package.json script.
addCdkDependencies Adds dependencies to AWS CDK modules.
addCdkTestDependencies Adds AWS CDK modules as dev dependencies.

toString
public toString(): string

Returns a string representation of this construct.

addExcludeFromCleanup
public addExcludeFromCleanup(globs: string): void

Exclude the matching files from pre-synth cleanup.

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

globsRequired

The glob patterns to match.


addGitIgnore
public addGitIgnore(pattern: string): void

Adds a .gitignore pattern.

patternRequired

The glob pattern to ignore.


addPackageIgnore
public addPackageIgnore(pattern: string): void

Exclude these files from the bundled package.

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

patternRequired

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

Adds a new task to this project.

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

nameRequired

The task name to add.


propsOptional

Task properties.


addTip
public addTip(message: string): void

Prints a “tip” message during synthesis.

messageRequired

The message.


annotateGenerated
public annotateGenerated(glob: string): void

Marks the provided file(s) as being generated.

This is achieved using the github-linguist attributes. Generated files do not count against the repository statistics and language breakdown.

https://github.com/github/linguist/blob/master/docs/overrides.md

globRequired

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


postSynthesize
public postSynthesize(): void

Called after all components are synthesized.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before all components are synthesized.

removeTask
public removeTask(name: string): Task

Removes a task from a project.

nameRequired

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.

This will typically be npx projen TASK.

taskRequired

The task for which the command is required.


synth
public synth(): void

Synthesize all project files into outdir.

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

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

filePathRequired

The file path.

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


tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile

Finds a json file by name.

filePathRequired

The file path.


tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile

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

filePathRequired

The file path.


tryRemoveFile
public tryRemoveFile(filePath: string): FileBase

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

filePathRequired

The file path.

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


addBins
public addBins(bins: {[ key: string ]: string}): void
binsRequired

addBundledDeps
public addBundledDeps(deps: string): void

Defines bundled dependencies.

Bundled dependencies will be added as normal dependencies as well as to the bundledDependencies section of your package.json.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addCompileCommand
public addCompileCommand(commands: string): void

DEPRECATED.

commandsRequired

addDeps
public addDeps(deps: string): void

Defines normal dependencies.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addDevDeps
public addDevDeps(deps: string): void

Defines development/test dependencies.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addFields
public addFields(fields: {[ key: string ]: any}): void

Directly set fields in package.json.

fieldsRequired

The fields to set.


addKeywords
public addKeywords(keywords: string): void

Adds keywords to package.json (deduplicated).

keywordsRequired

The keywords to add.


addPeerDeps
public addPeerDeps(deps: string): void

Defines peer dependencies.

When adding peer dependencies, a devDependency will also be added on the pinned version of the declared peer. This will ensure that you are testing your code against the minimum version required from your consumers.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addScripts
public addScripts(scripts: {[ key: string ]: string}): void

Replaces the contents of multiple npm package.json scripts.

scriptsRequired

The scripts to set.


addTestCommand
public addTestCommand(commands: string): void

DEPRECATED.

commandsRequired

hasScript
public hasScript(name: string): boolean

Indicates if a script by the name name is defined.

nameRequired

The name of the script.


removeScript
public removeScript(name: string): void

Removes the npm script (always successful).

nameRequired

The name of the script.


renderWorkflowSetup
public renderWorkflowSetup(options?: RenderWorkflowSetupOptions): JobStep[]

Returns the set of workflow steps which should be executed to bootstrap a workflow.

optionsOptional

Options.


setScript
public setScript(name: string, command: string): void

Replaces the contents of an npm package.json script.

nameRequired

The script name.


commandRequired

The command to execute.


addCdkDependencies
public addCdkDependencies(deps: string): void

Adds dependencies to AWS CDK modules.

Since this is a library project, dependencies will be added as peer dependencies.

depsRequired

names of cdk modules (e.g. @aws-cdk/aws-lambda).


addCdkTestDependencies
public addCdkTestDependencies(deps: string): void

Adds AWS CDK modules as dev dependencies.

depsRequired

names of cdk modules (e.g. @aws-cdk/aws-lambda).


Static Functions

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

isConstruct
import { awscdk } from 'projen'

awscdk.AwsCdkConstructLibrary.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isProject
import { awscdk } from 'projen'

awscdk.AwsCdkConstructLibrary.isProject(x: any)

Test whether the given construct is a project.

xRequired

of
import { awscdk } from 'projen'

awscdk.AwsCdkConstructLibrary.of(construct: IConstruct)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired

Properties

Name Type Description
node constructs.Node The tree node.
buildTask Task No description.
commitGenerated boolean Whether to commit the managed files by default.
compileTask Task No description.
components Component[] Returns all the components within this project.
deps Dependencies Project dependencies.
ejected boolean Whether or not the project is being ejected.
files FileBase[] All files in this project.
gitattributes GitAttributesFile The .gitattributes file for this repository.
gitignore IgnoreFile .gitignore.
logger Logger Logging utilities.
name string Project name.
outdir string Absolute output directory of this project.
packageTask Task No description.
postCompileTask Task No description.
preCompileTask Task No description.
projectBuild ProjectBuild Manages the build process of the project.
projenCommand string The command to use in order to run the projen CLI.
root Project The root project.
subprojects Project[] Returns all the subprojects within this project.
tasks Tasks Project tasks.
testTask Task No description.
defaultTask Task This is the “default” task, the one that executes “projen”.
initProject InitProject The options used when this project is bootstrapped via projen new.
parent Project A parent project.
projectType ProjectType No description.
autoApprove projen.github.AutoApprove Auto approve set up for this project.
devContainer projen.vscode.DevContainer Access for .devcontainer.json (used for GitHub Codespaces).
github projen.github.GitHub Access all github components.
gitpod Gitpod Access for Gitpod.
vscode projen.vscode.VsCode Access all VSCode components.
allowLibraryDependencies boolean No description.
artifactsDirectory string The build output directory.
artifactsJavascriptDirectory string The location of the npm tarball after build (${artifactsDirectory}/js).
bundler projen.javascript.Bundler No description.
entrypoint string No description.
manifest any No description.
npmrc projen.javascript.NpmConfig The .npmrc file.
package projen.javascript.NodePackage API for managing the node package.
packageManager projen.javascript.NodePackageManager The package manager to use.
runScriptCommand string The command to use to run scripts (e.g. yarn run or npm run depends on the package manager).
autoMerge projen.github.AutoMerge Component that sets up mergify for merging approved pull requests.
buildWorkflow projen.build.BuildWorkflow The PR build GitHub workflow.
buildWorkflowJobId string The job ID of the build workflow.
jest projen.javascript.Jest The Jest configuration (if enabled).
maxNodeVersion string Maximum node version required by this package.
minNodeVersion string Minimum node.js version required by this package.
npmignore IgnoreFile The .npmignore file.
prettier projen.javascript.Prettier No description.
publisher projen.release.Publisher Package publisher.
release projen.release.Release Release management.
upgradeWorkflow projen.javascript.UpgradeDependencies The upgrade workflow.
docsDirectory string No description.
libdir string The directory in which compiled .js files reside.
srcdir string The directory in which the .ts sources reside.
testdir string The directory in which tests reside.
tsconfigDev projen.javascript.TypescriptConfig A typescript configuration file which covers all files (sources, tests, projen).
watchTask Task The “watch” task.
docgen boolean No description.
eslint projen.javascript.Eslint No description.
tsconfig projen.javascript.TypescriptConfig No description.
tsconfigEslint projen.javascript.TypescriptConfig No description.
cdkDeps projen.awscdk.AwsCdkDeps No description.
cdkVersion string The target CDK version for this library.
version string No description.

nodeRequired
public readonly node: Node;

The tree node.


buildTaskRequired
public readonly buildTask: Task;

commitGeneratedRequired
public readonly commitGenerated: boolean;

Whether to commit the managed files by default.


compileTaskRequired
public readonly compileTask: Task;

componentsRequired
public readonly components: Component[];

Returns all the components within this project.


depsRequired
public readonly deps: Dependencies;

Project dependencies.


ejectedRequired
public readonly ejected: boolean;

Whether or not the project is being ejected.


filesRequired
public readonly files: FileBase[];

All files in this project.


gitattributesRequired
public readonly gitattributes: GitAttributesFile;

The .gitattributes file for this repository.


gitignoreRequired
public readonly gitignore: IgnoreFile;

.gitignore.


loggerRequired
public readonly logger: Logger;

Logging utilities.


nameRequired
public readonly name: string;

Project name.


outdirRequired
public readonly outdir: string;

Absolute output directory of this project.


packageTaskRequired
public readonly packageTask: Task;

postCompileTaskRequired
public readonly postCompileTask: Task;

preCompileTaskRequired
public readonly preCompileTask: Task;

projectBuildRequired
public readonly projectBuild: ProjectBuild;

Manages the build process of the project.


projenCommandRequired
public readonly projenCommand: string;

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


rootRequired
public readonly root: Project;

The root project.


subprojectsRequired
public readonly subprojects: Project[];

Returns all the subprojects within this project.


tasksRequired
public readonly tasks: Tasks;

Project tasks.


testTaskRequired
public readonly testTask: Task;

defaultTaskOptional
public readonly defaultTask: Task;

This is the “default” task, the one that executes “projen”.

Undefined if the project is being ejected.


initProjectOptional
public readonly initProject: InitProject;

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

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


parentOptional
public readonly parent: Project;

A parent project.

If undefined, this is the root project.


projectTypeRequired
public readonly projectType: ProjectType;

autoApproveOptional
public readonly autoApprove: AutoApprove;

Auto approve set up for this project.


devContainerOptional
public readonly devContainer: DevContainer;

Access for .devcontainer.json (used for GitHub Codespaces).

This will be undefined if devContainer boolean is false


githubOptional
public readonly github: GitHub;

Access all github components.

This will be undefined for subprojects.


gitpodOptional
public readonly gitpod: Gitpod;

Access for Gitpod.

This will be undefined if gitpod boolean is false


vscodeOptional
public readonly vscode: VsCode;

Access all VSCode components.

This will be undefined for subprojects.


allowLibraryDependenciesRequired
public readonly allowLibraryDependencies: boolean;

artifactsDirectoryRequired
public readonly artifactsDirectory: string;

The build output directory.

An npm tarball will be created under the js subdirectory. For example, if this is set to dist (the default), the npm tarball will be placed under dist/js/boom-boom-1.2.3.tg.


artifactsJavascriptDirectoryRequired
public readonly artifactsJavascriptDirectory: string;

The location of the npm tarball after build (${artifactsDirectory}/js).


bundlerRequired
public readonly bundler: Bundler;

entrypointRequired
public readonly entrypoint: string;

manifestRequired
public readonly manifest: any;

npmrcRequired
public readonly npmrc: NpmConfig;

The .npmrc file.


packageRequired
public readonly package: NodePackage;

API for managing the node package.


packageManagerRequired
public readonly packageManager: NodePackageManager;

The package manager to use.


runScriptCommandRequired
public readonly runScriptCommand: string;

The command to use to run scripts (e.g. yarn run or npm run depends on the package manager).


autoMergeOptional
public readonly autoMerge: AutoMerge;

Component that sets up mergify for merging approved pull requests.


buildWorkflowOptional
public readonly buildWorkflow: BuildWorkflow;

The PR build GitHub workflow.

undefined if buildWorkflow is disabled.


buildWorkflowJobIdOptional
public readonly buildWorkflowJobId: string;

The job ID of the build workflow.


jestOptional
public readonly jest: Jest;

The Jest configuration (if enabled).


maxNodeVersionOptional
public readonly maxNodeVersion: string;

Maximum node version required by this package.


minNodeVersionOptional
public readonly minNodeVersion: string;

Minimum node.js version required by this package.


npmignoreOptional
public readonly npmignore: IgnoreFile;

The .npmignore file.


prettierOptional
public readonly prettier: Prettier;

publisherOptional
public readonly publisher: Publisher;

Package publisher.

This will be undefined if the project does not have a release workflow.


releaseOptional
public readonly release: Release;

Release management.


upgradeWorkflowOptional
public readonly upgradeWorkflow: UpgradeDependencies;

The upgrade workflow.


docsDirectoryRequired
public readonly docsDirectory: string;

libdirRequired
public readonly libdir: string;

The directory in which compiled .js files reside.


srcdirRequired
public readonly srcdir: string;

The directory in which the .ts sources reside.


testdirRequired
public readonly testdir: string;

The directory in which tests reside.


tsconfigDevRequired
public readonly tsconfigDev: TypescriptConfig;

A typescript configuration file which covers all files (sources, tests, projen).


watchTaskRequired
public readonly watchTask: Task;

The “watch” task.


docgenOptional
public readonly docgen: boolean;

eslintOptional
public readonly eslint: Eslint;

tsconfigOptional
public readonly tsconfig: TypescriptConfig;

tsconfigEslintOptional
public readonly tsconfigEslint: TypescriptConfig;

cdkDepsRequired
public readonly cdkDeps: AwsCdkDeps;

cdkVersionRequired
public readonly cdkVersion: string;

The target CDK version for this library.


versionRequired
public readonly version: string;

Constants

Name Type Description
DEFAULT_TASK string The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
public readonly DEFAULT_TASK: string;

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

Normally this task should synthesize the project files.


AwsCdkDeps

Manages dependencies on the AWS CDK.

Initializers

import { awscdk } from 'projen'

new awscdk.AwsCdkDeps(project: Project, options: AwsCdkDepsOptions)
Name Type Description
project Project No description.
options projen.awscdk.AwsCdkDepsOptions No description.

projectRequired

optionsRequired

Methods

Name Description
toString Returns a string representation of this construct.
postSynthesize Called after synthesis.
preSynthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.
addV1Dependencies Adds dependencies to AWS CDK modules.
addV1DevDependencies Adds AWS CDK modules as dev dependencies.

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.

addV1Dependencies
public addV1Dependencies(deps: string): void

Adds dependencies to AWS CDK modules.

The type of dependency is determined by the dependencyType option.

This method is not supported in CDK v2. Use project.addPeerDeps() or project.addDeps() as appropriate.

depsRequired

names of cdk modules (e.g. @aws-cdk/aws-lambda).


addV1DevDependencies
public addV1DevDependencies(deps: string): void

Adds AWS CDK modules as dev dependencies.

This method is not supported in CDK v2. Use project.addPeerDeps() or project.addDeps() as appropriate.

depsRequired

fully qualified names of cdk modules (e.g. @aws-cdk/aws-lambda).


Static Functions

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

isConstruct
import { awscdk } from 'projen'

awscdk.AwsCdkDeps.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { awscdk } from 'projen'

awscdk.AwsCdkDeps.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.
cdkDependenciesAsDeps boolean Whether CDK dependencies are added as normal dependencies (and peer dependencies).
cdkMajorVersion number The major version of the AWS CDK (e.g. 1, 2, …).
cdkMinimumVersion string The minimum version of the AWS CDK (e.g. 2.0.0).
cdkVersion string The dependency requirement for AWS CDK (e.g. ^2.0.0).

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

cdkDependenciesAsDepsRequired
public readonly cdkDependenciesAsDeps: boolean;

Whether CDK dependencies are added as normal dependencies (and peer dependencies).


cdkMajorVersionRequired
public readonly cdkMajorVersion: number;

The major version of the AWS CDK (e.g. 1, 2, …).


cdkMinimumVersionRequired
public readonly cdkMinimumVersion: string;

The minimum version of the AWS CDK (e.g. 2.0.0).


cdkVersionRequired
public readonly cdkVersion: string;

The dependency requirement for AWS CDK (e.g. ^2.0.0).


AwsCdkDepsJava

Manages dependencies on the AWS CDK for Java projects.

Initializers

import { awscdk } from 'projen'

new awscdk.AwsCdkDepsJava(project: Project, options: AwsCdkDepsOptions)
Name Type Description
project Project No description.
options projen.awscdk.AwsCdkDepsOptions No description.

projectRequired

optionsRequired

Methods

Name Description
toString Returns a string representation of this construct.
postSynthesize Called after synthesis.
preSynthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.
addV1Dependencies Adds dependencies to AWS CDK modules.
addV1DevDependencies Adds AWS CDK modules as dev dependencies.

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.

addV1Dependencies
public addV1Dependencies(deps: string): void

Adds dependencies to AWS CDK modules.

The type of dependency is determined by the dependencyType option.

This method is not supported in CDK v2. Use project.addPeerDeps() or project.addDeps() as appropriate.

depsRequired

names of cdk modules (e.g. @aws-cdk/aws-lambda).


addV1DevDependencies
public addV1DevDependencies(deps: string): void

Adds AWS CDK modules as dev dependencies.

This method is not supported in CDK v2. Use project.addPeerDeps() or project.addDeps() as appropriate.

depsRequired

fully qualified names of cdk modules (e.g. @aws-cdk/aws-lambda).


Static Functions

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

isConstruct
import { awscdk } from 'projen'

awscdk.AwsCdkDepsJava.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { awscdk } from 'projen'

awscdk.AwsCdkDepsJava.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.
cdkDependenciesAsDeps boolean Whether CDK dependencies are added as normal dependencies (and peer dependencies).
cdkMajorVersion number The major version of the AWS CDK (e.g. 1, 2, …).
cdkMinimumVersion string The minimum version of the AWS CDK (e.g. 2.0.0).
cdkVersion string The dependency requirement for AWS CDK (e.g. ^2.0.0).

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

cdkDependenciesAsDepsRequired
public readonly cdkDependenciesAsDeps: boolean;

Whether CDK dependencies are added as normal dependencies (and peer dependencies).


cdkMajorVersionRequired
public readonly cdkMajorVersion: number;

The major version of the AWS CDK (e.g. 1, 2, …).


cdkMinimumVersionRequired
public readonly cdkMinimumVersion: string;

The minimum version of the AWS CDK (e.g. 2.0.0).


cdkVersionRequired
public readonly cdkVersion: string;

The dependency requirement for AWS CDK (e.g. ^2.0.0).


AwsCdkDepsJs

Manages dependencies on the AWS CDK for Node.js projects.

Initializers

import { awscdk } from 'projen'

new awscdk.AwsCdkDepsJs(project: Project, options: AwsCdkDepsOptions)
Name Type Description
project Project No description.
options projen.awscdk.AwsCdkDepsOptions No description.

projectRequired

optionsRequired

Methods

Name Description
toString Returns a string representation of this construct.
postSynthesize Called after synthesis.
preSynthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.
addV1Dependencies Adds dependencies to AWS CDK modules.
addV1DevDependencies Adds AWS CDK modules as dev dependencies.

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.

addV1Dependencies
public addV1Dependencies(deps: string): void

Adds dependencies to AWS CDK modules.

The type of dependency is determined by the dependencyType option.

This method is not supported in CDK v2. Use project.addPeerDeps() or project.addDeps() as appropriate.

depsRequired

names of cdk modules (e.g. @aws-cdk/aws-lambda).


addV1DevDependencies
public addV1DevDependencies(deps: string): void

Adds AWS CDK modules as dev dependencies.

This method is not supported in CDK v2. Use project.addPeerDeps() or project.addDeps() as appropriate.

depsRequired

fully qualified names of cdk modules (e.g. @aws-cdk/aws-lambda).


Static Functions

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

isConstruct
import { awscdk } from 'projen'

awscdk.AwsCdkDepsJs.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { awscdk } from 'projen'

awscdk.AwsCdkDepsJs.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.
cdkDependenciesAsDeps boolean Whether CDK dependencies are added as normal dependencies (and peer dependencies).
cdkMajorVersion number The major version of the AWS CDK (e.g. 1, 2, …).
cdkMinimumVersion string The minimum version of the AWS CDK (e.g. 2.0.0).
cdkVersion string The dependency requirement for AWS CDK (e.g. ^2.0.0).

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

cdkDependenciesAsDepsRequired
public readonly cdkDependenciesAsDeps: boolean;

Whether CDK dependencies are added as normal dependencies (and peer dependencies).


cdkMajorVersionRequired
public readonly cdkMajorVersion: number;

The major version of the AWS CDK (e.g. 1, 2, …).


cdkMinimumVersionRequired
public readonly cdkMinimumVersion: string;

The minimum version of the AWS CDK (e.g. 2.0.0).


cdkVersionRequired
public readonly cdkVersion: string;

The dependency requirement for AWS CDK (e.g. ^2.0.0).


AwsCdkDepsPy

Manages dependencies on the AWS CDK for Python projects.

Initializers

import { awscdk } from 'projen'

new awscdk.AwsCdkDepsPy(project: Project, options: AwsCdkDepsOptions)
Name Type Description
project Project No description.
options projen.awscdk.AwsCdkDepsOptions No description.

projectRequired

optionsRequired

Methods

Name Description
toString Returns a string representation of this construct.
postSynthesize Called after synthesis.
preSynthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.
addV1Dependencies Adds dependencies to AWS CDK modules.
addV1DevDependencies Adds AWS CDK modules as dev dependencies.

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.

addV1Dependencies
public addV1Dependencies(deps: string): void

Adds dependencies to AWS CDK modules.

The type of dependency is determined by the dependencyType option.

This method is not supported in CDK v2. Use project.addPeerDeps() or project.addDeps() as appropriate.

depsRequired

names of cdk modules (e.g. @aws-cdk/aws-lambda).


addV1DevDependencies
public addV1DevDependencies(deps: string): void

Adds AWS CDK modules as dev dependencies.

This method is not supported in CDK v2. Use project.addPeerDeps() or project.addDeps() as appropriate.

depsRequired

fully qualified names of cdk modules (e.g. @aws-cdk/aws-lambda).


Static Functions

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

isConstruct
import { awscdk } from 'projen'

awscdk.AwsCdkDepsPy.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { awscdk } from 'projen'

awscdk.AwsCdkDepsPy.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.
cdkDependenciesAsDeps boolean Whether CDK dependencies are added as normal dependencies (and peer dependencies).
cdkMajorVersion number The major version of the AWS CDK (e.g. 1, 2, …).
cdkMinimumVersion string The minimum version of the AWS CDK (e.g. 2.0.0).
cdkVersion string The dependency requirement for AWS CDK (e.g. ^2.0.0).

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

cdkDependenciesAsDepsRequired
public readonly cdkDependenciesAsDeps: boolean;

Whether CDK dependencies are added as normal dependencies (and peer dependencies).


cdkMajorVersionRequired
public readonly cdkMajorVersion: number;

The major version of the AWS CDK (e.g. 1, 2, …).


cdkMinimumVersionRequired
public readonly cdkMinimumVersion: string;

The minimum version of the AWS CDK (e.g. 2.0.0).


cdkVersionRequired
public readonly cdkVersion: string;

The dependency requirement for AWS CDK (e.g. ^2.0.0).


AwsCdkJavaApp

AWS CDK app in Java.

Initializers

import { awscdk } from 'projen'

new awscdk.AwsCdkJavaApp(options: AwsCdkJavaAppOptions)
Name Type Description
options projen.awscdk.AwsCdkJavaAppOptions No description.

optionsRequired

Methods

Name Description
toString Returns a string representation of this construct.
addExcludeFromCleanup Exclude the matching files from pre-synth cleanup.
addGitIgnore Adds a .gitignore pattern.
addPackageIgnore Exclude these files from the bundled package.
addTask Adds a new task to this project.
addTip Prints a “tip” message during synthesis.
annotateGenerated Marks the provided file(s) as being generated.
postSynthesize Called after all components are synthesized.
preSynthesize Called before all components are synthesized.
removeTask Removes a task from a project.
runTaskCommand Returns the shell command to execute in order to run a task.
synth Synthesize all project files into outdir.
tryFindFile Finds a file at the specified relative path within this project and all its subprojects.
tryFindJsonFile Finds a json file by name.
tryFindObjectFile Finds an object file (like JsonFile, YamlFile, etc.) by name.
tryRemoveFile Finds a file at the specified relative path within this project and removes it.
addDependency Adds a runtime dependency.
addPlugin Adds a build plugin to the pom.
addTestDependency Adds a test dependency.
addCdkDependency Adds an AWS CDK module dependencies.

toString
public toString(): string

Returns a string representation of this construct.

addExcludeFromCleanup
public addExcludeFromCleanup(globs: string): void

Exclude the matching files from pre-synth cleanup.

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

globsRequired

The glob patterns to match.


addGitIgnore
public addGitIgnore(pattern: string): void

Adds a .gitignore pattern.

patternRequired

The glob pattern to ignore.


addPackageIgnore
public addPackageIgnore(_pattern: string): void

Exclude these files from the bundled package.

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

_patternRequired

The glob pattern to exclude.


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

Adds a new task to this project.

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

nameRequired

The task name to add.


propsOptional

Task properties.


addTip
public addTip(message: string): void

Prints a “tip” message during synthesis.

messageRequired

The message.


annotateGenerated
public annotateGenerated(glob: string): void

Marks the provided file(s) as being generated.

This is achieved using the github-linguist attributes. Generated files do not count against the repository statistics and language breakdown.

https://github.com/github/linguist/blob/master/docs/overrides.md

globRequired

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


postSynthesize
public postSynthesize(): void

Called after all components are synthesized.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before all components are synthesized.

removeTask
public removeTask(name: string): Task

Removes a task from a project.

nameRequired

The name of the task to remove.


runTaskCommand
public runTaskCommand(task: Task): string

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

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

taskRequired

The task for which the command is required.


synth
public synth(): void

Synthesize all project files into outdir.

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

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

filePathRequired

The file path.

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


tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile

Finds a json file by name.

filePathRequired

The file path.


tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile

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

filePathRequired

The file path.


tryRemoveFile
public tryRemoveFile(filePath: string): FileBase

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

filePathRequired

The file path.

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


addDependency
public addDependency(spec: string): void

Adds a runtime dependency.

specRequired

Format <groupId>/<artifactId>@<semver>.


addPlugin
public addPlugin(spec: string, options?: PluginOptions): Dependency

Adds a build plugin to the pom.

The plug in is also added as a BUILD dep to the project.

specRequired

dependency spec (group/artifact@version).


optionsOptional

plugin options.


addTestDependency
public addTestDependency(spec: string): void

Adds a test dependency.

specRequired

Format <groupId>/<artifactId>@<semver>.


addCdkDependency
public addCdkDependency(modules: string): void

Adds an AWS CDK module dependencies.

modulesRequired

The list of modules to depend on (e.g. “software.amazon.awscdk/aws-lambda”, “software.amazon.awscdk/aws-iam”, etc).


Static Functions

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

isConstruct
import { awscdk } from 'projen'

awscdk.AwsCdkJavaApp.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isProject
import { awscdk } from 'projen'

awscdk.AwsCdkJavaApp.isProject(x: any)

Test whether the given construct is a project.

xRequired

of
import { awscdk } from 'projen'

awscdk.AwsCdkJavaApp.of(construct: IConstruct)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired

Properties

Name Type Description
node constructs.Node The tree node.
buildTask Task No description.
commitGenerated boolean Whether to commit the managed files by default.
compileTask Task No description.
components Component[] Returns all the components within this project.
deps Dependencies Project dependencies.
ejected boolean Whether or not the project is being ejected.
files FileBase[] All files in this project.
gitattributes GitAttributesFile The .gitattributes file for this repository.
gitignore IgnoreFile .gitignore.
logger Logger Logging utilities.
name string Project name.
outdir string Absolute output directory of this project.
packageTask Task No description.
postCompileTask Task No description.
preCompileTask Task No description.
projectBuild ProjectBuild Manages the build process of the project.
projenCommand string The command to use in order to run the projen CLI.
root Project The root project.
subprojects Project[] Returns all the subprojects within this project.
tasks Tasks Project tasks.
testTask Task No description.
defaultTask Task This is the “default” task, the one that executes “projen”.
initProject InitProject The options used when this project is bootstrapped via projen new.
parent Project A parent project.
projectType ProjectType No description.
autoApprove projen.github.AutoApprove Auto approve set up for this project.
devContainer projen.vscode.DevContainer Access for .devcontainer.json (used for GitHub Codespaces).
github projen.github.GitHub Access all github components.
gitpod Gitpod Access for Gitpod.
vscode projen.vscode.VsCode Access all VSCode components.
compile projen.java.MavenCompile Compile component.
distdir string Maven artifact output directory.
packaging projen.java.MavenPackaging Packaging component.
pom projen.java.Pom API for managing pom.xml.
junit projen.java.Junit JUnit component.
projenrc projen.java.Projenrc Projenrc component.
cdkConfig projen.awscdk.CdkConfig The cdk.json file.
cdkDeps projen.awscdk.AwsCdkDeps CDK dependency management helper class.
cdkTasks projen.awscdk.CdkTasks CDK tasks.
mainClass string The full name of the main class of the java app (package.Class).
mainClassName string The name of the Java class with the static main() method.
mainPackage string The name of the Java package that includes the main class.

nodeRequired
public readonly node: Node;

The tree node.


buildTaskRequired
public readonly buildTask: Task;

commitGeneratedRequired
public readonly commitGenerated: boolean;

Whether to commit the managed files by default.


compileTaskRequired
public readonly compileTask: Task;

componentsRequired
public readonly components: Component[];

Returns all the components within this project.


depsRequired
public readonly deps: Dependencies;

Project dependencies.


ejectedRequired
public readonly ejected: boolean;

Whether or not the project is being ejected.


filesRequired
public readonly files: FileBase[];

All files in this project.


gitattributesRequired
public readonly gitattributes: GitAttributesFile;

The .gitattributes file for this repository.


gitignoreRequired
public readonly gitignore: IgnoreFile;

.gitignore.


loggerRequired
public readonly logger: Logger;

Logging utilities.


nameRequired
public readonly name: string;

Project name.


outdirRequired
public readonly outdir: string;

Absolute output directory of this project.


packageTaskRequired
public readonly packageTask: Task;

postCompileTaskRequired
public readonly postCompileTask: Task;

preCompileTaskRequired
public readonly preCompileTask: Task;

projectBuildRequired
public readonly projectBuild: ProjectBuild;

Manages the build process of the project.


projenCommandRequired
public readonly projenCommand: string;

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


rootRequired
public readonly root: Project;

The root project.


subprojectsRequired
public readonly subprojects: Project[];

Returns all the subprojects within this project.


tasksRequired
public readonly tasks: Tasks;

Project tasks.


testTaskRequired
public readonly testTask: Task;

defaultTaskOptional
public readonly defaultTask: Task;

This is the “default” task, the one that executes “projen”.

Undefined if the project is being ejected.


initProjectOptional
public readonly initProject: InitProject;

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

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


parentOptional
public readonly parent: Project;

A parent project.

If undefined, this is the root project.


projectTypeRequired
public readonly projectType: ProjectType;

autoApproveOptional
public readonly autoApprove: AutoApprove;

Auto approve set up for this project.


devContainerOptional
public readonly devContainer: DevContainer;

Access for .devcontainer.json (used for GitHub Codespaces).

This will be undefined if devContainer boolean is false


githubOptional
public readonly github: GitHub;

Access all github components.

This will be undefined for subprojects.


gitpodOptional
public readonly gitpod: Gitpod;

Access for Gitpod.

This will be undefined if gitpod boolean is false


vscodeOptional
public readonly vscode: VsCode;

Access all VSCode components.

This will be undefined for subprojects.


compileRequired
public readonly compile: MavenCompile;

Compile component.


distdirRequired
public readonly distdir: string;

Maven artifact output directory.


packagingRequired
public readonly packaging: MavenPackaging;

Packaging component.


pomRequired
public readonly pom: Pom;

API for managing pom.xml.


junitOptional
public readonly junit: Junit;

JUnit component.


projenrcOptional
public readonly projenrc: Projenrc;

Projenrc component.


cdkConfigRequired
public readonly cdkConfig: CdkConfig;

The cdk.json file.


cdkDepsRequired
public readonly cdkDeps: AwsCdkDeps;

CDK dependency management helper class.


cdkTasksRequired
public readonly cdkTasks: CdkTasks;

CDK tasks.


mainClassRequired
public readonly mainClass: string;

The full name of the main class of the java app (package.Class).


mainClassNameRequired
public readonly mainClassName: string;

The name of the Java class with the static main() method.


mainPackageRequired
public readonly mainPackage: string;

The name of the Java package that includes the main class.


Constants

Name Type Description
DEFAULT_TASK string The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
public readonly DEFAULT_TASK: string;

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

Normally this task should synthesize the project files.


AwsCdkPythonApp

AWS CDK app in Python.

Initializers

import { awscdk } from 'projen'

new awscdk.AwsCdkPythonApp(options: AwsCdkPythonAppOptions)
Name Type Description
options projen.awscdk.AwsCdkPythonAppOptions No description.

optionsRequired

Methods

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

toString
public toString(): string

Returns a string representation of this construct.

addExcludeFromCleanup
public addExcludeFromCleanup(globs: string): void

Exclude the matching files from pre-synth cleanup.

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

globsRequired

The glob patterns to match.


addGitIgnore
public addGitIgnore(pattern: string): void

Adds a .gitignore pattern.

patternRequired

The glob pattern to ignore.


addPackageIgnore
public addPackageIgnore(_pattern: string): void

Exclude these files from the bundled package.

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

_patternRequired

The glob pattern to exclude.


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

Adds a new task to this project.

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

nameRequired

The task name to add.


propsOptional

Task properties.


addTip
public addTip(message: string): void

Prints a “tip” message during synthesis.

messageRequired

The message.


annotateGenerated
public annotateGenerated(glob: string): void

Marks the provided file(s) as being generated.

This is achieved using the github-linguist attributes. Generated files do not count against the repository statistics and language breakdown.

https://github.com/github/linguist/blob/master/docs/overrides.md

globRequired

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


postSynthesize
public postSynthesize(): void

Called after all components are synthesized.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before all components are synthesized.

removeTask
public removeTask(name: string): Task

Removes a task from a project.

nameRequired

The name of the task to remove.


runTaskCommand
public runTaskCommand(task: Task): string

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

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

taskRequired

The task for which the command is required.


synth
public synth(): void

Synthesize all project files into outdir.

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

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

filePathRequired

The file path.

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


tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile

Finds a json file by name.

filePathRequired

The file path.


tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile

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

filePathRequired

The file path.


tryRemoveFile
public tryRemoveFile(filePath: string): FileBase

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

filePathRequired

The file path.

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


addDependency
public addDependency(spec: string): void

Adds a runtime dependency.

specRequired

Format <module>@<semver>.


addDevDependency
public addDevDependency(spec: string): void

Adds a dev dependency.

specRequired

Format <module>@<semver>.


Static Functions

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

isConstruct
import { awscdk } from 'projen'

awscdk.AwsCdkPythonApp.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isProject
import { awscdk } from 'projen'

awscdk.AwsCdkPythonApp.isProject(x: any)

Test whether the given construct is a project.

xRequired

of
import { awscdk } from 'projen'

awscdk.AwsCdkPythonApp.of(construct: IConstruct)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired

Properties

Name Type Description
node constructs.Node The tree node.
buildTask Task No description.
commitGenerated boolean Whether to commit the managed files by default.
compileTask Task No description.
components Component[] Returns all the components within this project.
deps Dependencies Project dependencies.
ejected boolean Whether or not the project is being ejected.
files FileBase[] All files in this project.
gitattributes GitAttributesFile The .gitattributes file for this repository.
gitignore IgnoreFile .gitignore.
logger Logger Logging utilities.
name string Project name.
outdir string Absolute output directory of this project.
packageTask Task No description.
postCompileTask Task No description.
preCompileTask Task No description.
projectBuild ProjectBuild Manages the build process of the project.
projenCommand string The command to use in order to run the projen CLI.
root Project The root project.
subprojects Project[] Returns all the subprojects within this project.
tasks Tasks Project tasks.
testTask Task No description.
defaultTask Task This is the “default” task, the one that executes “projen”.
initProject InitProject The options used when this project is bootstrapped via projen new.
parent Project A parent project.
projectType ProjectType No description.
autoApprove projen.github.AutoApprove Auto approve set up for this project.
devContainer projen.vscode.DevContainer Access for .devcontainer.json (used for GitHub Codespaces).
github projen.github.GitHub Access all github components.
gitpod Gitpod Access for Gitpod.
vscode projen.vscode.VsCode Access all VSCode components.
depsManager projen.python.IPythonDeps API for managing dependencies.
envManager projen.python.IPythonEnv API for mangaging the Python runtime environment.
moduleName string Python module name (the project name, with any hyphens or periods replaced with underscores).
version string Version of the package for distribution (should follow semver).
packagingManager projen.python.IPythonPackaging API for managing packaging the project as a library.
pytest projen.python.Pytest Pytest component.
appEntrypoint string The CDK app entrypoint.
cdkConfig projen.awscdk.CdkConfig cdk.json configuration.
cdkDeps projen.awscdk.AwsCdkDeps No description.
cdkTasks projen.awscdk.CdkTasks Common CDK tasks.
cdkVersion string The CDK version this app is using.
testdir string The directory in which the python tests reside.

nodeRequired
public readonly node: Node;

The tree node.


buildTaskRequired
public readonly buildTask: Task;

commitGeneratedRequired
public readonly commitGenerated: boolean;

Whether to commit the managed files by default.


compileTaskRequired
public readonly compileTask: Task;

componentsRequired
public readonly components: Component[];

Returns all the components within this project.


depsRequired
public readonly deps: Dependencies;

Project dependencies.


ejectedRequired
public readonly ejected: boolean;

Whether or not the project is being ejected.


filesRequired
public readonly files: FileBase[];

All files in this project.


gitattributesRequired
public readonly gitattributes: GitAttributesFile;

The .gitattributes file for this repository.


gitignoreRequired
public readonly gitignore: IgnoreFile;

.gitignore.


loggerRequired
public readonly logger: Logger;

Logging utilities.


nameRequired
public readonly name: string;

Project name.


outdirRequired
public readonly outdir: string;

Absolute output directory of this project.


packageTaskRequired
public readonly packageTask: Task;

postCompileTaskRequired
public readonly postCompileTask: Task;

preCompileTaskRequired
public readonly preCompileTask: Task;

projectBuildRequired
public readonly projectBuild: ProjectBuild;

Manages the build process of the project.


projenCommandRequired
public readonly projenCommand: string;

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


rootRequired
public readonly root: Project;

The root project.


subprojectsRequired
public readonly subprojects: Project[];

Returns all the subprojects within this project.


tasksRequired
public readonly tasks: Tasks;

Project tasks.


testTaskRequired
public readonly testTask: Task;

defaultTaskOptional
public readonly defaultTask: Task;

This is the “default” task, the one that executes “projen”.

Undefined if the project is being ejected.


initProjectOptional
public readonly initProject: InitProject;

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

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


parentOptional
public readonly parent: Project;

A parent project.

If undefined, this is the root project.


projectTypeRequired
public readonly projectType: ProjectType;

autoApproveOptional
public readonly autoApprove: AutoApprove;

Auto approve set up for this project.


devContainerOptional
public readonly devContainer: DevContainer;

Access for .devcontainer.json (used for GitHub Codespaces).

This will be undefined if devContainer boolean is false


githubOptional
public readonly github: GitHub;

Access all github components.

This will be undefined for subprojects.


gitpodOptional
public readonly gitpod: Gitpod;

Access for Gitpod.

This will be undefined if gitpod boolean is false


vscodeOptional
public readonly vscode: VsCode;

Access all VSCode components.

This will be undefined for subprojects.


depsManagerRequired
public readonly depsManager: IPythonDeps;

API for managing dependencies.


envManagerRequired
public readonly envManager: IPythonEnv;

API for mangaging the Python runtime environment.


moduleNameRequired
public readonly moduleName: string;

Python module name (the project name, with any hyphens or periods replaced with underscores).


versionRequired
public readonly version: string;

Version of the package for distribution (should follow semver).


packagingManagerOptional
public readonly packagingManager: IPythonPackaging;

API for managing packaging the project as a library.

Only applies when the projectType is LIB.


pytestOptional
public readonly pytest: Pytest;

Pytest component.


appEntrypointRequired
public readonly appEntrypoint: string;

The CDK app entrypoint.


cdkConfigRequired
public readonly cdkConfig: CdkConfig;

cdk.json configuration.


cdkDepsRequired
public readonly cdkDeps: AwsCdkDeps;

cdkTasksRequired
public readonly cdkTasks: CdkTasks;

Common CDK tasks.


cdkVersionRequired
public readonly cdkVersion: string;

The CDK version this app is using.


testdirRequired
public readonly testdir: string;

The directory in which the python tests reside.


Constants

Name Type Description
DEFAULT_TASK string The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
public readonly DEFAULT_TASK: string;

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

Normally this task should synthesize the project files.


AwsCdkTypeScriptApp

AWS CDK app in TypeScript.

Initializers

import { awscdk } from 'projen'

new awscdk.AwsCdkTypeScriptApp(options: AwsCdkTypeScriptAppOptions)
Name Type Description
options projen.awscdk.AwsCdkTypeScriptAppOptions No description.

optionsRequired

Methods

Name Description
toString Returns a string representation of this construct.
addExcludeFromCleanup Exclude the matching files from pre-synth cleanup.
addGitIgnore Adds a .gitignore pattern.
addPackageIgnore Exclude these files from the bundled package.
addTask Adds a new task to this project.
addTip Prints a “tip” message during synthesis.
annotateGenerated Marks the provided file(s) as being generated.
postSynthesize Called after all components are synthesized.
preSynthesize Called before all components are synthesized.
removeTask Removes a task from a project.
runTaskCommand Returns the shell command to execute in order to run a task.
synth Synthesize all project files into outdir.
tryFindFile Finds a file at the specified relative path within this project and all its subprojects.
tryFindJsonFile Finds a json file by name.
tryFindObjectFile Finds an object file (like JsonFile, YamlFile, etc.) by name.
tryRemoveFile Finds a file at the specified relative path within this project and removes it.
addBins No description.
addBundledDeps Defines bundled dependencies.
addCompileCommand DEPRECATED.
addDeps Defines normal dependencies.
addDevDeps Defines development/test dependencies.
addFields Directly set fields in package.json.
addKeywords Adds keywords to package.json (deduplicated).
addPeerDeps Defines peer dependencies.
addScripts Replaces the contents of multiple npm package.json scripts.
addTestCommand DEPRECATED.
hasScript Indicates if a script by the name name is defined.
removeScript Removes the npm script (always successful).
renderWorkflowSetup Returns the set of workflow steps which should be executed to bootstrap a workflow.
setScript Replaces the contents of an npm package.json script.
addCdkDependency Adds an AWS CDK module dependencies.

toString
public toString(): string

Returns a string representation of this construct.

addExcludeFromCleanup
public addExcludeFromCleanup(globs: string): void

Exclude the matching files from pre-synth cleanup.

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

globsRequired

The glob patterns to match.


addGitIgnore
public addGitIgnore(pattern: string): void

Adds a .gitignore pattern.

patternRequired

The glob pattern to ignore.


addPackageIgnore
public addPackageIgnore(pattern: string): void

Exclude these files from the bundled package.

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

patternRequired

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

Adds a new task to this project.

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

nameRequired

The task name to add.


propsOptional

Task properties.


addTip
public addTip(message: string): void

Prints a “tip” message during synthesis.

messageRequired

The message.


annotateGenerated
public annotateGenerated(glob: string): void

Marks the provided file(s) as being generated.

This is achieved using the github-linguist attributes. Generated files do not count against the repository statistics and language breakdown.

https://github.com/github/linguist/blob/master/docs/overrides.md

globRequired

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


postSynthesize
public postSynthesize(): void

Called after all components are synthesized.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before all components are synthesized.

removeTask
public removeTask(name: string): Task

Removes a task from a project.

nameRequired

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.

This will typically be npx projen TASK.

taskRequired

The task for which the command is required.


synth
public synth(): void

Synthesize all project files into outdir.

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

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

filePathRequired

The file path.

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


tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile

Finds a json file by name.

filePathRequired

The file path.


tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile

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

filePathRequired

The file path.


tryRemoveFile
public tryRemoveFile(filePath: string): FileBase

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

filePathRequired

The file path.

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


addBins
public addBins(bins: {[ key: string ]: string}): void
binsRequired

addBundledDeps
public addBundledDeps(deps: string): void

Defines bundled dependencies.

Bundled dependencies will be added as normal dependencies as well as to the bundledDependencies section of your package.json.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addCompileCommand
public addCompileCommand(commands: string): void

DEPRECATED.

commandsRequired

addDeps
public addDeps(deps: string): void

Defines normal dependencies.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addDevDeps
public addDevDeps(deps: string): void

Defines development/test dependencies.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addFields
public addFields(fields: {[ key: string ]: any}): void

Directly set fields in package.json.

fieldsRequired

The fields to set.


addKeywords
public addKeywords(keywords: string): void

Adds keywords to package.json (deduplicated).

keywordsRequired

The keywords to add.


addPeerDeps
public addPeerDeps(deps: string): void

Defines peer dependencies.

When adding peer dependencies, a devDependency will also be added on the pinned version of the declared peer. This will ensure that you are testing your code against the minimum version required from your consumers.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addScripts
public addScripts(scripts: {[ key: string ]: string}): void

Replaces the contents of multiple npm package.json scripts.

scriptsRequired

The scripts to set.


addTestCommand
public addTestCommand(commands: string): void

DEPRECATED.

commandsRequired

hasScript
public hasScript(name: string): boolean

Indicates if a script by the name name is defined.

nameRequired

The name of the script.


removeScript
public removeScript(name: string): void

Removes the npm script (always successful).

nameRequired

The name of the script.


renderWorkflowSetup
public renderWorkflowSetup(options?: RenderWorkflowSetupOptions): JobStep[]

Returns the set of workflow steps which should be executed to bootstrap a workflow.

optionsOptional

Options.


setScript
public setScript(name: string, command: string): void

Replaces the contents of an npm package.json script.

nameRequired

The script name.


commandRequired

The command to execute.


addCdkDependency
public addCdkDependency(modules: string): void

Adds an AWS CDK module dependencies.

modulesRequired

The list of modules to depend on.


Static Functions

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

isConstruct
import { awscdk } from 'projen'

awscdk.AwsCdkTypeScriptApp.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isProject
import { awscdk } from 'projen'

awscdk.AwsCdkTypeScriptApp.isProject(x: any)

Test whether the given construct is a project.

xRequired

of
import { awscdk } from 'projen'

awscdk.AwsCdkTypeScriptApp.of(construct: IConstruct)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired

Properties

Name Type Description
node constructs.Node The tree node.
buildTask Task No description.
commitGenerated boolean Whether to commit the managed files by default.
compileTask Task No description.
components Component[] Returns all the components within this project.
deps Dependencies Project dependencies.
ejected boolean Whether or not the project is being ejected.
files FileBase[] All files in this project.
gitattributes GitAttributesFile The .gitattributes file for this repository.
gitignore IgnoreFile .gitignore.
logger Logger Logging utilities.
name string Project name.
outdir string Absolute output directory of this project.
packageTask Task No description.
postCompileTask Task No description.
preCompileTask Task No description.
projectBuild ProjectBuild Manages the build process of the project.
projenCommand string The command to use in order to run the projen CLI.
root Project The root project.
subprojects Project[] Returns all the subprojects within this project.
tasks Tasks Project tasks.
testTask Task No description.
defaultTask Task This is the “default” task, the one that executes “projen”.
initProject InitProject The options used when this project is bootstrapped via projen new.
parent Project A parent project.
projectType ProjectType No description.
autoApprove projen.github.AutoApprove Auto approve set up for this project.
devContainer projen.vscode.DevContainer Access for .devcontainer.json (used for GitHub Codespaces).
github projen.github.GitHub Access all github components.
gitpod Gitpod Access for Gitpod.
vscode projen.vscode.VsCode Access all VSCode components.
allowLibraryDependencies boolean No description.
artifactsDirectory string The build output directory.
artifactsJavascriptDirectory string The location of the npm tarball after build (${artifactsDirectory}/js).
bundler projen.javascript.Bundler No description.
entrypoint string No description.
manifest any No description.
npmrc projen.javascript.NpmConfig The .npmrc file.
package projen.javascript.NodePackage API for managing the node package.
packageManager projen.javascript.NodePackageManager The package manager to use.
runScriptCommand string The command to use to run scripts (e.g. yarn run or npm run depends on the package manager).
autoMerge projen.github.AutoMerge Component that sets up mergify for merging approved pull requests.
buildWorkflow projen.build.BuildWorkflow The PR build GitHub workflow.
buildWorkflowJobId string The job ID of the build workflow.
jest projen.javascript.Jest The Jest configuration (if enabled).
maxNodeVersion string Maximum node version required by this package.
minNodeVersion string Minimum node.js version required by this package.
npmignore IgnoreFile The .npmignore file.
prettier projen.javascript.Prettier No description.
publisher projen.release.Publisher Package publisher.
release projen.release.Release Release management.
upgradeWorkflow projen.javascript.UpgradeDependencies The upgrade workflow.
docsDirectory string No description.
libdir string The directory in which compiled .js files reside.
srcdir string The directory in which the .ts sources reside.
testdir string The directory in which tests reside.
tsconfigDev projen.javascript.TypescriptConfig A typescript configuration file which covers all files (sources, tests, projen).
watchTask Task The “watch” task.
docgen boolean No description.
eslint projen.javascript.Eslint No description.
tsconfig projen.javascript.TypescriptConfig No description.
tsconfigEslint projen.javascript.TypescriptConfig No description.
appEntrypoint string The CDK app entrypoint.
cdkConfig projen.awscdk.CdkConfig cdk.json configuration.
cdkDeps projen.awscdk.AwsCdkDeps No description.
cdkTasks projen.awscdk.CdkTasks Common CDK tasks.
cdkVersion string The CDK version this app is using.

nodeRequired
public readonly node: Node;

The tree node.


buildTaskRequired
public readonly buildTask: Task;

commitGeneratedRequired
public readonly commitGenerated: boolean;

Whether to commit the managed files by default.


compileTaskRequired
public readonly compileTask: Task;

componentsRequired
public readonly components: Component[];

Returns all the components within this project.


depsRequired
public readonly deps: Dependencies;

Project dependencies.


ejectedRequired
public readonly ejected: boolean;

Whether or not the project is being ejected.


filesRequired
public readonly files: FileBase[];

All files in this project.


gitattributesRequired
public readonly gitattributes: GitAttributesFile;

The .gitattributes file for this repository.


gitignoreRequired
public readonly gitignore: IgnoreFile;

.gitignore.


loggerRequired
public readonly logger: Logger;

Logging utilities.


nameRequired
public readonly name: string;

Project name.


outdirRequired
public readonly outdir: string;

Absolute output directory of this project.


packageTaskRequired
public readonly packageTask: Task;

postCompileTaskRequired
public readonly postCompileTask: Task;

preCompileTaskRequired
public readonly preCompileTask: Task;

projectBuildRequired
public readonly projectBuild: ProjectBuild;

Manages the build process of the project.


projenCommandRequired
public readonly projenCommand: string;

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


rootRequired
public readonly root: Project;

The root project.


subprojectsRequired
public readonly subprojects: Project[];

Returns all the subprojects within this project.


tasksRequired
public readonly tasks: Tasks;

Project tasks.


testTaskRequired
public readonly testTask: Task;

defaultTaskOptional
public readonly defaultTask: Task;

This is the “default” task, the one that executes “projen”.

Undefined if the project is being ejected.


initProjectOptional
public readonly initProject: InitProject;

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

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


parentOptional
public readonly parent: Project;

A parent project.

If undefined, this is the root project.


projectTypeRequired
public readonly projectType: ProjectType;

autoApproveOptional
public readonly autoApprove: AutoApprove;

Auto approve set up for this project.


devContainerOptional
public readonly devContainer: DevContainer;

Access for .devcontainer.json (used for GitHub Codespaces).

This will be undefined if devContainer boolean is false


githubOptional
public readonly github: GitHub;

Access all github components.

This will be undefined for subprojects.


gitpodOptional
public readonly gitpod: Gitpod;

Access for Gitpod.

This will be undefined if gitpod boolean is false


vscodeOptional
public readonly vscode: VsCode;

Access all VSCode components.

This will be undefined for subprojects.


allowLibraryDependenciesRequired
public readonly allowLibraryDependencies: boolean;

artifactsDirectoryRequired
public readonly artifactsDirectory: string;

The build output directory.

An npm tarball will be created under the js subdirectory. For example, if this is set to dist (the default), the npm tarball will be placed under dist/js/boom-boom-1.2.3.tg.


artifactsJavascriptDirectoryRequired
public readonly artifactsJavascriptDirectory: string;

The location of the npm tarball after build (${artifactsDirectory}/js).


bundlerRequired
public readonly bundler: Bundler;

entrypointRequired
public readonly entrypoint: string;

manifestRequired
public readonly manifest: any;

npmrcRequired
public readonly npmrc: NpmConfig;

The .npmrc file.


packageRequired
public readonly package: NodePackage;

API for managing the node package.


packageManagerRequired
public readonly packageManager: NodePackageManager;

The package manager to use.


runScriptCommandRequired
public readonly runScriptCommand: string;

The command to use to run scripts (e.g. yarn run or npm run depends on the package manager).


autoMergeOptional
public readonly autoMerge: AutoMerge;

Component that sets up mergify for merging approved pull requests.


buildWorkflowOptional
public readonly buildWorkflow: BuildWorkflow;

The PR build GitHub workflow.

undefined if buildWorkflow is disabled.


buildWorkflowJobIdOptional
public readonly buildWorkflowJobId: string;

The job ID of the build workflow.


jestOptional
public readonly jest: Jest;

The Jest configuration (if enabled).


maxNodeVersionOptional
public readonly maxNodeVersion: string;

Maximum node version required by this package.


minNodeVersionOptional
public readonly minNodeVersion: string;

Minimum node.js version required by this package.


npmignoreOptional
public readonly npmignore: IgnoreFile;

The .npmignore file.


prettierOptional
public readonly prettier: Prettier;

publisherOptional
public readonly publisher: Publisher;

Package publisher.

This will be undefined if the project does not have a release workflow.


releaseOptional
public readonly release: Release;

Release management.


upgradeWorkflowOptional
public readonly upgradeWorkflow: UpgradeDependencies;

The upgrade workflow.


docsDirectoryRequired
public readonly docsDirectory: string;

libdirRequired
public readonly libdir: string;

The directory in which compiled .js files reside.


srcdirRequired
public readonly srcdir: string;

The directory in which the .ts sources reside.


testdirRequired
public readonly testdir: string;

The directory in which tests reside.


tsconfigDevRequired
public readonly tsconfigDev: TypescriptConfig;

A typescript configuration file which covers all files (sources, tests, projen).


watchTaskRequired
public readonly watchTask: Task;

The “watch” task.


docgenOptional
public readonly docgen: boolean;

eslintOptional
public readonly eslint: Eslint;

tsconfigOptional
public readonly tsconfig: TypescriptConfig;

tsconfigEslintOptional
public readonly tsconfigEslint: TypescriptConfig;

appEntrypointRequired
public readonly appEntrypoint: string;

The CDK app entrypoint.


cdkConfigRequired
public readonly cdkConfig: CdkConfig;

cdk.json configuration.


cdkDepsRequired
public readonly cdkDeps: AwsCdkDeps;

cdkTasksRequired
public readonly cdkTasks: CdkTasks;

Common CDK tasks.


cdkVersionRequired
public readonly cdkVersion: string;

The CDK version this app is using.


Constants

Name Type Description
DEFAULT_TASK string The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
public readonly DEFAULT_TASK: string;

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

Normally this task should synthesize the project files.


BuildWorkflow

Initializers

import { build } from 'projen'

new build.BuildWorkflow(project: Project, options: BuildWorkflowOptions)
Name Type Description
project Project No description.
options projen.build.BuildWorkflowOptions No description.

projectRequired

optionsRequired

Methods

Name Description
toString Returns a string representation of this construct.
postSynthesize Called after synthesis.
preSynthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.
addPostBuildJob Adds another job to the build workflow which is executed after the build job succeeded.
addPostBuildJobCommands Run a sequence of commands as a job within the build workflow which is executed after the build job succeeded.
addPostBuildJobTask Run a task as a job within the build workflow which is executed after the build job succeeded.
addPostBuildSteps Adds steps that are executed after the build.

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.

addPostBuildJob
public addPostBuildJob(id: string, job: Job): void

Adds another job to the build workflow which is executed after the build job succeeded.

Jobs are executed only if the build did NOT self mutate. If the build self-mutate, the branch will either be updated or the build will fail (in forks), so there is no point in executing the post-build job.

idRequired

The id of the new job.


jobRequired

The job specification.


addPostBuildJobCommands
public addPostBuildJobCommands(id: string, commands: string[], options?: AddPostBuildJobCommandsOptions): void

Run a sequence of commands as a job within the build workflow which is executed after the build job succeeded.

Jobs are executed only if the build did NOT self mutate. If the build self-mutate, the branch will either be updated or the build will fail (in forks), so there is no point in executing the post-build job.

idRequired

commandsRequired

optionsOptional

Specify tools and other options.


addPostBuildJobTask
public addPostBuildJobTask(task: Task, options?: AddPostBuildJobTaskOptions): void

Run a task as a job within the build workflow which is executed after the build job succeeded.

The job will have access to build artifacts and will install project dependencies in order to be able to run any commands used in the tasks.

Jobs are executed only if the build did NOT self mutate. If the build self-mutate, the branch will either be updated or the build will fail (in forks), so there is no point in executing the post-build job.

taskRequired

optionsOptional

Specify tools and other options.


addPostBuildSteps
public addPostBuildSteps(steps: JobStep): void

Adds steps that are executed after the build.

stepsRequired

The job steps.


Static Functions

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

isConstruct
import { build } from 'projen'

build.BuildWorkflow.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { build } from 'projen'

build.BuildWorkflow.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.
buildJobIds string[] Returns a list of job IDs that are part of the build.

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

buildJobIdsRequired
public readonly buildJobIds: string[];

Returns a list of job IDs that are part of the build.


Bundler

Adds support for bundling JavaScript applications and dependencies into a single file.

In the future, this will also supports bundling websites.

Initializers

import { javascript } from 'projen'

new javascript.Bundler(project: Project, options?: BundlerOptions)
Name Type Description
project Project No description.
options projen.javascript.BundlerOptions No description.

projectRequired

optionsOptional

Methods

Name Description
toString Returns a string representation of this construct.
postSynthesize Called after synthesis.
preSynthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.
addBundle Adds a task to the project which bundles a specific entrypoint and all of its dependencies into a single javascript output 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.

addBundle
public addBundle(entrypoint: string, options: AddBundleOptions): Bundle

Adds a task to the project which bundles a specific entrypoint and all of its dependencies into a single javascript output file.

entrypointRequired

The relative path of the artifact within the project.


optionsRequired

Bundling options.


Static Functions

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

isConstruct
import { javascript } from 'projen'

javascript.Bundler.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { javascript } from 'projen'

javascript.Bundler.isComponent(x: any)

Test whether the given construct is a component.

xRequired

of
import { javascript } from 'projen'

javascript.Bundler.of(project: Project)

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

projectRequired

The project.


Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.
bundledir string Root bundle directory.
bundleTask Task Gets or creates the singleton “bundle” task of the project.
esbuildVersion string The semantic version requirement for esbuild (if defined).

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

bundledirRequired
public readonly bundledir: string;

Root bundle directory.


bundleTaskRequired
public readonly bundleTask: Task;

Gets or creates the singleton “bundle” task of the project.

If the project doesn’t have a “bundle” task, it will be created and spawned during the pre-compile phase.


esbuildVersionOptional
public readonly esbuildVersion: string;

The semantic version requirement for esbuild (if defined).


Cdk8sDeps

Manages dependencies on the CDK8s.

Initializers

import { cdk8s } from 'projen'

new cdk8s.Cdk8sDeps(project: Project, options: Cdk8sDepsOptions)
Name Type Description
project Project No description.
options projen.cdk8s.Cdk8sDepsOptions No description.

projectRequired

optionsRequired

Methods

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

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

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

isConstruct
import { cdk8s } from 'projen'

cdk8s.Cdk8sDeps.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { cdk8s } from 'projen'

cdk8s.Cdk8sDeps.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.
cdk8sMajorVersion number The major version of the CDK8s (e.g. 1, 2, …).
cdk8sMinimumVersion string The minimum version of the CDK8s (e.g. 2.0.0).
cdk8sVersion string The dependency requirement for CDK8s.

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

cdk8sMajorVersionRequired
public readonly cdk8sMajorVersion: number;

The major version of the CDK8s (e.g. 1, 2, …).


cdk8sMinimumVersionRequired
public readonly cdk8sMinimumVersion: string;

The minimum version of the CDK8s (e.g. 2.0.0).


cdk8sVersionRequired
public readonly cdk8sVersion: string;

The dependency requirement for CDK8s.


Cdk8sDepsPy

Initializers

import { cdk8s } from 'projen'

new cdk8s.Cdk8sDepsPy(project: Project, options: Cdk8sDepsOptions)
Name Type Description
project Project No description.
options projen.cdk8s.Cdk8sDepsOptions No description.

projectRequired

optionsRequired

Methods

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

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

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

isConstruct
import { cdk8s } from 'projen'

cdk8s.Cdk8sDepsPy.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { cdk8s } from 'projen'

cdk8s.Cdk8sDepsPy.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.
cdk8sMajorVersion number The major version of the CDK8s (e.g. 1, 2, …).
cdk8sMinimumVersion string The minimum version of the CDK8s (e.g. 2.0.0).
cdk8sVersion string The dependency requirement for CDK8s.

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

cdk8sMajorVersionRequired
public readonly cdk8sMajorVersion: number;

The major version of the CDK8s (e.g. 1, 2, …).


cdk8sMinimumVersionRequired
public readonly cdk8sMinimumVersion: string;

The minimum version of the CDK8s (e.g. 2.0.0).


cdk8sVersionRequired
public readonly cdk8sVersion: string;

The dependency requirement for CDK8s.


Cdk8sPythonApp

CDK8s app in Python.

Initializers

import { cdk8s } from 'projen'

new cdk8s.Cdk8sPythonApp(options: Cdk8sPythonOptions)
Name Type Description
options projen.cdk8s.Cdk8sPythonOptions No description.

optionsRequired

Methods

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

toString
public toString(): string

Returns a string representation of this construct.

addExcludeFromCleanup
public addExcludeFromCleanup(globs: string): void

Exclude the matching files from pre-synth cleanup.

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

globsRequired

The glob patterns to match.


addGitIgnore
public addGitIgnore(pattern: string): void

Adds a .gitignore pattern.

patternRequired

The glob pattern to ignore.


addPackageIgnore
public addPackageIgnore(_pattern: string): void

Exclude these files from the bundled package.

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

_patternRequired

The glob pattern to exclude.


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

Adds a new task to this project.

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

nameRequired

The task name to add.


propsOptional

Task properties.


addTip
public addTip(message: string): void

Prints a “tip” message during synthesis.

messageRequired

The message.


annotateGenerated
public annotateGenerated(glob: string): void

Marks the provided file(s) as being generated.

This is achieved using the github-linguist attributes. Generated files do not count against the repository statistics and language breakdown.

https://github.com/github/linguist/blob/master/docs/overrides.md

globRequired

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


postSynthesize
public postSynthesize(): void

Called after all components are synthesized.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before all components are synthesized.

removeTask
public removeTask(name: string): Task

Removes a task from a project.

nameRequired

The name of the task to remove.


runTaskCommand
public runTaskCommand(task: Task): string

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

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

taskRequired

The task for which the command is required.


synth
public synth(): void

Synthesize all project files into outdir.

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

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

filePathRequired

The file path.

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


tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile

Finds a json file by name.

filePathRequired

The file path.


tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile

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

filePathRequired

The file path.


tryRemoveFile
public tryRemoveFile(filePath: string): FileBase

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

filePathRequired

The file path.

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


addDependency
public addDependency(spec: string): void

Adds a runtime dependency.

specRequired

Format <module>@<semver>.


addDevDependency
public addDevDependency(spec: string): void

Adds a dev dependency.

specRequired

Format <module>@<semver>.


Static Functions

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

isConstruct
import { cdk8s } from 'projen'

cdk8s.Cdk8sPythonApp.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isProject
import { cdk8s } from 'projen'

cdk8s.Cdk8sPythonApp.isProject(x: any)

Test whether the given construct is a project.

xRequired

of
import { cdk8s } from 'projen'

cdk8s.Cdk8sPythonApp.of(construct: IConstruct)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired

Properties

Name Type Description
node constructs.Node The tree node.
buildTask Task No description.
commitGenerated boolean Whether to commit the managed files by default.
compileTask Task No description.
components Component[] Returns all the components within this project.
deps Dependencies Project dependencies.
ejected boolean Whether or not the project is being ejected.
files FileBase[] All files in this project.
gitattributes GitAttributesFile The .gitattributes file for this repository.
gitignore IgnoreFile .gitignore.
logger Logger Logging utilities.
name string Project name.
outdir string Absolute output directory of this project.
packageTask Task No description.
postCompileTask Task No description.
preCompileTask Task No description.
projectBuild ProjectBuild Manages the build process of the project.
projenCommand string The command to use in order to run the projen CLI.
root Project The root project.
subprojects Project[] Returns all the subprojects within this project.
tasks Tasks Project tasks.
testTask Task No description.
defaultTask Task This is the “default” task, the one that executes “projen”.
initProject InitProject The options used when this project is bootstrapped via projen new.
parent Project A parent project.
projectType ProjectType No description.
autoApprove projen.github.AutoApprove Auto approve set up for this project.
devContainer projen.vscode.DevContainer Access for .devcontainer.json (used for GitHub Codespaces).
github projen.github.GitHub Access all github components.
gitpod Gitpod Access for Gitpod.
vscode projen.vscode.VsCode Access all VSCode components.
depsManager projen.python.IPythonDeps API for managing dependencies.
envManager projen.python.IPythonEnv API for mangaging the Python runtime environment.
moduleName string Python module name (the project name, with any hyphens or periods replaced with underscores).
version string Version of the package for distribution (should follow semver).
packagingManager projen.python.IPythonPackaging API for managing packaging the project as a library.
pytest projen.python.Pytest Pytest component.
appEntrypoint string The CDK8s app entrypoint.
cdk8sDeps projen.cdk8s.Cdk8sDeps No description.

nodeRequired
public readonly node: Node;

The tree node.


buildTaskRequired
public readonly buildTask: Task;

commitGeneratedRequired
public readonly commitGenerated: boolean;

Whether to commit the managed files by default.


compileTaskRequired
public readonly compileTask: Task;

componentsRequired
public readonly components: Component[];

Returns all the components within this project.


depsRequired
public readonly deps: Dependencies;

Project dependencies.


ejectedRequired
public readonly ejected: boolean;

Whether or not the project is being ejected.


filesRequired
public readonly files: FileBase[];

All files in this project.


gitattributesRequired
public readonly gitattributes: GitAttributesFile;

The .gitattributes file for this repository.


gitignoreRequired
public readonly gitignore: IgnoreFile;

.gitignore.


loggerRequired
public readonly logger: Logger;

Logging utilities.


nameRequired
public readonly name: string;

Project name.


outdirRequired
public readonly outdir: string;

Absolute output directory of this project.


packageTaskRequired
public readonly packageTask: Task;

postCompileTaskRequired
public readonly postCompileTask: Task;

preCompileTaskRequired
public readonly preCompileTask: Task;

projectBuildRequired
public readonly projectBuild: ProjectBuild;

Manages the build process of the project.


projenCommandRequired
public readonly projenCommand: string;

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


rootRequired
public readonly root: Project;

The root project.


subprojectsRequired
public readonly subprojects: Project[];

Returns all the subprojects within this project.


tasksRequired
public readonly tasks: Tasks;

Project tasks.


testTaskRequired
public readonly testTask: Task;

defaultTaskOptional
public readonly defaultTask: Task;

This is the “default” task, the one that executes “projen”.

Undefined if the project is being ejected.


initProjectOptional
public readonly initProject: InitProject;

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

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


parentOptional
public readonly parent: Project;

A parent project.

If undefined, this is the root project.


projectTypeRequired
public readonly projectType: ProjectType;

autoApproveOptional
public readonly autoApprove: AutoApprove;

Auto approve set up for this project.


devContainerOptional
public readonly devContainer: DevContainer;

Access for .devcontainer.json (used for GitHub Codespaces).

This will be undefined if devContainer boolean is false


githubOptional
public readonly github: GitHub;

Access all github components.

This will be undefined for subprojects.


gitpodOptional
public readonly gitpod: Gitpod;

Access for Gitpod.

This will be undefined if gitpod boolean is false


vscodeOptional
public readonly vscode: VsCode;

Access all VSCode components.

This will be undefined for subprojects.


depsManagerRequired
public readonly depsManager: IPythonDeps;

API for managing dependencies.


envManagerRequired
public readonly envManager: IPythonEnv;

API for mangaging the Python runtime environment.


moduleNameRequired
public readonly moduleName: string;

Python module name (the project name, with any hyphens or periods replaced with underscores).


versionRequired
public readonly version: string;

Version of the package for distribution (should follow semver).


packagingManagerOptional
public readonly packagingManager: IPythonPackaging;

API for managing packaging the project as a library.

Only applies when the projectType is LIB.


pytestOptional
public readonly pytest: Pytest;

Pytest component.


appEntrypointRequired
public readonly appEntrypoint: string;

The CDK8s app entrypoint.


cdk8sDepsRequired
public readonly cdk8sDeps: Cdk8sDeps;

Constants

Name Type Description
DEFAULT_TASK string The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
public readonly DEFAULT_TASK: string;

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

Normally this task should synthesize the project files.


Cdk8sTypeScriptApp

CDK8s app in TypeScript.

Initializers

import { cdk8s } from 'projen'

new cdk8s.Cdk8sTypeScriptApp(options: Cdk8sTypeScriptAppOptions)
Name Type Description
options projen.cdk8s.Cdk8sTypeScriptAppOptions No description.

optionsRequired

Methods

Name Description
toString Returns a string representation of this construct.
addExcludeFromCleanup Exclude the matching files from pre-synth cleanup.
addGitIgnore Adds a .gitignore pattern.
addPackageIgnore Exclude these files from the bundled package.
addTask Adds a new task to this project.
addTip Prints a “tip” message during synthesis.
annotateGenerated Marks the provided file(s) as being generated.
postSynthesize Called after all components are synthesized.
preSynthesize Called before all components are synthesized.
removeTask Removes a task from a project.
runTaskCommand Returns the shell command to execute in order to run a task.
synth Synthesize all project files into outdir.
tryFindFile Finds a file at the specified relative path within this project and all its subprojects.
tryFindJsonFile Finds a json file by name.
tryFindObjectFile Finds an object file (like JsonFile, YamlFile, etc.) by name.
tryRemoveFile Finds a file at the specified relative path within this project and removes it.
addBins No description.
addBundledDeps Defines bundled dependencies.
addCompileCommand DEPRECATED.
addDeps Defines normal dependencies.
addDevDeps Defines development/test dependencies.
addFields Directly set fields in package.json.
addKeywords Adds keywords to package.json (deduplicated).
addPeerDeps Defines peer dependencies.
addScripts Replaces the contents of multiple npm package.json scripts.
addTestCommand DEPRECATED.
hasScript Indicates if a script by the name name is defined.
removeScript Removes the npm script (always successful).
renderWorkflowSetup Returns the set of workflow steps which should be executed to bootstrap a workflow.
setScript Replaces the contents of an npm package.json script.

toString
public toString(): string

Returns a string representation of this construct.

addExcludeFromCleanup
public addExcludeFromCleanup(globs: string): void

Exclude the matching files from pre-synth cleanup.

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

globsRequired

The glob patterns to match.


addGitIgnore
public addGitIgnore(pattern: string): void

Adds a .gitignore pattern.

patternRequired

The glob pattern to ignore.


addPackageIgnore
public addPackageIgnore(pattern: string): void

Exclude these files from the bundled package.

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

patternRequired

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

Adds a new task to this project.

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

nameRequired

The task name to add.


propsOptional

Task properties.


addTip
public addTip(message: string): void

Prints a “tip” message during synthesis.

messageRequired

The message.


annotateGenerated
public annotateGenerated(glob: string): void

Marks the provided file(s) as being generated.

This is achieved using the github-linguist attributes. Generated files do not count against the repository statistics and language breakdown.

https://github.com/github/linguist/blob/master/docs/overrides.md

globRequired

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


postSynthesize
public postSynthesize(): void

Called after all components are synthesized.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before all components are synthesized.

removeTask
public removeTask(name: string): Task

Removes a task from a project.

nameRequired

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.

This will typically be npx projen TASK.

taskRequired

The task for which the command is required.


synth
public synth(): void

Synthesize all project files into outdir.

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

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

filePathRequired

The file path.

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


tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile

Finds a json file by name.

filePathRequired

The file path.


tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile

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

filePathRequired

The file path.


tryRemoveFile
public tryRemoveFile(filePath: string): FileBase

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

filePathRequired

The file path.

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


addBins
public addBins(bins: {[ key: string ]: string}): void
binsRequired

addBundledDeps
public addBundledDeps(deps: string): void

Defines bundled dependencies.

Bundled dependencies will be added as normal dependencies as well as to the bundledDependencies section of your package.json.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addCompileCommand
public addCompileCommand(commands: string): void

DEPRECATED.

commandsRequired

addDeps
public addDeps(deps: string): void

Defines normal dependencies.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addDevDeps
public addDevDeps(deps: string): void

Defines development/test dependencies.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addFields
public addFields(fields: {[ key: string ]: any}): void

Directly set fields in package.json.

fieldsRequired

The fields to set.


addKeywords
public addKeywords(keywords: string): void

Adds keywords to package.json (deduplicated).

keywordsRequired

The keywords to add.


addPeerDeps
public addPeerDeps(deps: string): void

Defines peer dependencies.

When adding peer dependencies, a devDependency will also be added on the pinned version of the declared peer. This will ensure that you are testing your code against the minimum version required from your consumers.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addScripts
public addScripts(scripts: {[ key: string ]: string}): void

Replaces the contents of multiple npm package.json scripts.

scriptsRequired

The scripts to set.


addTestCommand
public addTestCommand(commands: string): void

DEPRECATED.

commandsRequired

hasScript
public hasScript(name: string): boolean

Indicates if a script by the name name is defined.

nameRequired

The name of the script.


removeScript
public removeScript(name: string): void

Removes the npm script (always successful).

nameRequired

The name of the script.


renderWorkflowSetup
public renderWorkflowSetup(options?: RenderWorkflowSetupOptions): JobStep[]

Returns the set of workflow steps which should be executed to bootstrap a workflow.

optionsOptional

Options.


setScript
public setScript(name: string, command: string): void

Replaces the contents of an npm package.json script.

nameRequired

The script name.


commandRequired

The command to execute.


Static Functions

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

isConstruct
import { cdk8s } from 'projen'

cdk8s.Cdk8sTypeScriptApp.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isProject
import { cdk8s } from 'projen'

cdk8s.Cdk8sTypeScriptApp.isProject(x: any)

Test whether the given construct is a project.

xRequired

of
import { cdk8s } from 'projen'

cdk8s.Cdk8sTypeScriptApp.of(construct: IConstruct)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired

Properties

Name Type Description
node constructs.Node The tree node.
buildTask Task No description.
commitGenerated boolean Whether to commit the managed files by default.
compileTask Task No description.
components Component[] Returns all the components within this project.
deps Dependencies Project dependencies.
ejected boolean Whether or not the project is being ejected.
files FileBase[] All files in this project.
gitattributes GitAttributesFile The .gitattributes file for this repository.
gitignore IgnoreFile .gitignore.
logger Logger Logging utilities.
name string Project name.
outdir string Absolute output directory of this project.
packageTask Task No description.
postCompileTask Task No description.
preCompileTask Task No description.
projectBuild ProjectBuild Manages the build process of the project.
projenCommand string The command to use in order to run the projen CLI.
root Project The root project.
subprojects Project[] Returns all the subprojects within this project.
tasks Tasks Project tasks.
testTask Task No description.
defaultTask Task This is the “default” task, the one that executes “projen”.
initProject InitProject The options used when this project is bootstrapped via projen new.
parent Project A parent project.
projectType ProjectType No description.
autoApprove projen.github.AutoApprove Auto approve set up for this project.
devContainer projen.vscode.DevContainer Access for .devcontainer.json (used for GitHub Codespaces).
github projen.github.GitHub Access all github components.
gitpod Gitpod Access for Gitpod.
vscode projen.vscode.VsCode Access all VSCode components.
allowLibraryDependencies boolean No description.
artifactsDirectory string The build output directory.
artifactsJavascriptDirectory string The location of the npm tarball after build (${artifactsDirectory}/js).
bundler projen.javascript.Bundler No description.
entrypoint string No description.
manifest any No description.
npmrc projen.javascript.NpmConfig The .npmrc file.
package projen.javascript.NodePackage API for managing the node package.
packageManager projen.javascript.NodePackageManager The package manager to use.
runScriptCommand string The command to use to run scripts (e.g. yarn run or npm run depends on the package manager).
autoMerge projen.github.AutoMerge Component that sets up mergify for merging approved pull requests.
buildWorkflow projen.build.BuildWorkflow The PR build GitHub workflow.
buildWorkflowJobId string The job ID of the build workflow.
jest projen.javascript.Jest The Jest configuration (if enabled).
maxNodeVersion string Maximum node version required by this package.
minNodeVersion string Minimum node.js version required by this package.
npmignore IgnoreFile The .npmignore file.
prettier projen.javascript.Prettier No description.
publisher projen.release.Publisher Package publisher.
release projen.release.Release Release management.
upgradeWorkflow projen.javascript.UpgradeDependencies The upgrade workflow.
docsDirectory string No description.
libdir string The directory in which compiled .js files reside.
srcdir string The directory in which the .ts sources reside.
testdir string The directory in which tests reside.
tsconfigDev projen.javascript.TypescriptConfig A typescript configuration file which covers all files (sources, tests, projen).
watchTask Task The “watch” task.
docgen boolean No description.
eslint projen.javascript.Eslint No description.
tsconfig projen.javascript.TypescriptConfig No description.
tsconfigEslint projen.javascript.TypescriptConfig No description.
appEntrypoint string The CDK8s app entrypoint.
cdk8sDeps projen.cdk8s.Cdk8sDeps No description.

nodeRequired
public readonly node: Node;

The tree node.


buildTaskRequired
public readonly buildTask: Task;

commitGeneratedRequired
public readonly commitGenerated: boolean;

Whether to commit the managed files by default.


compileTaskRequired
public readonly compileTask: Task;

componentsRequired
public readonly components: Component[];

Returns all the components within this project.


depsRequired
public readonly deps: Dependencies;

Project dependencies.


ejectedRequired
public readonly ejected: boolean;

Whether or not the project is being ejected.


filesRequired
public readonly files: FileBase[];

All files in this project.


gitattributesRequired
public readonly gitattributes: GitAttributesFile;

The .gitattributes file for this repository.


gitignoreRequired
public readonly gitignore: IgnoreFile;

.gitignore.


loggerRequired
public readonly logger: Logger;

Logging utilities.


nameRequired
public readonly name: string;

Project name.


outdirRequired
public readonly outdir: string;

Absolute output directory of this project.


packageTaskRequired
public readonly packageTask: Task;

postCompileTaskRequired
public readonly postCompileTask: Task;

preCompileTaskRequired
public readonly preCompileTask: Task;

projectBuildRequired
public readonly projectBuild: ProjectBuild;

Manages the build process of the project.


projenCommandRequired
public readonly projenCommand: string;

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


rootRequired
public readonly root: Project;

The root project.


subprojectsRequired
public readonly subprojects: Project[];

Returns all the subprojects within this project.


tasksRequired
public readonly tasks: Tasks;

Project tasks.


testTaskRequired
public readonly testTask: Task;

defaultTaskOptional
public readonly defaultTask: Task;

This is the “default” task, the one that executes “projen”.

Undefined if the project is being ejected.


initProjectOptional
public readonly initProject: InitProject;

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

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


parentOptional
public readonly parent: Project;

A parent project.

If undefined, this is the root project.


projectTypeRequired
public readonly projectType: ProjectType;

autoApproveOptional
public readonly autoApprove: AutoApprove;

Auto approve set up for this project.


devContainerOptional
public readonly devContainer: DevContainer;

Access for .devcontainer.json (used for GitHub Codespaces).

This will be undefined if devContainer boolean is false


githubOptional
public readonly github: GitHub;

Access all github components.

This will be undefined for subprojects.


gitpodOptional
public readonly gitpod: Gitpod;

Access for Gitpod.

This will be undefined if gitpod boolean is false


vscodeOptional
public readonly vscode: VsCode;

Access all VSCode components.

This will be undefined for subprojects.


allowLibraryDependenciesRequired
public readonly allowLibraryDependencies: boolean;

artifactsDirectoryRequired
public readonly artifactsDirectory: string;

The build output directory.

An npm tarball will be created under the js subdirectory. For example, if this is set to dist (the default), the npm tarball will be placed under dist/js/boom-boom-1.2.3.tg.


artifactsJavascriptDirectoryRequired
public readonly artifactsJavascriptDirectory: string;

The location of the npm tarball after build (${artifactsDirectory}/js).


bundlerRequired
public readonly bundler: Bundler;

entrypointRequired
public readonly entrypoint: string;

manifestRequired
public readonly manifest: any;

npmrcRequired
public readonly npmrc: NpmConfig;

The .npmrc file.


packageRequired
public readonly package: NodePackage;

API for managing the node package.


packageManagerRequired
public readonly packageManager: NodePackageManager;

The package manager to use.


runScriptCommandRequired
public readonly runScriptCommand: string;

The command to use to run scripts (e.g. yarn run or npm run depends on the package manager).


autoMergeOptional
public readonly autoMerge: AutoMerge;

Component that sets up mergify for merging approved pull requests.


buildWorkflowOptional
public readonly buildWorkflow: BuildWorkflow;

The PR build GitHub workflow.

undefined if buildWorkflow is disabled.


buildWorkflowJobIdOptional
public readonly buildWorkflowJobId: string;

The job ID of the build workflow.


jestOptional
public readonly jest: Jest;

The Jest configuration (if enabled).


maxNodeVersionOptional
public readonly maxNodeVersion: string;

Maximum node version required by this package.


minNodeVersionOptional
public readonly minNodeVersion: string;

Minimum node.js version required by this package.


npmignoreOptional
public readonly npmignore: IgnoreFile;

The .npmignore file.


prettierOptional
public readonly prettier: Prettier;

publisherOptional
public readonly publisher: Publisher;

Package publisher.

This will be undefined if the project does not have a release workflow.


releaseOptional
public readonly release: Release;

Release management.


upgradeWorkflowOptional
public readonly upgradeWorkflow: UpgradeDependencies;

The upgrade workflow.


docsDirectoryRequired
public readonly docsDirectory: string;

libdirRequired
public readonly libdir: string;

The directory in which compiled .js files reside.


srcdirRequired
public readonly srcdir: string;

The directory in which the .ts sources reside.


testdirRequired
public readonly testdir: string;

The directory in which tests reside.


tsconfigDevRequired
public readonly tsconfigDev: TypescriptConfig;

A typescript configuration file which covers all files (sources, tests, projen).


watchTaskRequired
public readonly watchTask: Task;

The “watch” task.


docgenOptional
public readonly docgen: boolean;

eslintOptional
public readonly eslint: Eslint;

tsconfigOptional
public readonly tsconfig: TypescriptConfig;

tsconfigEslintOptional
public readonly tsconfigEslint: TypescriptConfig;

appEntrypointRequired
public readonly appEntrypoint: string;

The CDK8s app entrypoint.


cdk8sDepsRequired
public readonly cdk8sDeps: Cdk8sDeps;

Constants

Name Type Description
DEFAULT_TASK string The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
public readonly DEFAULT_TASK: string;

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

Normally this task should synthesize the project files.


CdkConfig

Represents cdk.json file.

Initializers

import { awscdk } from 'projen'

new awscdk.CdkConfig(project: Project, options: CdkConfigOptions)
Name Type Description
project Project No description.
options projen.awscdk.CdkConfigOptions No description.

projectRequired

optionsRequired

Methods

Name Description
toString Returns a string representation of this construct.
postSynthesize Called after synthesis.
preSynthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.
addExcludes Add excludes to cdk.json.
addIncludes Add includes to cdk.json.

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.

addExcludes
public addExcludes(patterns: string): void

Add excludes to cdk.json.

patternsRequired

The excludes to add.


addIncludes
public addIncludes(patterns: string): void

Add includes to cdk.json.

patternsRequired

The includes to add.


Static Functions

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

isConstruct
import { awscdk } from 'projen'

awscdk.CdkConfig.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { awscdk } from 'projen'

awscdk.CdkConfig.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.
cdkout string Name of the cdk.out directory.
exclude string[] List of glob patterns to be excluded by CDK.
include string[] List of glob patterns to be included by CDK.
json JsonFile Represents the JSON file.

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

cdkoutRequired
public readonly cdkout: string;

Name of the cdk.out directory.


excludeRequired
public readonly exclude: string[];

List of glob patterns to be excluded by CDK.


includeRequired
public readonly include: string[];

List of glob patterns to be included by CDK.


jsonRequired
public readonly json: JsonFile;

Represents the JSON file.


CdkTasks

Adds standard AWS CDK tasks to your project.

Initializers

import { awscdk } from 'projen'

new awscdk.CdkTasks(project: Project)
Name Type Description
project Project No description.

projectRequired

Methods

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

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

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

isConstruct
import { awscdk } from 'projen'

awscdk.CdkTasks.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { awscdk } from 'projen'

awscdk.CdkTasks.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.
deploy Task Deploys your app.
destroy Task Destroys all the stacks.
diff Task Diff against production.
synth Task Synthesizes your app.
synthSilent Task Synthesizes your app and suppresses stdout.
watch Task Watch task.

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

deployRequired
public readonly deploy: Task;

Deploys your app.


destroyRequired
public readonly destroy: Task;

Destroys all the stacks.


diffRequired
public readonly diff: Task;

Diff against production.


synthRequired
public readonly synth: Task;

Synthesizes your app.


synthSilentRequired
public readonly synthSilent: Task;

Synthesizes your app and suppresses stdout.


watchRequired
public readonly watch: Task;

Watch task.


CiConfiguration

CI for GitLab.

A CI is a configurable automated process made up of one or more stages/jobs.

https://docs.gitlab.com/ee/ci/yaml/

Initializers

import { gitlab } from 'projen'

new gitlab.CiConfiguration(project: Project, name: string, options?: CiConfigurationOptions)
Name Type Description
project Project No description.
name string No description.
options projen.gitlab.CiConfigurationOptions No description.

projectRequired

nameRequired

optionsOptional

Methods

Name Description
toString Returns a string representation of this construct.
postSynthesize Called after synthesis.
preSynthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.
addGlobalVariables Add a globally defined variable to the CI configuration.
addIncludes Add additional yml/yaml files to the CI includes.
addJobs Add jobs and their stages to the CI configuration.
addServices Add additional services.
addStages Add stages to the CI configuration if not already present.

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.

addGlobalVariables
public addGlobalVariables(variables: {[ key: string ]: any}): void

Add a globally defined variable to the CI configuration.

variablesRequired

The variables to add.


addIncludes
public addIncludes(includes: Include): void

Add additional yml/yaml files to the CI includes.

includesRequired

The includes to add.


addJobs
public addJobs(jobs: {[ key: string ]: Job}): void

Add jobs and their stages to the CI configuration.

jobsRequired

Jobs to add.


addServices
public addServices(services: Service): void

Add additional services.

servicesRequired

The services to add.


addStages
public addStages(stages: string): void

Add stages to the CI configuration if not already present.

stagesRequired

stages to add.


Static Functions

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

isConstruct
import { gitlab } from 'projen'

gitlab.CiConfiguration.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { gitlab } from 'projen'

gitlab.CiConfiguration.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.
defaultAfterScript string[] Defines default scripts that should run after all jobs.
defaultBeforeScript string[] Defines default scripts that should run before all jobs.
defaultTags string[] Used to select a specific runner from the list of all runners that are available for the project.
file YamlFile The workflow YAML file.
jobs {[ key: string ]: projen.gitlab.Job} The jobs in the CI configuration.
name string The name of the configuration.
path string Path to CI file generated by the configuration.
stages string[] Groups jobs into stages.
variables {[ key: string ]: string \| number \| projen.gitlab.VariableConfig} Global variables that are passed to jobs.
defaultArtifacts projen.gitlab.Artifacts Default list of files and directories that should be attached to the job if it succeeds.
defaultCache projen.gitlab.Cache A default list of files and directories to cache between jobs.
defaultImage projen.gitlab.Image Specifies the default docker image to use globally for all jobs.
defaultInterruptible boolean The default behavior for whether a job should be canceled when a newer pipeline starts before the job completes (Default: false).
defaultRetry projen.gitlab.Retry How many times a job is retried if it fails.
defaultTimeout string A default timeout job written in natural language (Ex.
pages projen.gitlab.Job A special job used to upload static sites to Gitlab pages.
workflow projen.gitlab.Workflow Used to control pipeline behavior.

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

defaultAfterScriptRequired
public readonly defaultAfterScript: string[];

Defines default scripts that should run after all jobs.

Can be overriden by the job level afterScript.


defaultBeforeScriptRequired
public readonly defaultBeforeScript: string[];

Defines default scripts that should run before all jobs.

Can be overriden by the job level afterScript.


defaultTagsRequired
public readonly defaultTags: string[];

Used to select a specific runner from the list of all runners that are available for the project.


fileRequired
public readonly file: YamlFile;

The workflow YAML file.


jobsRequired
public readonly jobs: {[ key: string ]: Job};

The jobs in the CI configuration.


nameRequired
public readonly name: string;

The name of the configuration.


pathRequired
public readonly path: string;

Path to CI file generated by the configuration.


stagesRequired
public readonly stages: string[];

Groups jobs into stages.

All jobs in one stage must complete before next stage is executed. Defaults to [‘build’, ‘test’, ‘deploy’].


variablesRequired
public readonly variables: {[ key: string ]: string | number | VariableConfig};

Global variables that are passed to jobs.

If the job already has that variable defined, the job-level variable takes precedence.


defaultArtifactsOptional
public readonly defaultArtifacts: Artifacts;

Default list of files and directories that should be attached to the job if it succeeds.

Artifacts are sent to Gitlab where they can be downloaded.


defaultCacheOptional
public readonly defaultCache: Cache;

A default list of files and directories to cache between jobs.

You can only use paths that are in the local working copy.


defaultImageOptional
public readonly defaultImage: Image;

Specifies the default docker image to use globally for all jobs.


defaultInterruptibleOptional
public readonly defaultInterruptible: boolean;

The default behavior for whether a job should be canceled when a newer pipeline starts before the job completes (Default: false).


defaultRetryOptional
public readonly defaultRetry: Retry;

How many times a job is retried if it fails.

If not defined, defaults to 0 and jobs do not retry.


defaultTimeoutOptional
public readonly defaultTimeout: string;

A default timeout job written in natural language (Ex.

one hour, 3600 seconds, 60 minutes).


pagesOptional
public readonly pages: Job;

A special job used to upload static sites to Gitlab pages.

Requires a public/ directory with artifacts.path pointing to it.


workflowOptional
public readonly workflow: Workflow;

Used to control pipeline behavior.


Circleci

Circleci Class to manage .circleci/config.yml. Check projen’s docs for more information.

https://circleci.com/docs/2.0/configuration-reference/

Initializers

import { circleci } from 'projen'

new circleci.Circleci(project: Project, options?: CircleCiProps)
Name Type Description
project Project No description.
options projen.circleci.CircleCiProps No description.

projectRequired

optionsOptional

Methods

Name Description
toString Returns a string representation of this construct.
postSynthesize Called after synthesis.
preSynthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.
addOrb Add a Circleci Orb to pipeline.
addWorkflow add new workflow to existing pipeline.

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.

addOrb
public addOrb(name: string, orb: string): void

Add a Circleci Orb to pipeline.

Will throw error if the orb already exists

nameRequired

orbRequired

addWorkflow
public addWorkflow(workflow: Workflow): void

add new workflow to existing pipeline.

workflowRequired

Static Functions

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

isConstruct
import { circleci } from 'projen'

circleci.Circleci.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { circleci } from 'projen'

circleci.Circleci.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.
file YamlFile The yaml file for the Circleci pipeline.

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

fileRequired
public readonly file: YamlFile;

The yaml file for the Circleci pipeline.


Component

Represents a project component.

Initializers

import { Component } from 'projen'

new Component(scope: IConstruct, id?: string)
Name Type Description
scope constructs.IConstruct No description.
id string No description.

scopeRequired

idOptional

Methods

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

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

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

isConstruct
import { Component } from 'projen'

Component.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isComponent
import { Component } from 'projen'

Component.isComponent(x: any)

Test whether the given construct is a component.

xRequired

Properties

Name Type Description
node constructs.Node The tree node.
project Project No description.

nodeRequired
public readonly node: Node;

The tree node.


projectRequired
public readonly project: Project;

ConstructLibrary

A multi-language library for CDK constructs.

Initializers

import { cdk } from 'projen'

new cdk.ConstructLibrary(options: ConstructLibraryOptions)
Name Type Description
options projen.cdk.ConstructLibraryOptions No description.

optionsRequired

Methods

Name Description
toString Returns a string representation of this construct.
addExcludeFromCleanup Exclude the matching files from pre-synth cleanup.
addGitIgnore Adds a .gitignore pattern.
addPackageIgnore Exclude these files from the bundled package.
addTask Adds a new task to this project.
addTip Prints a “tip” message during synthesis.
annotateGenerated Marks the provided file(s) as being generated.
postSynthesize Called after all components are synthesized.
preSynthesize Called before all components are synthesized.
removeTask Removes a task from a project.
runTaskCommand Returns the shell command to execute in order to run a task.
synth Synthesize all project files into outdir.
tryFindFile Finds a file at the specified relative path within this project and all its subprojects.
tryFindJsonFile Finds a json file by name.
tryFindObjectFile Finds an object file (like JsonFile, YamlFile, etc.) by name.
tryRemoveFile Finds a file at the specified relative path within this project and removes it.
addBins No description.
addBundledDeps Defines bundled dependencies.
addCompileCommand DEPRECATED.
addDeps Defines normal dependencies.
addDevDeps Defines development/test dependencies.
addFields Directly set fields in package.json.
addKeywords Adds keywords to package.json (deduplicated).
addPeerDeps Defines peer dependencies.
addScripts Replaces the contents of multiple npm package.json scripts.
addTestCommand DEPRECATED.
hasScript Indicates if a script by the name name is defined.
removeScript Removes the npm script (always successful).
renderWorkflowSetup Returns the set of workflow steps which should be executed to bootstrap a workflow.
setScript Replaces the contents of an npm package.json script.

toString
public toString(): string

Returns a string representation of this construct.

addExcludeFromCleanup
public addExcludeFromCleanup(globs: string): void

Exclude the matching files from pre-synth cleanup.

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

globsRequired

The glob patterns to match.


addGitIgnore
public addGitIgnore(pattern: string): void

Adds a .gitignore pattern.

patternRequired

The glob pattern to ignore.


addPackageIgnore
public addPackageIgnore(pattern: string): void

Exclude these files from the bundled package.

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

patternRequired

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

Adds a new task to this project.

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

nameRequired

The task name to add.


propsOptional

Task properties.


addTip
public addTip(message: string): void

Prints a “tip” message during synthesis.

messageRequired

The message.


annotateGenerated
public annotateGenerated(glob: string): void

Marks the provided file(s) as being generated.

This is achieved using the github-linguist attributes. Generated files do not count against the repository statistics and language breakdown.

https://github.com/github/linguist/blob/master/docs/overrides.md

globRequired

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


postSynthesize
public postSynthesize(): void

Called after all components are synthesized.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before all components are synthesized.

removeTask
public removeTask(name: string): Task

Removes a task from a project.

nameRequired

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.

This will typically be npx projen TASK.

taskRequired

The task for which the command is required.


synth
public synth(): void

Synthesize all project files into outdir.

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

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

filePathRequired

The file path.

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


tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile

Finds a json file by name.

filePathRequired

The file path.


tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile

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

filePathRequired

The file path.


tryRemoveFile
public tryRemoveFile(filePath: string): FileBase

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

filePathRequired

The file path.

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


addBins
public addBins(bins: {[ key: string ]: string}): void
binsRequired

addBundledDeps
public addBundledDeps(deps: string): void

Defines bundled dependencies.

Bundled dependencies will be added as normal dependencies as well as to the bundledDependencies section of your package.json.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addCompileCommand
public addCompileCommand(commands: string): void

DEPRECATED.

commandsRequired

addDeps
public addDeps(deps: string): void

Defines normal dependencies.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addDevDeps
public addDevDeps(deps: string): void

Defines development/test dependencies.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addFields
public addFields(fields: {[ key: string ]: any}): void

Directly set fields in package.json.

fieldsRequired

The fields to set.


addKeywords
public addKeywords(keywords: string): void

Adds keywords to package.json (deduplicated).

keywordsRequired

The keywords to add.


addPeerDeps
public addPeerDeps(deps: string): void

Defines peer dependencies.

When adding peer dependencies, a devDependency will also be added on the pinned version of the declared peer. This will ensure that you are testing your code against the minimum version required from your consumers.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addScripts
public addScripts(scripts: {[ key: string ]: string}): void

Replaces the contents of multiple npm package.json scripts.

scriptsRequired

The scripts to set.


addTestCommand
public addTestCommand(commands: string): void

DEPRECATED.

commandsRequired

hasScript
public hasScript(name: string): boolean

Indicates if a script by the name name is defined.

nameRequired

The name of the script.


removeScript
public removeScript(name: string): void

Removes the npm script (always successful).

nameRequired

The name of the script.


renderWorkflowSetup
public renderWorkflowSetup(options?: RenderWorkflowSetupOptions): JobStep[]

Returns the set of workflow steps which should be executed to bootstrap a workflow.

optionsOptional

Options.


setScript
public setScript(name: string, command: string): void

Replaces the contents of an npm package.json script.

nameRequired

The script name.


commandRequired

The command to execute.


Static Functions

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

isConstruct
import { cdk } from 'projen'

cdk.ConstructLibrary.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isProject
import { cdk } from 'projen'

cdk.ConstructLibrary.isProject(x: any)

Test whether the given construct is a project.

xRequired

of
import { cdk } from 'projen'

cdk.ConstructLibrary.of(construct: IConstruct)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired

Properties

Name Type Description
node constructs.Node The tree node.
buildTask Task No description.
commitGenerated boolean Whether to commit the managed files by default.
compileTask Task No description.
components Component[] Returns all the components within this project.
deps Dependencies Project dependencies.
ejected boolean Whether or not the project is being ejected.
files FileBase[] All files in this project.
gitattributes GitAttributesFile The .gitattributes file for this repository.
gitignore IgnoreFile .gitignore.
logger Logger Logging utilities.
name string Project name.
outdir string Absolute output directory of this project.
packageTask Task No description.
postCompileTask Task No description.
preCompileTask Task No description.
projectBuild ProjectBuild Manages the build process of the project.
projenCommand string The command to use in order to run the projen CLI.
root Project The root project.
subprojects Project[] Returns all the subprojects within this project.
tasks Tasks Project tasks.
testTask Task No description.
defaultTask Task This is the “default” task, the one that executes “projen”.
initProject InitProject The options used when this project is bootstrapped via projen new.
parent Project A parent project.
projectType ProjectType No description.
autoApprove projen.github.AutoApprove Auto approve set up for this project.
devContainer projen.vscode.DevContainer Access for .devcontainer.json (used for GitHub Codespaces).
github projen.github.GitHub Access all github components.
gitpod Gitpod Access for Gitpod.
vscode projen.vscode.VsCode Access all VSCode components.
allowLibraryDependencies boolean No description.
artifactsDirectory string The build output directory.
artifactsJavascriptDirectory string The location of the npm tarball after build (${artifactsDirectory}/js).
bundler projen.javascript.Bundler No description.
entrypoint string No description.
manifest any No description.
npmrc projen.javascript.NpmConfig The .npmrc file.
package projen.javascript.NodePackage API for managing the node package.
packageManager projen.javascript.NodePackageManager The package manager to use.
runScriptCommand string The command to use to run scripts (e.g. yarn run or npm run depends on the package manager).
autoMerge projen.github.AutoMerge Component that sets up mergify for merging approved pull requests.
buildWorkflow projen.build.BuildWorkflow The PR build GitHub workflow.
buildWorkflowJobId string The job ID of the build workflow.
jest projen.javascript.Jest The Jest configuration (if enabled).
maxNodeVersion string Maximum node version required by this package.
minNodeVersion string Minimum node.js version required by this package.
npmignore IgnoreFile The .npmignore file.
prettier projen.javascript.Prettier No description.
publisher projen.release.Publisher Package publisher.
release projen.release.Release Release management.
upgradeWorkflow projen.javascript.UpgradeDependencies The upgrade workflow.
docsDirectory string No description.
libdir string The directory in which compiled .js files reside.
srcdir string The directory in which the .ts sources reside.
testdir string The directory in which tests reside.
tsconfigDev projen.javascript.TypescriptConfig A typescript configuration file which covers all files (sources, tests, projen).
watchTask Task The “watch” task.
docgen boolean No description.
eslint projen.javascript.Eslint No description.
tsconfig projen.javascript.TypescriptConfig No description.
tsconfigEslint projen.javascript.TypescriptConfig No description.

nodeRequired
public readonly node: Node;

The tree node.


buildTaskRequired
public readonly buildTask: Task;

commitGeneratedRequired
public readonly commitGenerated: boolean;

Whether to commit the managed files by default.


compileTaskRequired
public readonly compileTask: Task;

componentsRequired
public readonly components: Component[];

Returns all the components within this project.


depsRequired
public readonly deps: Dependencies;

Project dependencies.


ejectedRequired
public readonly ejected: boolean;

Whether or not the project is being ejected.


filesRequired
public readonly files: FileBase[];

All files in this project.


gitattributesRequired
public readonly gitattributes: GitAttributesFile;

The .gitattributes file for this repository.


gitignoreRequired
public readonly gitignore: IgnoreFile;

.gitignore.


loggerRequired
public readonly logger: Logger;

Logging utilities.


nameRequired
public readonly name: string;

Project name.


outdirRequired
public readonly outdir: string;

Absolute output directory of this project.


packageTaskRequired
public readonly packageTask: Task;

postCompileTaskRequired
public readonly postCompileTask: Task;

preCompileTaskRequired
public readonly preCompileTask: Task;

projectBuildRequired
public readonly projectBuild: ProjectBuild;

Manages the build process of the project.


projenCommandRequired
public readonly projenCommand: string;

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


rootRequired
public readonly root: Project;

The root project.


subprojectsRequired
public readonly subprojects: Project[];

Returns all the subprojects within this project.


tasksRequired
public readonly tasks: Tasks;

Project tasks.


testTaskRequired
public readonly testTask: Task;

defaultTaskOptional
public readonly defaultTask: Task;

This is the “default” task, the one that executes “projen”.

Undefined if the project is being ejected.


initProjectOptional
public readonly initProject: InitProject;

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

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


parentOptional
public readonly parent: Project;

A parent project.

If undefined, this is the root project.


projectTypeRequired
public readonly projectType: ProjectType;

autoApproveOptional
public readonly autoApprove: AutoApprove;

Auto approve set up for this project.


devContainerOptional
public readonly devContainer: DevContainer;

Access for .devcontainer.json (used for GitHub Codespaces).

This will be undefined if devContainer boolean is false


githubOptional
public readonly github: GitHub;

Access all github components.

This will be undefined for subprojects.


gitpodOptional
public readonly gitpod: Gitpod;

Access for Gitpod.

This will be undefined if gitpod boolean is false


vscodeOptional
public readonly vscode: VsCode;

Access all VSCode components.

This will be undefined for subprojects.


allowLibraryDependenciesRequired
public readonly allowLibraryDependencies: boolean;

artifactsDirectoryRequired
public readonly artifactsDirectory: string;

The build output directory.

An npm tarball will be created under the js subdirectory. For example, if this is set to dist (the default), the npm tarball will be placed under dist/js/boom-boom-1.2.3.tg.


artifactsJavascriptDirectoryRequired
public readonly artifactsJavascriptDirectory: string;

The location of the npm tarball after build (${artifactsDirectory}/js).


bundlerRequired
public readonly bundler: Bundler;

entrypointRequired
public readonly entrypoint: string;

manifestRequired
public readonly manifest: any;

npmrcRequired
public readonly npmrc: NpmConfig;

The .npmrc file.


packageRequired
public readonly package: NodePackage;

API for managing the node package.


packageManagerRequired
public readonly packageManager: NodePackageManager;

The package manager to use.


runScriptCommandRequired
public readonly runScriptCommand: string;

The command to use to run scripts (e.g. yarn run or npm run depends on the package manager).


autoMergeOptional
public readonly autoMerge: AutoMerge;

Component that sets up mergify for merging approved pull requests.


buildWorkflowOptional
public readonly buildWorkflow: BuildWorkflow;

The PR build GitHub workflow.

undefined if buildWorkflow is disabled.


buildWorkflowJobIdOptional
public readonly buildWorkflowJobId: string;

The job ID of the build workflow.


jestOptional
public readonly jest: Jest;

The Jest configuration (if enabled).


maxNodeVersionOptional
public readonly maxNodeVersion: string;

Maximum node version required by this package.


minNodeVersionOptional
public readonly minNodeVersion: string;

Minimum node.js version required by this package.


npmignoreOptional
public readonly npmignore: IgnoreFile;

The .npmignore file.


prettierOptional
public readonly prettier: Prettier;

publisherOptional
public readonly publisher: Publisher;

Package publisher.

This will be undefined if the project does not have a release workflow.


releaseOptional
public readonly release: Release;

Release management.


upgradeWorkflowOptional
public readonly upgradeWorkflow: UpgradeDependencies;

The upgrade workflow.


docsDirectoryRequired
public readonly docsDirectory: string;

libdirRequired
public readonly libdir: string;

The directory in which compiled .js files reside.


srcdirRequired
public readonly srcdir: string;

The directory in which the .ts sources reside.


testdirRequired
public readonly testdir: string;

The directory in which tests reside.


tsconfigDevRequired
public readonly tsconfigDev: TypescriptConfig;

A typescript configuration file which covers all files (sources, tests, projen).


watchTaskRequired
public readonly watchTask: Task;

The “watch” task.


docgenOptional
public readonly docgen: boolean;

eslintOptional
public readonly eslint: Eslint;

tsconfigOptional
public readonly tsconfig: TypescriptConfig;

tsconfigEslintOptional
public readonly tsconfigEslint: TypescriptConfig;

Constants

Name Type Description
DEFAULT_TASK string The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
public readonly DEFAULT_TASK: string;

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

Normally this task should synthesize the project files.


ConstructLibraryAws

Initializers

import { awscdk } from 'projen'

new awscdk.ConstructLibraryAws(options: AwsCdkConstructLibraryOptions)
Name Type Description
options projen.awscdk.AwsCdkConstructLibraryOptions No description.

optionsRequired

Methods

Name Description
toString Returns a string representation of this construct.
addExcludeFromCleanup Exclude the matching files from pre-synth cleanup.
addGitIgnore Adds a .gitignore pattern.
addPackageIgnore Exclude these files from the bundled package.
addTask Adds a new task to this project.
addTip Prints a “tip” message during synthesis.
annotateGenerated Marks the provided file(s) as being generated.
postSynthesize Called after all components are synthesized.
preSynthesize Called before all components are synthesized.
removeTask Removes a task from a project.
runTaskCommand Returns the shell command to execute in order to run a task.
synth Synthesize all project files into outdir.
tryFindFile Finds a file at the specified relative path within this project and all its subprojects.
tryFindJsonFile Finds a json file by name.
tryFindObjectFile Finds an object file (like JsonFile, YamlFile, etc.) by name.
tryRemoveFile Finds a file at the specified relative path within this project and removes it.
addBins No description.
addBundledDeps Defines bundled dependencies.
addCompileCommand DEPRECATED.
addDeps Defines normal dependencies.
addDevDeps Defines development/test dependencies.
addFields Directly set fields in package.json.
addKeywords Adds keywords to package.json (deduplicated).
addPeerDeps Defines peer dependencies.
addScripts Replaces the contents of multiple npm package.json scripts.
addTestCommand DEPRECATED.
hasScript Indicates if a script by the name name is defined.
removeScript Removes the npm script (always successful).
renderWorkflowSetup Returns the set of workflow steps which should be executed to bootstrap a workflow.
setScript Replaces the contents of an npm package.json script.
addCdkDependencies Adds dependencies to AWS CDK modules.
addCdkTestDependencies Adds AWS CDK modules as dev dependencies.

toString
public toString(): string

Returns a string representation of this construct.

addExcludeFromCleanup
public addExcludeFromCleanup(globs: string): void

Exclude the matching files from pre-synth cleanup.

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

globsRequired

The glob patterns to match.


addGitIgnore
public addGitIgnore(pattern: string): void

Adds a .gitignore pattern.

patternRequired

The glob pattern to ignore.


addPackageIgnore
public addPackageIgnore(pattern: string): void

Exclude these files from the bundled package.

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

patternRequired

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

Adds a new task to this project.

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

nameRequired

The task name to add.


propsOptional

Task properties.


addTip
public addTip(message: string): void

Prints a “tip” message during synthesis.

messageRequired

The message.


annotateGenerated
public annotateGenerated(glob: string): void

Marks the provided file(s) as being generated.

This is achieved using the github-linguist attributes. Generated files do not count against the repository statistics and language breakdown.

https://github.com/github/linguist/blob/master/docs/overrides.md

globRequired

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


postSynthesize
public postSynthesize(): void

Called after all components are synthesized.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before all components are synthesized.

removeTask
public removeTask(name: string): Task

Removes a task from a project.

nameRequired

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.

This will typically be npx projen TASK.

taskRequired

The task for which the command is required.


synth
public synth(): void

Synthesize all project files into outdir.

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

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

filePathRequired

The file path.

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


tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile

Finds a json file by name.

filePathRequired

The file path.


tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile

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

filePathRequired

The file path.


tryRemoveFile
public tryRemoveFile(filePath: string): FileBase

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

filePathRequired

The file path.

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


addBins
public addBins(bins: {[ key: string ]: string}): void
binsRequired

addBundledDeps
public addBundledDeps(deps: string): void

Defines bundled dependencies.

Bundled dependencies will be added as normal dependencies as well as to the bundledDependencies section of your package.json.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addCompileCommand
public addCompileCommand(commands: string): void

DEPRECATED.

commandsRequired

addDeps
public addDeps(deps: string): void

Defines normal dependencies.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addDevDeps
public addDevDeps(deps: string): void

Defines development/test dependencies.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addFields
public addFields(fields: {[ key: string ]: any}): void

Directly set fields in package.json.

fieldsRequired

The fields to set.


addKeywords
public addKeywords(keywords: string): void

Adds keywords to package.json (deduplicated).

keywordsRequired

The keywords to add.


addPeerDeps
public addPeerDeps(deps: string): void

Defines peer dependencies.

When adding peer dependencies, a devDependency will also be added on the pinned version of the declared peer. This will ensure that you are testing your code against the minimum version required from your consumers.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addScripts
public addScripts(scripts: {[ key: string ]: string}): void

Replaces the contents of multiple npm package.json scripts.

scriptsRequired

The scripts to set.


addTestCommand
public addTestCommand(commands: string): void

DEPRECATED.

commandsRequired

hasScript
public hasScript(name: string): boolean

Indicates if a script by the name name is defined.

nameRequired

The name of the script.


removeScript
public removeScript(name: string): void

Removes the npm script (always successful).

nameRequired

The name of the script.


renderWorkflowSetup
public renderWorkflowSetup(options?: RenderWorkflowSetupOptions): JobStep[]

Returns the set of workflow steps which should be executed to bootstrap a workflow.

optionsOptional

Options.


setScript
public setScript(name: string, command: string): void

Replaces the contents of an npm package.json script.

nameRequired

The script name.


commandRequired

The command to execute.


addCdkDependencies
public addCdkDependencies(deps: string): void

Adds dependencies to AWS CDK modules.

Since this is a library project, dependencies will be added as peer dependencies.

depsRequired

names of cdk modules (e.g. @aws-cdk/aws-lambda).


addCdkTestDependencies
public addCdkTestDependencies(deps: string): void

Adds AWS CDK modules as dev dependencies.

depsRequired

names of cdk modules (e.g. @aws-cdk/aws-lambda).


Static Functions

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

isConstruct
import { awscdk } from 'projen'

awscdk.ConstructLibraryAws.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired

Any object.


isProject
import { awscdk } from 'projen'

awscdk.ConstructLibraryAws.isProject(x: any)

Test whether the given construct is a project.

xRequired

of
import { awscdk } from 'projen'

awscdk.ConstructLibraryAws.of(construct: IConstruct)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired

Properties

Name Type Description
node constructs.Node The tree node.
buildTask Task No description.
commitGenerated boolean Whether to commit the managed files by default.
compileTask Task No description.
components Component[] Returns all the components within this project.
deps Dependencies Project dependencies.
ejected boolean Whether or not the project is being ejected.
files FileBase[] All files in this project.
gitattributes GitAttributesFile The .gitattributes file for this repository.
gitignore IgnoreFile .gitignore.
logger Logger Logging utilities.
name string Project name.
outdir string Absolute output directory of this project.
packageTask Task No description.
postCompileTask Task No description.
preCompileTask Task No description.
projectBuild ProjectBuild Manages the build process of the project.
projenCommand string The command to use in order to run the projen CLI.
root Project The root project.
subprojects Project[] Returns all the subprojects within this project.
tasks Tasks Project tasks.
testTask Task No description.
defaultTask Task This is the “default” task, the one that executes “projen”.
initProject InitProject The options used when this project is bootstrapped via projen new.
parent Project A parent project.
projectType ProjectType No description.
autoApprove projen.github.AutoApprove Auto approve set up for this project.
devContainer projen.vscode.DevContainer Access for .devcontainer.json (used for GitHub Codespaces).
github projen.github.GitHub Access all github components.
gitpod Gitpod Access for Gitpod.
vscode projen.vscode.VsCode Access all VSCode components.
allowLibraryDependencies boolean No description.
artifactsDirectory string The build output directory.
artifactsJavascriptDirectory string The location of the npm tarball after build (${artifactsDirectory}/js).
bundler projen.javascript.Bundler No description.
entrypoint string No description.
manifest any No description.
npmrc projen.javascript.NpmConfig The .npmrc file.
package projen.javascript.NodePackage API for managing the node package.
packageManager projen.javascript.NodePackageManager The package manager to use.
runScriptCommand string The command to use to run scripts (e.g. yarn run or npm run depends on the package manager).
autoMerge projen.github.AutoMerge Component that sets up mergify for merging approved pull requests.
buildWorkflow projen.build.BuildWorkflow The PR build GitHub workflow.
buildWorkflowJobId string The job ID of the build workflow.
jest projen.javascript.Jest The Jest configuration (if enabled).
maxNodeVersion string Maximum node version required by this package.
minNodeVersion string Minimum node.js version required by this package.
npmignore IgnoreFile The .npmignore file.
prettier projen.javascript.Prettier No description.
publisher projen.release.Publisher Package publisher.
release projen.release.Release Release management.
upgradeWorkflow projen.javascript.UpgradeDependencies The upgrade workflow.
docsDirectory string No description.
libdir string The directory in which compiled .js files reside.
srcdir string The directory in which the .ts sources reside.
testdir string The directory in which tests reside.
tsconfigDev projen.javascript.TypescriptConfig A typescript configuration file which covers all files (sources, tests, projen).
watchTask Task The “watch” task.
docgen boolean No description.
eslint projen.javascript.Eslint No description.
tsconfig projen.javascript.TypescriptConfig No description.
tsconfigEslint projen.javascript.TypescriptConfig No description.
cdkDeps projen.awscdk.AwsCdkDeps No description.
cdkVersion string The target CDK version for this library.
version string No description.

nodeRequired
public readonly node: Node;

The tree node.


buildTaskRequired
public readonly buildTask: Task;

commitGeneratedRequired
public readonly commitGenerated: boolean;

Whether to commit the managed files by default.


compileTaskRequired
public readonly compileTask: Task;

componentsRequired
public readonly components: Component[];

Returns all the components within this project.


depsRequired
public readonly deps: Dependencies;

Project dependencies.


ejectedRequired
public readonly ejected: boolean;

Whether or not the project is being ejected.


filesRequired
public readonly files: FileBase[];

All files in this project.


gitattributesRequired
public readonly gitattributes: GitAttributesFile;

The .gitattributes file for this repository.


gitignoreRequired
public readonly gitignore: IgnoreFile;

.gitignore.


loggerRequired
public readonly logger: Logger;

Logging utilities.


nameRequired
public readonly name: string;

Project name.


outdirRequired
public readonly outdir: string;

Absolute output directory of this project.


packageTaskRequired
public readonly packageTask: Task;

postCompileTaskRequired
public readonly postCompileTask: Task;

preCompileTaskRequired
public readonly preCompileTask: Task;

projectBuildRequired
public readonly projectBuild: ProjectBuild;

Manages the build process of the project.


projenCommandRequired
public readonly projenCommand: string;

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


rootRequired
public readonly root: Project;

The root project.


subprojectsRequired
public readonly subprojects: Project[];

Returns all the subprojects within this project.


tasksRequired
public readonly tasks: Tasks;

Project tasks.


testTaskRequired
public readonly testTask: Task;

defaultTaskOptional
public readonly defaultTask: Task;

This is the “default” task, the one that executes “projen”.

Undefined if the project is being ejected.


initProjectOptional
public readonly initProject: InitProject;

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

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


parentOptional
public readonly parent: Project;

A parent project.

If undefined, this is the root project.


projectTypeRequired
public readonly projectType: ProjectType;

autoApproveOptional
public readonly autoApprove: AutoApprove;

Auto approve set up for this project.


devContainerOptional
public readonly devContainer: DevContainer;

Access for .devcontainer.json (used for GitHub Codespaces).

This will be undefined if devContainer boolean is false


githubOptional
public readonly github: GitHub;

Access all github components.

This will be undefined for subprojects.


gitpodOptional
public readonly gitpod: Gitpod;

Access for Gitpod.

This will be undefined if gitpod boolean is false


vscodeOptional
public readonly vscode: VsCode;

Access all VSCode components.

This will be undefined for subprojects.


allowLibraryDependenciesRequired
public readonly allowLibraryDependencies: boolean;

artifactsDirectoryRequired
public readonly artifactsDirectory: string;

The build output directory.

An npm tarball will be created under the js subdirectory. For example, if this is set to dist (the default), the npm tarball will be placed under dist/js/boom-boom-1.2.3.tg.


artifactsJavascriptDirectoryRequired
public readonly artifactsJavascriptDirectory: string;

The location of the npm tarball after build (${artifactsDirectory}/js).


bundlerRequired
public readonly bundler: Bundler;

entrypointRequired
public readonly entrypoint: string;

manifestRequired
public readonly manifest: any;

npmrcRequired
public readonly npmrc: NpmConfig;

The .npmrc file.


packageRequired
public readonly package: NodePackage;

API for managing the node package.


packageManagerRequired
public readonly packageManager: NodePackageManager;

The package manager to use.


runScriptCommandRequired
public readonly runScriptCommand: string;

The command to use to run scripts (e.g. yarn run or npm run depends on the package manager).


autoMergeOptional
public readonly autoMerge: AutoMerge;

Component that sets up mergify for merging approved pull requests.


buildWorkflowOptional
public readonly buildWorkflow: BuildWorkflow;

The PR build GitHub workflow.

undefined if buildWorkflow is disabled.


buildWorkflowJobIdOptional
public readonly buildWorkflowJobId: string;

The job ID of the build workflow.


jestOptional
public readonly jest: Jest;

The Jest configuration (if enabled).


maxNodeVersionOptional
public readonly maxNodeVersion: string;

Maximum node version required by this package.


minNodeVersionOptional
public readonly minNodeVersion: string;

Minimum node.js version required by this package.


npmignoreOptional
public readonly npmignore: IgnoreFile;

The .npmignore file.


prettierOptional
public readonly prettier: Prettier;

publisherOptional
public readonly publisher: Publisher;

Package publisher.

This will be undefined if the project does not have a release workflow.


releaseOptional
public readonly release: Release;

Release management.


upgradeWorkflowOptional
public readonly upgradeWorkflow: UpgradeDependencies;

The upgrade workflow.


docsDirectoryRequired
public readonly docsDirectory: string;

libdirRequired
public readonly libdir: string;

The directory in which compiled .js files reside.


srcdirRequired
public readonly srcdir: string;

The directory in which the .ts sources reside.


testdirRequired
public readonly testdir: string;

The directory in which tests reside.


tsconfigDevRequired
public readonly tsconfigDev: TypescriptConfig;

A typescript configuration file which covers all files (sources, tests, projen).


watchTaskRequired
public readonly watchTask: Task;

The “watch” task.


docgenOptional
public readonly docgen: boolean;

eslintOptional
public readonly eslint: Eslint;

tsconfigOptional
public readonly tsconfig: TypescriptConfig;

tsconfigEslintOptional
public readonly tsconfigEslint: TypescriptConfig;

cdkDepsRequired
public readonly cdkDeps: AwsCdkDeps;

cdkVersionRequired
public readonly cdkVersion: string;

The target CDK version for this library.


versionRequired
public readonly version: string;

Constants

Name Type Description
DEFAULT_TASK string The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
public readonly DEFAULT_TASK: string;

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

Normally this task should synthesize the project files.


ConstructLibraryCdk8s

CDK8s construct library project.

A multi-language (jsii) construct library which vends constructs designed to use within the CDK for Kubernetes (CDK8s), with a friendly workflow and automatic publishing to the construct catalog.

Initializers

import { cdk8s } from 'projen'

new cdk8s.ConstructLibraryCdk8s(options: ConstructLibraryCdk8sOptions)
Name Type Description
options projen.cdk8s.ConstructLibraryCdk8sOptions No description.

optionsRequired

Methods

Name Description
toString Returns a string representation of this construct.
addExcludeFromCleanup Exclude the matching files from pre-synth cleanup.
addGitIgnore Adds a .gitignore pattern.
addPackageIgnore Exclude these files from the bundled package.
addTask Adds a new task to this project.
addTip Prints a “tip” message during synthesis.
annotateGenerated Marks the provided file(s) as being generated.
postSynthesize Called after all components are synthesized.
preSynthesize Called before all components are synthesized.
removeTask Removes a task from a project.
runTaskCommand Returns the shell command to execute in order to run a task.
synth Synthesize all project files into outdir.
tryFindFile Finds a file at the specified relative path within this project and all its subprojects.
tryFindJsonFile Finds a json file by name.
tryFindObjectFile Finds an object file (like JsonFile, YamlFile, etc.) by name.
tryRemoveFile Finds a file at the specified relative path within this project and removes it.
addBins No description.
addBundledDeps Defines bundled dependencies.
addCompileCommand DEPRECATED.
addDeps Defines normal dependencies.
addDevDeps Defines development/test dependencies.
addFields Directly set fields in package.json.
addKeywords Adds keywords to package.json (deduplicated).
addPeerDeps Defines peer dependencies.
addScripts Replaces the contents of multiple npm package.json scripts.
addTestCommand DEPRECATED.
hasScript Indicates if a script by the name name is defined.
removeScript Removes the npm script (always successful).
renderWorkflowSetup Returns the set of workflow steps which should be executed to bootstrap a workflow.
setScript Replaces the contents of an npm package.json script.

toString
public toString(): string

Returns a string representation of this construct.

addExcludeFromCleanup
public addExcludeFromCleanup(globs: string): void

Exclude the matching files from pre-synth cleanup.

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

globsRequired

The glob patterns to match.


addGitIgnore
public addGitIgnore(pattern: string): void

Adds a .gitignore pattern.

patternRequired

The glob pattern to ignore.


addPackageIgnore
public addPackageIgnore(pattern: string): void

Exclude these files from the bundled package.

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

patternRequired

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

Adds a new task to this project.

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

nameRequired

The task name to add.


propsOptional

Task properties.


addTip
public addTip(message: string): void

Prints a “tip” message during synthesis.

messageRequired

The message.


annotateGenerated
public annotateGenerated(glob: string): void

Marks the provided file(s) as being generated.

This is achieved using the github-linguist attributes. Generated files do not count against the repository statistics and language breakdown.

https://github.com/github/linguist/blob/master/docs/overrides.md

globRequired

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


postSynthesize
public postSynthesize(): void

Called after all components are synthesized.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before all components are synthesized.

removeTask
public removeTask(name: string): Task

Removes a task from a project.

nameRequired

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.

This will typically be npx projen TASK.

taskRequired

The task for which the command is required.


synth
public synth(): void

Synthesize all project files into outdir.

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

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

filePathRequired

The file path.

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


tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile

Finds a json file by name.

filePathRequired

The file path.


tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile

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

filePathRequired

The file path.


tryRemoveFile
public tryRemoveFile(filePath: string): FileBase

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

filePathRequired

The file path.

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


addBins
public addBins(bins: {[ key: string ]: string}): void
binsRequired

addBundledDeps
public addBundledDeps(deps: string): void

Defines bundled dependencies.

Bundled dependencies will be added as normal dependencies as well as to the bundledDependencies section of your package.json.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addCompileCommand
public addCompileCommand(commands: string): void

DEPRECATED.

commandsRequired

addDeps
public addDeps(deps: string): void

Defines normal dependencies.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addDevDeps
public addDevDeps(deps: string): void

Defines development/test dependencies.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addFields
public addFields(fields: {[ key: string ]: any}): void

Directly set fields in package.json.

fieldsRequired

The fields to set.


addKeywords
public addKeywords(keywords: string): void

Adds keywords to package.json (deduplicated).

keywordsRequired

The keywords to add.


addPeerDeps
public addPeerDeps(deps: string): void

Defines peer dependencies.

When adding peer dependencies, a devDependency will also be added on the pinned version of the declared peer. This will ensure that you are testing your code against the minimum version required from your consumers.

depsRequired

Names modules to install.

By default, the the dependency will be installed in the next npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addScripts
public addScripts(scripts: {[ key: string ]: string}): void

Replaces the contents of multiple npm package.json scripts.

scriptsRequired

The scripts to set.


addTestCommand
public addTestCommand(commands: string): void

DEPRECATED.

commandsRequired

hasScript
public hasScript(name: string): boolean

Indicates if a script by the name name is defined.

nameRequired

The name of the script.


removeScript
public removeScript(name: string): void

Removes the npm script (always successful).

nameRequired

The name of the script.