typescript Submodule
Constructs
Projenrc
A projenrc file written in TypeScript.
This component is used within TypeScriptProject.
Initializers
import { typescript } from 'projen'
new typescript.Projenrc(project: TypeScriptProject, options?: ProjenrcOptions)
| Name | Type | Description |
|---|---|---|
| | No description. |
| | No description. |
projectRequired
- Type: TypeScriptProject
optionsOptional
- Type: ProjenrcOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Applies one or more mixins to this construct. |
| Called once, right after postSynthesize(), only when the project is created for the first time. |
| Called after synthesis. |
| Called before synthesis. |
| Called once, right after synthesize(), only when the project is created for the first time. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
with
public with(mixins: ...IMixin[]): IConstruct
Applies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.
mixinsRequired
- Type: ...constructs.IMixin[]
The mixins to apply.
postProjectCreation
public postProjectCreation(initProject: InitProject): void
Called once, right after postSynthesize(), only when the project is created for the first time.
It does not run on later projen invocations. It only fires for projen new (or Projects.createProject).
It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST.
Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate
feedback on their new project. Order across components is not guaranteed.
initProjectRequired
- Type: projen.InitProject
Details about how the project was created, e.g. its type and the original CLI args.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
projectCreation
public projectCreation(initProject: InitProject): void
Called once, right after synthesize(), only when the project is created for the first time.
It does not run on later projen invocations. It only fires for projen new (or Projects.createProject).
Use it for deterministic, one-off file generation. Order across components is not guaranteed.
initProjectRequired
- Type: projen.InitProject
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| Returns the Projenrc instance associated with a project or undefined if there is no Projenrc. |
isConstruct
import { typescript } from 'projen'
typescript.Projenrc.isConstruct(x: any)
Checks if x is a construct.
Use this method instead of instanceof to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct in each copy of the constructs library
is seen as a different class, and an instance of one class will not test as
instanceof the other class. npm install will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof will behave
unpredictably. It is safest to avoid using instanceof, and using
this type-testing method instead.
xRequired
- Type: any
Any object.
isComponent
import { typescript } from 'projen'
typescript.Projenrc.isComponent(x: any)
Test whether the given construct is a component.
xRequired
- Type: any
of
import { typescript } from 'projen'
typescript.Projenrc.of(project: Project)
Returns the Projenrc instance associated with a project or undefined if there is no Projenrc.
projectRequired
- Type: projen.Project
The project.
Properties
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| string | The path of the projenrc file. |
| projen.javascript.TypescriptConfig | No description. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: projen.Project
filePathRequired
public readonly filePath: string;
- Type: string
The path of the projenrc file.
tsconfigRequired
public readonly tsconfig: TypescriptConfig;
- Type: projen.javascript.TypescriptConfig
ProjenrcTs
A projenrc file written in TypeScript.
This component can be instantiated in any type of project and has no expectations around the project's main language.
Initializers
import { typescript } from 'projen'
new typescript.ProjenrcTs(project: Project, options?: ProjenrcTsOptions)
| Name | Type | Description |
|---|---|---|
| projen.Project | No description. |
| | No description. |
projectRequired
- Type: projen.Project
optionsOptional
- Type: ProjenrcTsOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Applies one or more mixins to this construct. |
| Called once, right after postSynthesize(), only when the project is created for the first time. |
| Called after synthesis. |
| Called before synthesis. |
| Called once, right after synthesize(), only when the project is created for the first time. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
with
public with(mixins: ...IMixin[]): IConstruct
Applies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.
mixinsRequired
- Type: ...constructs.IMixin[]
The mixins to apply.
postProjectCreation
public postProjectCreation(initProject: InitProject): void
Called once, right after postSynthesize(), only when the project is created for the first time.
It does not run on later projen invocations. It only fires for projen new (or Projects.createProject).
It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST.
Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate
feedback on their new project. Order across components is not guaranteed.
initProjectRequired
- Type: projen.InitProject
Details about how the project was created, e.g. its type and the original CLI args.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
projectCreation
public projectCreation(initProject: InitProject): void
Called once, right after synthesize(), only when the project is created for the first time.
It does not run on later projen invocations. It only fires for projen new (or Projects.createProject).
Use it for deterministic, one-off file generation. Order across components is not guaranteed.
initProjectRequired
- Type: projen.InitProject
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| Returns the Projenrc instance associated with a project or undefined if there is no Projenrc. |
isConstruct
import { typescript } from 'projen'
typescript.ProjenrcTs.isConstruct(x: any)
Checks if x is a construct.
Use this method instead of instanceof to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct in each copy of the constructs library
is seen as a different class, and an instance of one class will not test as
instanceof the other class. npm install will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof will behave
unpredictably. It is safest to avoid using instanceof, and using
this type-testing method instead.
xRequired
- Type: any
Any object.
isComponent
import { typescript } from 'projen'
typescript.ProjenrcTs.isComponent(x: any)
Test whether the given construct is a component.
xRequired
- Type: any
of
import { typescript } from 'projen'
typescript.ProjenrcTs.of(project: Project)
Returns the Projenrc instance associated with a project or undefined if there is no Projenrc.
projectRequired
- Type: projen.Project
The project.
Properties
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| string | The path of the projenrc file. |
| projen.javascript.TypescriptConfig | TypeScript configuration file used to compile projen source files. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: projen.Project
filePathRequired
public readonly filePath: string;
- Type: string
The path of the projenrc file.
tsconfigRequired
public readonly tsconfig: TypescriptConfig;
- Type: projen.javascript.TypescriptConfig
TypeScript configuration file used to compile projen source files.
TypeScriptAppProject
TypeScript app.
Initializers
import { typescript } from 'projen'
new typescript.TypeScriptAppProject(options: TypeScriptProjectOptions)
| Name | Type | Description |
|---|---|---|
| | No description. |
optionsRequired
- Type: TypeScriptProjectOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Applies one or more mixins to this construct. |
| Exclude the matching files from pre-synth cleanup. |
| Adds a .gitignore pattern. |
| Adds patterns to be ignored by npm. |
| Adds a new task to this project. |
| Marks the provided file(s) as being generated. |
| Called after all components are synthesized. |
| Called before all components are synthesized. |
| Removes a task from a project. |
| Returns the shell command to execute in order to run a task. |
| Synthesize all project files into outdir. |
| Finds a file at the specified relative path within this project and all its subprojects. |
| Finds an object file (like JsonFile, YamlFile, etc.) by name. |
| Finds a file at the specified relative path within this project and removes it. |
| No description. |
| Defines bundled dependencies. |
| Defines normal dependencies. |
| Defines development/test dependencies. |
| Directly set fields in package.json. |
| Adds keywords to package.json (deduplicated). |
| Defines peer dependencies. |
| Replaces the contents of multiple npm package.json scripts. |
| Removes the npm script (always successful). |
| Returns the set of workflow steps which should be executed to bootstrap a workflow. |
| Replaces the contents of an npm package.json script. |
toString
public toString(): string
Returns a string representation of this construct.
with
public with(mixins: ...IMixin[]): IConstruct
Applies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.
mixinsRequired
- Type: ...constructs.IMixin[]
The mixins to apply.
addExcludeFromCleanup
public addExcludeFromCleanup(globs: ...string[]): void
Exclude the matching files from pre-synth cleanup.
Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.
globsRequired
- Type: ...string[]
The glob patterns to match.
addGitIgnore
public addGitIgnore(pattern: string): void
Adds a .gitignore pattern.
patternRequired
- Type: string
The glob pattern to ignore.
addPackageIgnore
public addPackageIgnore(pattern: string): void
Adds patterns to be ignored by npm.
patternRequired
- Type: string
The pattern to ignore.
addTask
public addTask(name: string, props?: TaskOptions): Task
Adds a new task to this project.
This will fail if the project already has a task with this name.
nameRequired
- Type: string
The task name to add.
propsOptional
- Type: projen.TaskOptions
Task properties.
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
- Type: string
the glob pattern to match (could be a file path).
postSynthesize
public postSynthesize(): void
Called after all components are synthesized.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before all components are synthesized.
removeTask
public removeTask(name: string): Task
Removes a task from a project.
nameRequired
- Type: string
The name of the task to remove.
runTaskCommand
public runTaskCommand(task: Task): string
Returns the shell command to execute in order to run a task.
This will
typically be pnpm projen TASK.
taskRequired
- Type: projen.Task
The task for which the command is required.
synth
public synth(): void
Synthesize all project files into outdir.
- Call "this.preSynthesize()"
- Delete all generated files
- Synthesize all subprojects
- Synthesize all components of this project
- Call "projectCreation()" for all components, only if the project is being created for the first time
- Call "postSynthesize()" for all components of this project
- Call "this.postSynthesize()"
- Call "postProjectCreation()" for all components, only if the project is being created for the first time
tryFindFile
public tryFindFile(filePath: string): FileBase
Finds a file at the specified relative path within this project and all its subprojects.
filePathRequired
- Type: string
The file path.
If this path is relative, it will be resolved from the root of this project.
tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile
Finds an object file (like JsonFile, YamlFile, etc.) by name.
filePathRequired
- Type: string
The file path.
tryRemoveFile
public tryRemoveFile(filePath: string): FileBase
Finds a file at the specified relative path within this project and removes it.
filePathRequired
- Type: string
The file path.
If this path is relative, it will be resolved from the root of this project.
addBins
public addBins(bins: {[ key: string ]: string}): void
binsRequired
- Type: {[ key: string ]: string}
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
- Type: ...string[]
Names modules to install.
By default, the the dependency will
be installed in the next pnpm projen run and the version will be recorded
in your package.json file. You can upgrade manually or using pnpm add/update. If you wish to specify a version range use this syntax:
module@^7.
addDeps
public addDeps(deps: ...string[]): void
Defines normal dependencies.
depsRequired
- Type: ...string[]
Names modules to install.
By default, the the dependency will
be installed in the next pnpm projen run and the version will be recorded
in your package.json file. You can upgrade manually or using pnpm add/update. If you wish to specify a version range use this syntax:
module@^7.
addDevDeps
public addDevDeps(deps: ...string[]): void
Defines development/test dependencies.
depsRequired
- Type: ...string[]
Names modules to install.
By default, the the dependency will
be installed in the next pnpm projen run and the version will be recorded
in your package.json file. You can upgrade manually or using pnpm add/update. 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
- Type: {[ key: string ]: any}
The fields to set.
addKeywords
public addKeywords(keywords: ...string[]): void
Adds keywords to package.json (deduplicated).
keywordsRequired
- Type: ...string[]
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
- Type: ...string[]
Names modules to install.
By default, the the dependency will
be installed in the next pnpm projen run and the version will be recorded
in your package.json file. You can upgrade manually or using pnpm add/update. 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
- Type: {[ key: string ]: string}
The scripts to set.
removeScript
public removeScript(name: string): void
Removes the npm script (always successful).
nameRequired
- Type: string
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
- Type: projen.javascript.RenderWorkflowSetupOptions
Options.
setScript
public setScript(name: string, command: string): void
Replaces the contents of an npm package.json script.
nameRequired
- Type: string
The script name.
commandRequired
- Type: string
The command to execute.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| Test whether the given construct is a project. |
| Find the closest ancestor project for given construct. |
isConstruct
import { typescript } from 'projen'
typescript.TypeScriptAppProject.isConstruct(x: any)
Checks if x is a construct.
Use this method instead of instanceof to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct in each copy of the constructs library
is seen as a different class, and an instance of one class will not test as
instanceof the other class. npm install will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof will behave
unpredictably. It is safest to avoid using instanceof, and using
this type-testing method instead.
xRequired
- Type: any
Any object.
isProject
import { typescript } from 'projen'
typescript.TypeScriptAppProject.isProject(x: any)
Test whether the given construct is a project.
xRequired
- Type: any
of
import { typescript } from 'projen'
typescript.TypeScriptAppProject.of(construct: IConstruct)
Find the closest ancestor project for given construct.
When given a project, this it the project itself.
constructRequired
- Type: constructs.IConstruct
Properties
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| projen.Task | No description. |
| boolean | Whether to commit the managed files by default. |
| projen.Task | No description. |
| projen.Component[] | Returns all the components within this project. |
| projen.Dependencies | Project dependencies. |
| boolean | Whether or not the project is being ejected. |
| projen.FileBase[] | All files in this project. |
| projen.GitAttributesFile | The .gitattributes file for this repository. |
| projen.IgnoreFile | .gitignore. |
| projen.Logger | Logging utilities. |
| string | Project name. |
| string | Absolute output directory of this project. |
| projen.Task | No description. |
| projen.Task | No description. |
| projen.Task | No description. |
| projen.ProjectBuild | Manages the build process of the project. |
| string | The command to use in order to run the projen CLI. |
| projen.Project | The root project. |
| projen.Project[] | Returns all the subprojects within this project. |
| projen.Tasks | Project tasks. |
| projen.Task | No description. |
| projen.Task | This is the "default" task, the one that executes "projen". |
| projen.InitProject | The options used when this project is bootstrapped via projen new. |
| projen.Project | A parent project. |
| projen.github.AutoApprove | Auto approve set up for this project. |
| projen.vscode.DevContainer | Access for .devcontainer.json (used for GitHub Codespaces). |
| projen.github.GitHub | Access all github components. |
| projen.Gitpod | Access for Gitpod. |
| projen.vscode.VsCode | Access all VSCode components. |
| string | The build output directory. |
| string | The location of the npm tarball after build (${artifactsDirectory}/js). |
| projen.javascript.Bundler | No description. |
| projen.javascript.NpmConfig | The .npmrc file. |
| projen.javascript.NodePackage | API for managing the node package. |
| string | The command to use to run scripts (e.g. yarn run or npm run depends on the package manager). |
| projen.github.AutoMerge | Component that sets up mergify for merging approved pull requests. |
| projen.javascript.Biome | No description. |
| projen.build.BuildWorkflow | The PR build GitHub workflow. |
| string | The job ID of the build workflow. |
| projen.javascript.Jest | The Jest configuration (if enabled). |
| string | Maximum node version supported by this package. |
| string | The minimum node version required by this package to function. |
| projen.IgnoreFile | The .npmignore file. |
| projen.javascript.Prettier | No description. |
| projen.release.Release | Release management. |
| projen.javascript.UpgradeDependencies | The upgrade workflow. |
| string | No description. |
| string | The directory in which compiled .js files reside. |
| | The TypeScript runner used for executing TypeScript files. |
| string | The directory in which the .ts sources reside. |
| string | The directory in which tests reside. |
| projen.javascript.TypescriptConfig | A typescript configuration file which covers all files (sources, tests, projen). |
| projen.Task | The "watch" task. |
| boolean | No description. |
| projen.javascript.Eslint | No description. |
| projen.javascript.TypescriptConfig | No description. |
| projen.javascript.TypescriptConfig | No description. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
buildTaskRequired
public readonly buildTask: Task;
- Type: projen.Task
commitGeneratedRequired
public readonly commitGenerated: boolean;
- Type: boolean
Whether to commit the managed files by default.
compileTaskRequired
public readonly compileTask: Task;
- Type: projen.Task
componentsRequired
public readonly components: Component[];
- Type: projen.Component[]
Returns all the components within this project.
depsRequired
public readonly deps: Dependencies;
- Type: projen.Dependencies
Project dependencies.
ejectedRequired
public readonly ejected: boolean;
- Type: boolean
Whether or not the project is being ejected.
filesRequired
public readonly files: FileBase[];
- Type: projen.FileBase[]
All files in this project.
gitattributesRequired
public readonly gitattributes: GitAttributesFile;
- Type: projen.GitAttributesFile
The .gitattributes file for this repository.
gitignoreRequired
public readonly gitignore: IgnoreFile;
- Type: projen.IgnoreFile
.gitignore.
loggerRequired
public readonly logger: Logger;
- Type: projen.Logger
Logging utilities.
nameRequired
public readonly name: string;
- Type: string
Project name.
outdirRequired
public readonly outdir: string;
- Type: string
Absolute output directory of this project.
packageTaskRequired
public readonly packageTask: Task;
- Type: projen.Task
postCompileTaskRequired
public readonly postCompileTask: Task;
- Type: projen.Task
preCompileTaskRequired
public readonly preCompileTask: Task;
- Type: projen.Task
projectBuildRequired
public readonly projectBuild: ProjectBuild;
- Type: projen.ProjectBuild
Manages the build process of the project.
projenCommandRequired
public readonly projenCommand: string;
- Type: string
The command to use in order to run the projen CLI.
rootRequired
public readonly root: Project;
- Type: projen.Project
The root project.
subprojectsRequired
public readonly subprojects: Project[];
- Type: projen.Project[]
Returns all the subprojects within this project.
tasksRequired
public readonly tasks: Tasks;
- Type: projen.Tasks
Project tasks.
testTaskRequired
public readonly testTask: Task;
- Type: projen.Task
defaultTaskOptional
public readonly defaultTask: Task;
- Type: projen.Task
This is the "default" task, the one that executes "projen".
Undefined if the project is being ejected.
initProjectOptional
initProject- Deprecated: use the
initProjectargument passed toComponent.projectCreation()instead.
public readonly initProject: InitProject;
- Type: projen.InitProject
The options used when this project is bootstrapped via projen new.
It includes the original set of options passed to the CLI and also the JSII FQN of the project type.
parentOptional
public readonly parent: Project;
- Type: projen.Project
A parent project.
If undefined, this is the root project.
autoApproveOptional
public readonly autoApprove: AutoApprove;
- Type: projen.github.AutoApprove
Auto approve set up for this project.
devContainerOptional
public readonly devContainer: DevContainer;
- Type: projen.vscode.DevContainer
Access for .devcontainer.json (used for GitHub Codespaces).
This will be undefined if devContainer boolean is false
githubOptional
public readonly github: GitHub;
- Type: projen.github.GitHub
Access all github components.
This will be undefined for subprojects.
gitpodOptional
public readonly gitpod: Gitpod;
- Type: projen.Gitpod
Access for Gitpod.
This will be undefined if gitpod boolean is false
vscodeOptional
public readonly vscode: VsCode;
- Type: projen.vscode.VsCode
Access all VSCode components.
This will be undefined for subprojects.
artifactsDirectoryRequired
public readonly artifactsDirectory: string;
- Type: 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;
- Type: string
The location of the npm tarball after build (${artifactsDirectory}/js).
bundlerRequired
public readonly bundler: Bundler;
- Type: projen.javascript.Bundler
npmrcRequired
public readonly npmrc: NpmConfig;
- Type: projen.javascript.NpmConfig
The .npmrc file.
packageRequired
public readonly package: NodePackage;
- Type: projen.javascript.NodePackage
API for managing the node package.
runScriptCommandRequired
public readonly runScriptCommand: string;
- Type: 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;
- Type: projen.github.AutoMerge
Component that sets up mergify for merging approved pull requests.
biomeOptional
public readonly biome: Biome;
- Type: projen.javascript.Biome
buildWorkflowOptional
public readonly buildWorkflow: BuildWorkflow;
- Type: projen.build.BuildWorkflow
The PR build GitHub workflow.
undefined if buildWorkflow is disabled.
buildWorkflowJobIdOptional
public readonly buildWorkflowJobId: string;
- Type: string
The job ID of the build workflow.
jestOptional
public readonly jest: Jest;
- Type: projen.javascript.Jest
The Jest configuration (if enabled).
maxNodeVersionOptional
public readonly maxNodeVersion: string;
- Type: string
Maximum node version supported by this package.
The value indicates the package is incompatible with newer versions.
minNodeVersionOptional
public readonly minNodeVersion: string;
- Type: string
The minimum node version required by this package to function.
This value indicates the package is incompatible with older versions.
npmignoreOptional
public readonly npmignore: IgnoreFile;
- Type: projen.IgnoreFile
The .npmignore file.
prettierOptional
public readonly prettier: Prettier;
- Type: projen.javascript.Prettier
releaseOptional
public readonly release: Release;
- Type: projen.release.Release
Release management.
upgradeWorkflowOptional
public readonly upgradeWorkflow: UpgradeDependencies;
- Type: projen.javascript.UpgradeDependencies
The upgrade workflow.
docsDirectoryRequired
public readonly docsDirectory: string;
- Type: string
libdirRequired
public readonly libdir: string;
- Type: string
The directory in which compiled .js files reside.
runnerRequired
public readonly runner: TypeScriptRunner;
- Type: TypeScriptRunner
The TypeScript runner used for executing TypeScript files.
srcdirRequired
public readonly srcdir: string;
- Type: string
The directory in which the .ts sources reside.
testdirRequired
public readonly testdir: string;
- Type: string
The directory in which tests reside.
tsconfigDevRequired
public readonly tsconfigDev: TypescriptConfig;
- Type: projen.javascript.TypescriptConfig
A typescript configuration file which covers all files (sources, tests, projen).
watchTaskRequired
public readonly watchTask: Task;
- Type: projen.Task
The "watch" task.
docgenOptional
public readonly docgen: boolean;
- Type: boolean
eslintOptional
public readonly eslint: Eslint;
- Type: projen.javascript.Eslint
tsconfigOptional
public readonly tsconfig: TypescriptConfig;
- Type: projen.javascript.TypescriptConfig
tsconfigEslintOptional
public readonly tsconfigEslint: TypescriptConfig;
- Type: projen.javascript.TypescriptConfig
Constants
| Name | Type | Description |
|---|---|---|
| string | The name of the default task (the task executed when projen is run without arguments). |
| string | No description. |
DEFAULT_TASKRequired
public readonly DEFAULT_TASK: string;
- Type: string
The name of the default task (the task executed when projen is run without arguments).
Normally this task should synthesize the project files.
DEFAULT_TS_JEST_TRANFORM_PATTERNRequired
public readonly DEFAULT_TS_JEST_TRANFORM_PATTERN: string;
- Type: string
TypeScriptProject
TypeScript project.
Initializers
import { typescript } from 'projen'
new typescript.TypeScriptProject(options: TypeScriptProjectOptions)
| Name | Type | Description |
|---|---|---|
| | No description. |
optionsRequired
- Type: TypeScriptProjectOptions
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Applies one or more mixins to this construct. |
| Exclude the matching files from pre-synth cleanup. |
| Adds a .gitignore pattern. |
| Adds patterns to be ignored by npm. |
| Adds a new task to this project. |
| Marks the provided file(s) as being generated. |
| Called after all components are synthesized. |
| Called before all components are synthesized. |
| Removes a task from a project. |
| Returns the shell command to execute in order to run a task. |
| Synthesize all project files into outdir. |
| Finds a file at the specified relative path within this project and all its subprojects. |
| Finds an object file (like JsonFile, YamlFile, etc.) by name. |
| Finds a file at the specified relative path within this project and removes it. |
| No description. |
| Defines bundled dependencies. |
| Defines normal dependencies. |
| Defines development/test dependencies. |
| Directly set fields in package.json. |
| Adds keywords to package.json (deduplicated). |
| Defines peer dependencies. |
| Replaces the contents of multiple npm package.json scripts. |
| Removes the npm script (always successful). |
| Returns the set of workflow steps which should be executed to bootstrap a workflow. |
| Replaces the contents of an npm package.json script. |
toString
public toString(): string
Returns a string representation of this construct.
with
public with(mixins: ...IMixin[]): IConstruct
Applies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.
mixinsRequired
- Type: ...constructs.IMixin[]
The mixins to apply.
addExcludeFromCleanup
public addExcludeFromCleanup(globs: ...string[]): void
Exclude the matching files from pre-synth cleanup.
Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.
globsRequired
- Type: ...string[]
The glob patterns to match.
addGitIgnore
public addGitIgnore(pattern: string): void
Adds a .gitignore pattern.
patternRequired
- Type: string
The glob pattern to ignore.
addPackageIgnore
public addPackageIgnore(pattern: string): void
Adds patterns to be ignored by npm.
patternRequired
- Type: string
The pattern to ignore.
addTask
public addTask(name: string, props?: TaskOptions): Task
Adds a new task to this project.
This will fail if the project already has a task with this name.
nameRequired
- Type: string
The task name to add.
propsOptional
- Type: projen.TaskOptions
Task properties.
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
- Type: string
the glob pattern to match (could be a file path).
postSynthesize
public postSynthesize(): void
Called after all components are synthesized.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before all components are synthesized.
removeTask
public removeTask(name: string): Task
Removes a task from a project.
nameRequired
- Type: string
The name of the task to remove.
runTaskCommand
public runTaskCommand(task: Task): string
Returns the shell command to execute in order to run a task.
This will
typically be pnpm projen TASK.
taskRequired
- Type: projen.Task
The task for which the command is required.
synth
public synth(): void
Synthesize all project files into outdir.
- Call "this.preSynthesize()"
- Delete all generated files
- Synthesize all subprojects
- Synthesize all components of this project
- Call "projectCreation()" for all components, only if the project is being created for the first time
- Call "postSynthesize()" for all components of this project
- Call "this.postSynthesize()"
- Call "postProjectCreation()" for all components, only if the project is being created for the first time
tryFindFile
public tryFindFile(filePath: string): FileBase
Finds a file at the specified relative path within this project and all its subprojects.
filePathRequired
- Type: string
The file path.
If this path is relative, it will be resolved from the root of this project.
tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile
Finds an object file (like JsonFile, YamlFile, etc.) by name.
filePathRequired
- Type: string
The file path.
tryRemoveFile
public tryRemoveFile(filePath: string): FileBase
Finds a file at the specified relative path within this project and removes it.
filePathRequired
- Type: string
The file path.
If this path is relative, it will be resolved from the root of this project.
addBins
public addBins(bins: {[ key: string ]: string}): void
binsRequired
- Type: {[ key: string ]: string}
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
- Type: ...string[]
Names modules to install.
By default, the the dependency will
be installed in the next pnpm projen run and the version will be recorded
in your package.json file. You can upgrade manually or using pnpm add/update. If you wish to specify a version range use this syntax:
module@^7.
addDeps
public addDeps(deps: ...string[]): void
Defines normal dependencies.
depsRequired
- Type: ...string[]
Names modules to install.
By default, the the dependency will
be installed in the next pnpm projen run and the version will be recorded
in your package.json file. You can upgrade manually or using pnpm add/update. If you wish to specify a version range use this syntax:
module@^7.
addDevDeps
public addDevDeps(deps: ...string[]): void
Defines development/test dependencies.
depsRequired
- Type: ...string[]
Names modules to install.
By default, the the dependency will
be installed in the next pnpm projen run and the version will be recorded
in your package.json file. You can upgrade manually or using pnpm add/update. 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
- Type: {[ key: string ]: any}
The fields to set.
addKeywords
public addKeywords(keywords: ...string[]): void
Adds keywords to package.json (deduplicated).
keywordsRequired
- Type: ...string[]
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
- Type: ...string[]
Names modules to install.
By default, the the dependency will
be installed in the next pnpm projen run and the version will be recorded
in your package.json file. You can upgrade manually or using pnpm add/update. 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
- Type: {[ key: string ]: string}
The scripts to set.
removeScript
public removeScript(name: string): void
Removes the npm script (always successful).
nameRequired
- Type: string
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
- Type: projen.javascript.RenderWorkflowSetupOptions
Options.
setScript
public setScript(name: string, command: string): void
Replaces the contents of an npm package.json script.
nameRequired
- Type: string
The script name.
commandRequired
- Type: string
The command to execute.
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| Test whether the given construct is a project. |
| Find the closest ancestor project for given construct. |
isConstruct
import { typescript } from 'projen'
typescript.TypeScriptProject.isConstruct(x: any)
Checks if x is a construct.
Use this method instead of instanceof to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct in each copy of the constructs library
is seen as a different class, and an instance of one class will not test as
instanceof the other class. npm install will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof will behave
unpredictably. It is safest to avoid using instanceof, and using
this type-testing method instead.
xRequired
- Type: any
Any object.
isProject
import { typescript } from 'projen'
typescript.TypeScriptProject.isProject(x: any)
Test whether the given construct is a project.
xRequired
- Type: any
of
import { typescript } from 'projen'
typescript.TypeScriptProject.of(construct: IConstruct)
Find the closest ancestor project for given construct.
When given a project, this it the project itself.
constructRequired
- Type: constructs.IConstruct
Properties
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| projen.Task | No description. |
| boolean | Whether to commit the managed files by default. |
| projen.Task | No description. |
| projen.Component[] | Returns all the components within this project. |
| projen.Dependencies | Project dependencies. |
| boolean | Whether or not the project is being ejected. |
| projen.FileBase[] | All files in this project. |
| projen.GitAttributesFile | The .gitattributes file for this repository. |
| projen.IgnoreFile | .gitignore. |
| projen.Logger | Logging utilities. |
| string | Project name. |
| string | Absolute output directory of this project. |
| projen.Task | No description. |
| projen.Task | No description. |
| projen.Task | No description. |
| projen.ProjectBuild | Manages the build process of the project. |
| string | The command to use in order to run the projen CLI. |
| projen.Project | The root project. |
| projen.Project[] | Returns all the subprojects within this project. |
| projen.Tasks | Project tasks. |
| projen.Task | No description. |
| projen.Task | This is the "default" task, the one that executes "projen". |
| projen.InitProject | The options used when this project is bootstrapped via projen new. |
| projen.Project | A parent project. |
| projen.github.AutoApprove | Auto approve set up for this project. |
| projen.vscode.DevContainer | Access for .devcontainer.json (used for GitHub Codespaces). |
| projen.github.GitHub | Access all github components. |
| projen.Gitpod | Access for Gitpod. |
| projen.vscode.VsCode | Access all VSCode components. |
| string | The build output directory. |
| string | The location of the npm tarball after build (${artifactsDirectory}/js). |
| projen.javascript.Bundler | No description. |
| projen.javascript.NpmConfig | The .npmrc file. |
| projen.javascript.NodePackage | API for managing the node package. |
| string | The command to use to run scripts (e.g. yarn run or npm run depends on the package manager). |
| projen.github.AutoMerge | Component that sets up mergify for merging approved pull requests. |
| projen.javascript.Biome | No description. |
| projen.build.BuildWorkflow | The PR build GitHub workflow. |
| string | The job ID of the build workflow. |
| projen.javascript.Jest | The Jest configuration (if enabled). |
| string | Maximum node version supported by this package. |
| string | The minimum node version required by this package to function. |
| projen.IgnoreFile | The .npmignore file. |
| projen.javascript.Prettier | No description. |
| projen.release.Release | Release management. |
| projen.javascript.UpgradeDependencies | The upgrade workflow. |
| string | No description. |
| string | The directory in which compiled .js files reside. |
| | The TypeScript runner used for executing TypeScript files. |
| string | The directory in which the .ts sources reside. |
| string | The directory in which tests reside. |
| projen.javascript.TypescriptConfig | A typescript configuration file which covers all files (sources, tests, projen). |
| projen.Task | The "watch" task. |
| boolean | No description. |
| projen.javascript.Eslint | No description. |
| projen.javascript.TypescriptConfig | No description. |
| projen.javascript.TypescriptConfig | No description. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
buildTaskRequired
public readonly buildTask: Task;
- Type: projen.Task
commitGeneratedRequired
public readonly commitGenerated: boolean;
- Type: boolean
Whether to commit the managed files by default.
compileTaskRequired
public readonly compileTask: Task;
- Type: projen.Task
componentsRequired
public readonly components: Component[];
- Type: projen.Component[]
Returns all the components within this project.
depsRequired
public readonly deps: Dependencies;
- Type: projen.Dependencies
Project dependencies.
ejectedRequired
public readonly ejected: boolean;
- Type: boolean
Whether or not the project is being ejected.
filesRequired
public readonly files: FileBase[];
- Type: projen.FileBase[]
All files in this project.
gitattributesRequired
public readonly gitattributes: GitAttributesFile;
- Type: projen.GitAttributesFile
The .gitattributes file for this repository.
gitignoreRequired
public readonly gitignore: IgnoreFile;
- Type: projen.IgnoreFile
.gitignore.
loggerRequired
public readonly logger: Logger;
- Type: projen.Logger
Logging utilities.
nameRequired
public readonly name: string;
- Type: string
Project name.
outdirRequired
public readonly outdir: string;
- Type: string
Absolute output directory of this project.
packageTaskRequired
public readonly packageTask: Task;
- Type: projen.Task
postCompileTaskRequired
public readonly postCompileTask: Task;
- Type: projen.Task
preCompileTaskRequired
public readonly preCompileTask: Task;
- Type: projen.Task
projectBuildRequired
public readonly projectBuild: ProjectBuild;
- Type: projen.ProjectBuild
Manages the build process of the project.
projenCommandRequired
public readonly projenCommand: string;
- Type: string
The command to use in order to run the projen CLI.
rootRequired
public readonly root: Project;
- Type: projen.Project
The root project.
subprojectsRequired
public readonly subprojects: Project[];
- Type: projen.Project[]
Returns all the subprojects within this project.
tasksRequired
public readonly tasks: Tasks;
- Type: projen.Tasks
Project tasks.
testTaskRequired
public readonly testTask: Task;
- Type: projen.Task
defaultTaskOptional
public readonly defaultTask: Task;
- Type: projen.Task
This is the "default" task, the one that executes "projen".
Undefined if the project is being ejected.
initProjectOptional
initProject- Deprecated: use the
initProjectargument passed toComponent.projectCreation()instead.
public readonly initProject: InitProject;
- Type: projen.InitProject
The options used when this project is bootstrapped via projen new.
It includes the original set of options passed to the CLI and also the JSII FQN of the project type.
parentOptional
public readonly parent: Project;
- Type: projen.Project
A parent project.
If undefined, this is the root project.
autoApproveOptional
public readonly autoApprove: AutoApprove;
- Type: projen.github.AutoApprove
Auto approve set up for this project.
devContainerOptional
public readonly devContainer: DevContainer;
- Type: projen.vscode.DevContainer
Access for .devcontainer.json (used for GitHub Codespaces).
This will be undefined if devContainer boolean is false
githubOptional
public readonly github: GitHub;
- Type: projen.github.GitHub
Access all github components.
This will be undefined for subprojects.
gitpodOptional
public readonly gitpod: Gitpod;
- Type: projen.Gitpod
Access for Gitpod.
This will be undefined if gitpod boolean is false
vscodeOptional
public readonly vscode: VsCode;
- Type: projen.vscode.VsCode
Access all VSCode components.
This will be undefined for subprojects.
artifactsDirectoryRequired
public readonly artifactsDirectory: string;
- Type: 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;
- Type: string
The location of the npm tarball after build (${artifactsDirectory}/js).
bundlerRequired
public readonly bundler: Bundler;
- Type: projen.javascript.Bundler
npmrcRequired
public readonly npmrc: NpmConfig;
- Type: projen.javascript.NpmConfig
The .npmrc file.
packageRequired
public readonly package: NodePackage;
- Type: projen.javascript.NodePackage
API for managing the node package.
runScriptCommandRequired
public readonly runScriptCommand: string;
- Type: 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;
- Type: projen.github.AutoMerge
Component that sets up mergify for merging approved pull requests.
biomeOptional
public readonly biome: Biome;
- Type: projen.javascript.Biome
buildWorkflowOptional
public readonly buildWorkflow: BuildWorkflow;
- Type: projen.build.BuildWorkflow
The PR build GitHub workflow.
undefined if buildWorkflow is disabled.
buildWorkflowJobIdOptional
public readonly buildWorkflowJobId: string;
- Type: string
The job ID of the build workflow.
jestOptional
public readonly jest: Jest;
- Type: projen.javascript.Jest
The Jest configuration (if enabled).
maxNodeVersionOptional
public readonly maxNodeVersion: string;
- Type: string
Maximum node version supported by this package.
The value indicates the package is incompatible with newer versions.
minNodeVersionOptional
public readonly minNodeVersion: string;
- Type: string
The minimum node version required by this package to function.
This value indicates the package is incompatible with older versions.
npmignoreOptional
public readonly npmignore: IgnoreFile;
- Type: projen.IgnoreFile
The .npmignore file.
prettierOptional
public readonly prettier: Prettier;
- Type: projen.javascript.Prettier
releaseOptional
public readonly release: Release;
- Type: projen.release.Release
Release management.
upgradeWorkflowOptional
public readonly upgradeWorkflow: UpgradeDependencies;
- Type: projen.javascript.UpgradeDependencies
The upgrade workflow.
docsDirectoryRequired
public readonly docsDirectory: string;
- Type: string
libdirRequired
public readonly libdir: string;
- Type: string
The directory in which compiled .js files reside.
runnerRequired
public readonly runner: TypeScriptRunner;
- Type: TypeScriptRunner
The TypeScript runner used for executing TypeScript files.
srcdirRequired
public readonly srcdir: string;
- Type: string
The directory in which the .ts sources reside.
testdirRequired
public readonly testdir: string;
- Type: string
The directory in which tests reside.
tsconfigDevRequired
public readonly tsconfigDev: TypescriptConfig;
- Type: projen.javascript.TypescriptConfig
A typescript configuration file which covers all files (sources, tests, projen).
watchTaskRequired
public readonly watchTask: Task;
- Type: projen.Task
The "watch" task.
docgenOptional
public readonly docgen: boolean;
- Type: boolean
eslintOptional
public readonly eslint: Eslint;
- Type: projen.javascript.Eslint
tsconfigOptional
public readonly tsconfig: TypescriptConfig;
- Type: projen.javascript.TypescriptConfig
tsconfigEslintOptional
public readonly tsconfigEslint: TypescriptConfig;
- Type: projen.javascript.TypescriptConfig
Constants
| Name | Type | Description |
|---|---|---|
| string | The name of the default task (the task executed when projen is run without arguments). |
| string | No description. |
DEFAULT_TASKRequired
public readonly DEFAULT_TASK: string;
- Type: string
The name of the default task (the task executed when projen is run without arguments).
Normally this task should synthesize the project files.
DEFAULT_TS_JEST_TRANFORM_PATTERNRequired
public readonly DEFAULT_TS_JEST_TRANFORM_PATTERN: string;
- Type: string
TypeScriptRunner
The runner used to execute TypeScript files.
A runner is a {@link FutureComponent }: create it standalone (e.g. via one of the static factories) and it is attached to a project by the component that consumes it. Use {@link TypeScriptRunner.copy} to derive a new runner with adjusted options.
Methods
| Name | Description |
|---|---|
| Returns a string representation of this construct. |
| Applies one or more mixins to this construct. |
| Called once, right after postSynthesize(), only when the project is created for the first time. |
| Called after synthesis. |
| Called before synthesis. |
| Called once, right after synthesize(), only when the project is created for the first time. |
| Synthesizes files to the project output directory. |
| Attach the component to a scope. Only now does it become usable. |
| Attach the component if it isn't already, without caring where. |
| Produce the {@link RunScriptConfig} to run the given entrypoint with this runner. |
| Returns a new (detached) runner of the same kind, with overrides merged over the current options. |
toString
public toString(): string
Returns a string representation of this construct.
with
public with(mixins: ...IMixin[]): IConstruct
Applies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.
mixinsRequired
- Type: ...constructs.IMixin[]
The mixins to apply.
postProjectCreation
public postProjectCreation(initProject: InitProject): void
Called once, right after postSynthesize(), only when the project is created for the first time.
It does not run on later projen invocations. It only fires for projen new (or Projects.createProject).
It is also skipped when post-synthesis steps are disabled, e.g. --no-post or PROJEN_DISABLE_POST.
Use it for one-off setup that can be turned off by the user, like running a task to give the user immediate
feedback on their new project. Order across components is not guaranteed.
initProjectRequired
- Type: projen.InitProject
Details about how the project was created, e.g. its type and the original CLI args.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
projectCreation
public projectCreation(initProject: InitProject): void
Called once, right after synthesize(), only when the project is created for the first time.
It does not run on later projen invocations. It only fires for projen new (or Projects.createProject).
Use it for deterministic, one-off file generation. Order across components is not guaranteed.
initProjectRequired
- Type: projen.InitProject
Details about how the project was created, e.g. its type and the original CLI args.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
attach
public attach(scope: IConstruct, id?: string): FutureComponent
Attach the component to a scope. Only now does it become usable.
Returns the real, unwrapped component (not the proxy). A component may be
attached exactly once; attaching an already-attached component throws (copy
it first to attach a variant elsewhere). Use tryAttach() if you don't care
whether it has already been attached.
scopeRequired
- Type: constructs.IConstruct
idOptional
- Type: string
tryAttach
public tryAttach(scope: IConstruct, id?: string): FutureComponent
Attach the component if it isn't already, without caring where.
Unlike attach(), never throws on an already-attached component: if attached
anywhere at all, the existing instance is returned and scope is ignored.
Use attach() when attaching to a specific scope is part of your contract
and a pre-existing attachment elsewhere would be a bug.
scopeRequired
- Type: constructs.IConstruct
idOptional
- Type: string
configFor
public configFor(entrypoint: string): RunScriptConfig
Produce the {@link RunScriptConfig} to run the given entrypoint with this runner.
entrypointRequired
- Type: string
copy
public copy(overrides?: TypeScriptRunnerOptions): TypeScriptRunner
Returns a new (detached) runner of the same kind, with overrides merged over the current options.
Safe to call while detached.
overridesOptional
- Type: TypeScriptRunnerOptions
Static Functions
| Name | Description |
|---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| Use the native Node.js TypeScript support. |
| Use ts-node to execute TypeScript files. |
| Use tsx to execute TypeScript files. |
isConstruct
import { typescript } from 'projen'
typescript.TypeScriptRunner.isConstruct(x: any)
Checks if x is a construct.
Use this method instead of instanceof to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct in each copy of the constructs library
is seen as a different class, and an instance of one class will not test as
instanceof the other class. npm install will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof will behave
unpredictably. It is safest to avoid using instanceof, and using
this type-testing method instead.
xRequired
- Type: any
Any object.
isComponent
import { typescript } from 'projen'
typescript.TypeScriptRunner.isComponent(x: any)
Test whether the given construct is a component.
xRequired
- Type: any
nodejs
import { typescript } from 'projen'
typescript.TypeScriptRunner.nodejs(options?: NodeRunnerOptions)
Use the native Node.js TypeScript support.
Requires Node.js 22.18.0 or later. The script must use ESM style imports (no directories, include file endings, etc.).
Named nodejs (not node) because a runner is a construct, and node is
reserved by constructs.Construct for the construct's tree node.
optionsOptional
- Type: NodeRunnerOptions
tsNode
import { typescript } from 'projen'
typescript.TypeScriptRunner.tsNode(options?: TsNodeRunnerOptions)
Use ts-node to execute TypeScript files.
optionsOptional
- Type: TsNodeRunnerOptions
tsx
import { typescript } from 'projen'
typescript.TypeScriptRunner.tsx(options?: TsxRunnerOptions)
Use tsx to execute TypeScript files.
tsx is a fast TypeScript runtime that does not perform type-checking. You may opt-in to an explicit type-checking step before the script is run.
optionsOptional
- Type: TsxRunnerOptions
Properties
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| boolean | Whether attach() has been called. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: projen.Project
attachedRequired
public readonly attached: boolean;
- Type: boolean
Whether attach() has been called.
A convenience for tests/introspection;
prefer tryAttach() over reading this and branching.
Structs
NodeRunnerOptions
Options for the native Node.js TypeScript runner.
Initializer
import { typescript } from 'projen'
const nodeRunnerOptions: typescript.NodeRunnerOptions = { ... }
Properties
| Name | Type | Description |
|---|---|---|
| boolean | Whether to also enable --experimental-transform-types. |
| string | Path to the tsconfig file for type-checking. |
| boolean | Whether to type-check the entrypoint before executing. |
experimentalTransformTypesOptional
public readonly experimentalTransformTypes: boolean;
- Type: boolean
- Default: false
Whether to also enable --experimental-transform-types.
tsconfigOptional
public readonly tsconfig: string;
- Type: string
- Default: typescript default discovery
Path to the tsconfig file for type-checking.
When specified, will use this tsconfig for type-checking (if enabled).
typeCheckOptional
public readonly typeCheck: boolean;
- Type: boolean
- Default: false
Whether to type-check the entrypoint before executing.
Because the native Node.js TypeScript does not type check code,
you may want to enable this for additional type safety.
When enabled, runs tsc --noEmit, using the provided tsconfig.
ProjenrcOptions
Initializer
import { typescript } from 'projen'
const projenrcOptions: typescript.ProjenrcOptions = { ... }
Properties
| Name | Type | Description |
|---|---|---|
| string | The name of the projenrc file. |
| string | A directory tree that may contain *.ts files that can be referenced from your projenrc typescript file. |
| | The runner to use for executing TypeScript files. |
| boolean | Whether to use SWC for ts-node. |
filenameOptional
public readonly filename: string;
- Type: string
- Default: ".projenrc.ts"
The name of the projenrc file.
projenCodeDirOptional
public readonly projenCodeDir: string;
- Type: string
- Default: "projenrc"
A directory tree that may contain *.ts files that can be referenced from your projenrc typescript file.
runnerOptional
public readonly runner: TypeScriptRunner;
- Type: TypeScriptRunner
- Default: the project's runner
The runner to use for executing TypeScript files.
swcOptional
swc- Deprecated: Use
runner: TypeScriptRunner.tsNode({ swc: true })instead.
public readonly swc: boolean;
- Type: boolean
- Default: false
Whether to use SWC for ts-node.
ProjenrcTsOptions
Initializer
import { typescript } from 'projen'
const projenrcTsOptions: typescript.ProjenrcTsOptions = { ... }
Properties
| Name | Type | Description |
|---|---|---|
| string | The name of the projenrc file. |
| string | A directory tree that may contain *.ts files that can be referenced from your projenrc typescript file. |
| | The runner to use for executing TypeScript files. |
| string | The name of the tsconfig file that will be used by the runner when compiling projen source files. |
filenameOptional
public readonly filename: string;
- Type: string
- Default: ".projenrc.ts"
The name of the projenrc file.
projenCodeDirOptional
public readonly projenCodeDir: string;
- Type: string
- Default: "projenrc"
A directory tree that may contain *.ts files that can be referenced from your projenrc typescript file.
runnerOptional
public readonly runner: TypeScriptRunner;
- Type: TypeScriptRunner
- Default: TypeScriptRunner.tsNode()
The runner to use for executing TypeScript files.
tsconfigFileNameOptional
tsconfigFileName- Deprecated: Use
runnerto configure the tsconfigFileName directly.
public readonly tsconfigFileName: string;
- Type: string
- Default: "tsconfig.projen.json"
The name of the tsconfig file that will be used by the runner when compiling projen source files.
TsJestOptions
Initializer
import { typescript } from 'projen'
const tsJestOptions: typescript.TsJestOptions = { ... }
Properties
| Name | Type | Description |
|---|---|---|
| | Override the default ts-jest transformer configuration. |
| string | Which files should ts-jest act upon. |
transformOptionsOptional
public readonly transformOptions: TsJestTransformOptions;
- Type: TsJestTransformOptions
Override the default ts-jest transformer configuration.
transformPatternOptional
public readonly transformPattern: string;
- Type: string
- Default: "^.+\.[t]sx?$"
Which files should ts-jest act upon.
TsJestTransformOptions
https://kulshekhar.github.io/ts-jest/docs/getting-started/options
Initializer
import { typescript } from 'projen'
const tsJestTransformOptions: typescript.TsJestTransformOptions = { ... }
Properties
| Name | Type | Description |
|---|---|---|
| {[ key: string ]: any} | Custom TypeScript AST transformers. |
| | Babel(Jest) related configuration. |
| string | TypeScript module to use as compiler. |
| | Diagnostics related configuration. |
| boolean | Run ts-jest tests with this TSConfig isolatedModules setting. |
| string | Files which will become modules returning self content. |
| | TypeScript compiler related configuration. |
| boolean | Enable ESM support. |
astTransformersOptional
public readonly astTransformers: {[ key: string ]: any};
- Type: {[ key: string ]: any}
- Default: auto
Custom TypeScript AST transformers.
babelConfigOptional
public readonly babelConfig: TsJestBabelConfig;
- Type: TsJestBabelConfig
- Default: TsJestBabelConfig.disabled()
Babel(Jest) related configuration.
compilerOptional
public readonly compiler: string;
- Type: string
- Default: "typescript"
TypeScript module to use as compiler.
diagnosticsOptional
public readonly diagnostics: TsJestDiagnostics;
- Type: TsJestDiagnostics
- Default: TsJestDiagnostics.all()
Diagnostics related configuration.
isolatedModulesOptional
public readonly isolatedModules: boolean;
- Type: boolean
- Default: false
Run ts-jest tests with this TSConfig isolatedModules setting.
You'll lose type-checking ability and some features such as const enum, but in the case you plan on using Jest with the cache disabled (jest --no-cache), your tests will then run much faster.
https://kulshekhar.github.io/ts-jest/docs/getting-started/options/isolatedModules
stringifyContentPathRegexOptional
public readonly stringifyContentPathRegex: string;
- Type: string
- Default: disabled
Files which will become modules returning self content.
tsconfigOptional
public readonly tsconfig: TsJestTsconfig;
- Type: TsJestTsconfig
- Default: Your project's
tsconfigDevfile.
TypeScript compiler related configuration.
useESMOptional
public readonly useESM: boolean;
- Type: boolean
- Default: auto
Enable ESM support.
TsNodeRunnerOptions
Options for the ts-node runner.
Initializer
import { typescript } from 'projen'
const tsNodeRunnerOptions: typescript.TsNodeRunnerOptions = { ... }
Properties
| Name | Type | Description |
|---|---|---|
| boolean | Whether to use SWC for transpilation. |
| string | Path to the tsconfig file to use. |
| boolean | Whether to type-check the script during executing. |
swcOptional
public readonly swc: boolean;
- Type: boolean
- Default: false
Whether to use SWC for transpilation.
This will disable type-checking.
tsconfigOptional
public readonly tsconfig: string;
- Type: string
- Default: ts-node default discovery
Path to the tsconfig file to use.
typeCheckOptional
public readonly typeCheck: boolean;
- Type: boolean
- Default: true
Whether to type-check the script during executing.
TsxRunnerOptions
Options for the tsx runner.
Initializer
import { typescript } from 'projen'
const tsxRunnerOptions: typescript.TsxRunnerOptions = { ... }
Properties
| Name | Type | Description |
|---|---|---|
| string | Path to the tsconfig file to use. |
| boolean | Whether to type-check the entrypoint before executing. |
tsconfigOptional
public readonly tsconfig: string;
- Type: string
- Default: tsx/typescript default discovery
Path to the tsconfig file to use.
When specified, will use this tsconfig for running tsx and type-checking (if enabled).
typeCheckOptional
public readonly typeCheck: boolean;
- Type: boolean
- Default: false
Whether to type-check the entrypoint before executing.
Because tsx does not type check code, you may want to enable this for additional type safety.
When enabled, runs tsc --noEmit, using the provided tsconfig.
TypeScriptProjectOptions
Initializer
import { typescript } from 'projen'
const typeScriptProjectOptions: typescript.TypeScriptProjectOptions = { ... }
Properties
| Name | Type | Description |
|---|---|---|
| string | This is the name of your project. |
| boolean | Whether to commit the managed files by default. |
| projen.IgnoreFileOptions | Configuration options for .gitignore file. |
| projen.GitOptions | Configuration options for git. |
| projen.LoggerOptions | Configure logging options such as verbosity. |
| string | The root directory of the project. |
| projen.Project | The parent project, if this project is part of a bigger project. |
| boolean | Generate a project tree file (.projen/tree.json) that shows all components and their relationships. Useful for understanding your project structure and debugging. |
| string | The shell command to use in order to run the projen CLI. |
| boolean | Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation. |
| projen.ProjenrcJsonOptions | Options for .projenrc.json. |
| boolean | Use renovatebot to handle dependency upgrades. |
| projen.RenovatebotOptions | Options for renovatebot. |
| projen.github.AutoApproveOptions | Enable and configure the 'auto approve' workflow. |
| boolean | Enable automatic merging on GitHub. |
| projen.github.AutoMergeOptions | Configure options for automatic merging on GitHub. |
| boolean | Add a clobber task which resets the repo to origin. |
| boolean | Add a VSCode development environment (used for GitHub Codespaces). |
| boolean | Enable GitHub integration. |
| projen.github.GitHubOptions | Options for GitHub integration. |
| boolean | Add a Gitpod development environment. |
| projen.github.GithubCredentials | Choose a method of providing GitHub API access for projen workflows. |
| projen.SampleReadmeProps | The README setup. |
| boolean | Auto-close of stale issues and pull request. |
| projen.github.StaleOptions | Auto-close stale issues and pull requests. |
| boolean | Enable VSCode integration. |
| boolean | Automatically add the resolved packageManager to devEngines.packageManager in package.json, setting onFail to ignore. |
| boolean | Allow the project to include peerDependencies and bundledDependencies. |
| string[] | List of dependency (package) names that are allowed to run lifecycle install scripts (preinstall, install, postinstall, prepare) during dependency installation. |
| string | Author's e-mail. |
| string | Author's name. |
| boolean | Is the author an organization. |
| string | Author's URL / Website. |
| boolean | Automatically add all executables under the bin directory to your package.json file under the bin section. |
| {[ key: string ]: string} | Binary programs vended with your module. |
| string | The email address to which issues should be reported. |
| string | The url to your project's issue tracker. |
| string[] | List of dependencies to bundle into this module. |
| string | The version of Bun to use if using Bun as a package manager. |
| projen.javascript.CodeArtifactOptions | Options for npm packages using AWS CodeArtifact. |
| boolean | Automatically delete lockfiles from package managers that are not the active one. |
| string[] | Runtime dependencies of this module. |
| string | The description is just a string that helps people understand the purpose of the package. |
| string[] | Build dependencies for this module. |
| projen.javascript.DevEngines | Configure the devEngines field in package.json. |
| string | Module entrypoint (main in package.json). |
| string | Package's Homepage / Website. |
| string[] | Keywords to include in package.json. |
| string | License's SPDX identifier. |
| boolean | Indicates if a license should be added. |
| string | The maximum node version supported by this package. Most projects should not use this option. |
| string | The minimum node version required by this package to function. Most projects should not use this option. |
| projen.javascript.NpmAccess | Access level of the npm package. |
| boolean | Should provenance statements be generated when the package is published. |
| string | The base URL of the npm package registry. |
| string | GitHub secret which contains the NPM token to use when publishing packages. |
| boolean | Use trusted publishing for publishing to npmjs.com Needs to be pre-configured on npm.js to work. |
| projen.javascript.NodePackageManager | The Node Package Manager used to execute scripts. |
| string | The "name" in package.json. |
| projen.javascript.PeerDependencyOptions | Options for peerDeps. |
| string[] | Peer dependencies for this module. |
| projen.javascript.PnpmOptions | Options for pnpm. |
| string | The version of PNPM to use if using PNPM as a package manager. |
| string | The repository is the location where the actual code for your package lives. |
| string | If the package.json for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives. |
| projen.javascript.ScopedPackagesOptions[] | Options for privately hosted scoped packages. |
| string | Package's Stability. |
| projen.javascript.YarnBerryOptions | Options for Yarn Berry. |
| string | The commit-and-tag-version compatible package used to bump the package version, as a dependency string. |
| string | Version requirement of publib which is used to publish modules to npm. |
| number | Major version to release from the default branch. |
| number | Minimal Major version to release. |
| string | A shell command to control the next version to release. |
| string | The npmDistTag to use when publishing from the default branch. |
| projen.github.workflows.JobStep[] | Steps to execute after build as part of the release workflow. |
| string | Bump versions from the default branch as pre-releases (e.g. "beta", "alpha", "pre"). |
| boolean | Instead of actually publishing to package managers, just print the publishing command. |
| boolean | Define publishing tasks that can be executed manually as well as workflows. |
| projen.ReleasableCommits | Find commits that should be considered releasable Used to decide if a release is required. |
| {[ key: string ]: projen.release.BranchOptions} | Defines additional release branches. |
| string | The GitHub Actions environment used for the release. |
| boolean | Create a github issue on every failed publishing task. |
| string | The label to apply to issues indicating publish failures. |
| string | Automatically add the given prefix to release tags. Useful if you are releasing on multiple branches with overlapping version numbers. |
| projen.release.ReleaseTrigger | The release trigger to use. |
| {[ key: string ]: string} | Build environment variables for release workflows. |
| string | The name of the default release workflow. |
| projen.github.workflows.JobStep[] | A set of workflow steps to execute in order to setup the workflow container. |
| {[ key: string ]: any} | Custom configuration used when creating changelog with commit-and-tag-version package. |
| string | Container image to use for GitHub workflows. |
| string[] | Github Runner selection labels. |
| projen.GroupRunnerOptions | Github Runner Group selection options. |
| string | A directory which will contain build artifacts. |
| boolean | Run security audit on dependencies. |
| projen.javascript.AuditOptions | Security audit options. |
| boolean | Automatically approve deps upgrade PRs, allowing them to be merged by mergify (if configured). |
| boolean | Setup Biome. |
| projen.javascript.BiomeOptions | Biome options. |
| boolean | Define a GitHub workflow for building PRs. |
| projen.javascript.BuildWorkflowOptions | Options for PR build workflow. |
| projen.javascript.BundlerOptions | Options for Bundler. |
| projen.javascript.LicenseCheckerOptions | Configure which licenses should be deemed acceptable for use by dependencies. |
| boolean | Define a GitHub workflow step for sending code coverage metrics to https://codecov.io/ Uses codecov/codecov-action@v5 By default, OIDC auth is used. Alternatively a token can be provided via codeCovTokenSecret. |
| string | Define the secret name for a specified https://codecov.io/ token. |
| string | License copyright owner. |
| string | The copyright years to put in the LICENSE file. |
| string | The name of the main release branch. |
| boolean | Use dependabot to handle dependency upgrades. |
| projen.github.DependabotOptions | Options for dependabot. |
| boolean | Use tasks and github workflows to handle dependency upgrades. |
| projen.javascript.UpgradeDependenciesOptions | Options for UpgradeDependencies. |
| string[] | Additional entries to .gitignore. |
| boolean | Setup jest unit tests. |
| projen.javascript.JestOptions | Jest options. |
| boolean | Defines an .npmignore file. Normally this is only needed for libraries that are packaged as tarballs. |
| projen.IgnoreFileOptions | Configuration options for .npmignore file. |
| boolean | Defines a package task that will produce an npm tarball under the artifacts directory (e.g. dist). |
| boolean | Setup prettier. |
| projen.javascript.PrettierOptions | Prettier options. |
| boolean | Indicates of "projen" should be installed as a devDependency. |
| boolean | Generate (once) .projenrc.js (in JavaScript). Set to false in order to disable .projenrc.js generation. |
| projen.javascript.ProjenrcOptions | Options for .projenrc.js. |
| string | Version of projen to install. |
| boolean | Include a GitHub pull request template. |
| string[] | The contents of the pull request template. |
| boolean | Add release management to this project. |
| boolean | Automatically release to npm when new versions are introduced. |
| projen.github.workflows.JobStep[] | Workflow steps to use in order to bootstrap this repo. |
| projen.github.GitIdentity | The git identity to use in workflows. |
| string | The node version used in GitHub Actions workflows. |
| boolean | Enable Node.js package cache in GitHub workflows. |
| boolean | Do not generate a tsconfig.json file (used by jsii projects since tsconfig.json is generated by the jsii compiler). |
| boolean | Do not generate a development tsconfig file. |
| boolean | Docgen by Typedoc. |
| string | Docs directory. |
| string | The .d.ts file that includes the type declarations for this module. |
| boolean | Setup eslint. |
| projen.javascript.EslintOptions | Eslint options. |
| string | Typescript artifacts output directory. |
| boolean | Use TypeScript for your projenrc file (.projenrc.ts). |
| | Options for .projenrc.ts. |
| | The TypeScript runner to use for executing TypeScript files. |
| boolean | Generate one-time sample in src/ and test/ if there are no files there. |
| string | Typescript sources directory. |
| string | Jest tests directory. Tests files should be named xxx.test.ts. |
| projen.javascript.TypescriptConfigOptions | Custom TSConfig. |
| projen.javascript.TypescriptConfigOptions | Custom tsconfig options for the development tsconfig.json file (used for testing). |
| string | The name (and path) of the development tsconfig file. |
| | Options for ts-jest. |
| string | TypeScript version to use. |
nameRequired
public readonly name: string;
- Type: string
- Default: $BASEDIR
This is the name of your project.
commitGeneratedOptional
public readonly commitGenerated: boolean;
- Type: boolean
- Default: true
Whether to commit the managed files by default.
gitIgnoreOptionsOptional
public readonly gitIgnoreOptions: IgnoreFileOptions;
- Type: projen.IgnoreFileOptions
Configuration options for .gitignore file.
gitOptionsOptional
public readonly gitOptions: GitOptions;
- Type: projen.GitOptions
Configuration options for git.
loggingOptional
public readonly logging: LoggerOptions;
- Type: projen.LoggerOptions
- Default: {}
Configure logging options such as verbosity.
outdirOptional
public readonly outdir: string;
- Type: string
- Default: "."
The root directory of the project.
Relative to this directory, all files are synthesized.
If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.
parentOptional
public readonly parent: Project;
- Type: projen.Project
The parent project, if this project is part of a bigger project.
projectTreeOptional
public readonly projectTree: boolean;
- Type: boolean
- Default: false
Generate a project tree file (.projen/tree.json) that shows all components and their relationships. Useful for understanding your project structure and debugging.
projenCommandOptional
public readonly projenCommand: string;
- Type: string
- Default: "npx projen"
The shell command to use in order to run the projen CLI.
Can be used to customize in special environments.
projenrcJsonOptional
public readonly projenrcJson: boolean;
- Type: boolean
- Default: false
Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.
projenrcJsonOptionsOptional
public readonly projenrcJsonOptions: ProjenrcJsonOptions;
- Type: projen.ProjenrcJsonOptions
- Default: default options
Options for .projenrc.json.
renovatebotOptional
public readonly renovatebot: boolean;
- Type: boolean
- Default: false
Use renovatebot to handle dependency upgrades.
renovatebotOptionsOptional
public readonly renovatebotOptions: RenovatebotOptions;
- Type: projen.RenovatebotOptions
- Default: default options
Options for renovatebot.
autoApproveOptionsOptional
public readonly autoApproveOptions: AutoApproveOptions;
- Type: projen.github.AutoApproveOptions
- Default: auto approve is disabled
Enable and configure the 'auto approve' workflow.
autoMergeOptional
public readonly autoMerge: boolean;
- Type: boolean
- Default: true
Enable automatic merging on GitHub.
Has no effect if github.mergify
is set to false.
autoMergeOptionsOptional
public readonly autoMergeOptions: AutoMergeOptions;
- Type: projen.github.AutoMergeOptions
- Default: see defaults in
AutoMergeOptions
Configure options for automatic merging on GitHub.
Has no effect if
github.mergify or autoMerge is set to false.
clobberOptional
public readonly clobber: boolean;
- Type: boolean
- Default: true, but false for subprojects
Add a clobber task which resets the repo to origin.
devContainerOptional
public readonly devContainer: boolean;
- Type: boolean
- Default: false
Add a VSCode development environment (used for GitHub Codespaces).
githubOptional
public readonly github: boolean;
- Type: boolean
- Default: true
Enable GitHub integration.
Enabled by default for root projects. Disabled for non-root projects.
githubOptionsOptional
public readonly githubOptions: GitHubOptions;
- Type: projen.github.GitHubOptions
- Default: see GitHubOptions
Options for GitHub integration.
gitpodOptional
public readonly gitpod: boolean;
- Type: boolean
- Default: false
Add a Gitpod development environment.
projenCredentialsOptional
public readonly projenCredentials: GithubCredentials;
- Type: projen.github.GithubCredentials
- Default: use a personal access token named PROJEN_GITHUB_TOKEN
Choose a method of providing GitHub API access for projen workflows.
readmeOptional
public readonly readme: SampleReadmeProps;
- Type: projen.SampleReadmeProps
- Default: { filename: 'README.md', contents: '# replace this' }
The README setup.
Example
"{ filename: 'readme.md', contents: '# title' }"
staleOptional
public readonly stale: boolean;
- Type: boolean
- Default: false
Auto-close of stale issues and pull request.
See staleOptions for options.
staleOptionsOptional
public readonly staleOptions: StaleOptions;
- Type: projen.github.StaleOptions
- Default: see defaults in
StaleOptions
Auto-close stale issues and pull requests.
To disable set stale to false.
vscodeOptional
public readonly vscode: boolean;
- Type: boolean
- Default: true
Enable VSCode integration.
Enabled by default for root projects. Disabled for non-root projects.
addPackageManagerToDevEnginesOptional
public readonly addPackageManagerToDevEngines: boolean;
- Type: boolean
- Default: true
Automatically add the resolved packageManager to devEngines.packageManager in package.json, setting onFail to ignore.
allowLibraryDependenciesOptional
public readonly allowLibraryDependencies: boolean;
- Type: boolean
- Default: true
Allow the project to include peerDependencies and bundledDependencies.
This is normally only allowed for libraries. For apps, there's no meaning for specifying these.
allowScriptsOptional
public readonly allowScripts: string[];
- Type: string[]
- Default: all install scripts are allowed to run (package manager default)
List of dependency (package) names that are allowed to run lifecycle install scripts (preinstall, install, postinstall, prepare) during dependency installation.
These scripts can execute arbitrary code, making them a common
supply-chain attack vector. Package managers are moving toward
blocking them by default and requiring an explicit allowlist.
Configuring allowScripts sets up that allowlist so scripts only run
for the packages you have explicitly reviewed and trust.
Support for this setting depends on the configured packageManager:
NPM: written to the nativeallowScriptsfield inpackage.json(requires npm >= 11.16; see https://docs.npmjs.com/cli/v11/commands/npm-approve-scripts).BUN: written to the nativetrustedDependenciesfield inpackage.json(see https://bun.com/docs/pm/lifecycle).PNPM: written to theonlyBuiltDependenciessetting inpnpm-workspace.yaml(see https://pnpm.io/settings#onlybuiltdependencies).YARN2,YARN_BERRY: written to the nativedependenciesMeta.<pkg>.builtallowlist inpackage.json, combined withenableScripts: falsein.yarnrc.yml(see https://yarnpkg.com/features/security#postinstalls). If you setyarnBerryOptions.yarnRcOptions.enableScriptsexplicitly, that value is respected instead of being overridden.YARN,YARN_CLASSIC: not supported. Yarn Classic has no native mechanism to allowlist install scripts for specific dependencies. Setting this option with one of these package managers throws an error at synthesis time.
authorEmailOptional
public readonly authorEmail: string;
- Type: string
Author's e-mail.
authorNameOptional
public readonly authorName: string;
- Type: string
Author's name.
authorOrganizationOptional
public readonly authorOrganization: boolean;
- Type: boolean
Is the author an organization.
authorUrlOptional
public readonly authorUrl: string;
- Type: string
Author's URL / Website.
autoDetectBinOptional
public readonly autoDetectBin: boolean;
- Type: boolean
- Default: true
Automatically add all executables under the bin directory to your package.json file under the bin section.
binOptional
public readonly bin: {[ key: string ]: string};
- Type: {[ key: string ]: string}
Binary programs vended with your module.
You can use this option to add/customize how binaries are represented in
your package.json, but unless autoDetectBin is false, every
executable file under bin will automatically be added to this section.
bugsEmailOptional
public readonly bugsEmail: string;
- Type: string
The email address to which issues should be reported.
bugsUrlOptional
public readonly bugsUrl: string;
- Type: string
The url to your project's issue tracker.
bundledDepsOptional
public readonly bundledDeps: string[];
- Type: string[]
List of dependencies to bundle into this module.
These modules will be
added both to the dependencies section and bundledDependencies section of
your package.json.
The recommendation is to only specify the module name here (e.g.
express). This will behave similar to pnpm add or npm install in the
sense that it will add the module as a dependency to your package.json
file with the latest version (^). You can specify semver requirements in
the same syntax passed to pnpm add or npm i (e.g. express@^2) and
this will be what your package.json will eventually include.
bunVersionOptional
public readonly bunVersion: string;
- Type: string
- Default: "latest"
The version of Bun to use if using Bun as a package manager.
codeArtifactOptionsOptional
public readonly codeArtifactOptions: CodeArtifactOptions;
- Type: projen.javascript.CodeArtifactOptions
- Default: undefined
Options for npm packages using AWS CodeArtifact.
This is required if publishing packages to, or installing scoped packages from AWS CodeArtifact
deleteOrphanedLockFilesOptional
public readonly deleteOrphanedLockFiles: boolean;
- Type: boolean
- Default: true
Automatically delete lockfiles from package managers that are not the active one.
Only triggered when the lockfile for the configured package manager already exists.
This is useful when migrating between package managers to avoid conflicts.
depsOptional
public readonly deps: string[];
- Type: string[]
- Default: []
Runtime dependencies of this module.
The recommendation is to only specify the module name here (e.g.
express). This will behave similar to pnpm add or npm install in the
sense that it will add the module as a dependency to your package.json
file with the latest version (^). You can specify semver requirements in
the same syntax passed to pnpm add or npm i (e.g. express@^2) and
this will be what your package.json will eventually include.
Example
[ 'express', 'lodash', 'foo@^2' ]
descriptionOptional
public readonly description: string;
- Type: string
The description is just a string that helps people understand the purpose of the package.
It can be used when searching for packages in a package manager as well. See https://classic.yarnpkg.com/en/docs/package-json/#toc-description
devDepsOptional
public readonly devDeps: string[];
- Type: string[]
- Default: []
Build dependencies for this module.
These dependencies will only be available in your build environment but will not be fetched when this module is consumed.
The recommendation is to only specify the module name here (e.g.
express). This will behave similar to pnpm add or npm install in the
sense that it will add the module as a dependency to your package.json
file with the latest version (^). You can specify semver requirements in
the same syntax passed to pnpm add or npm i (e.g. express@^2) and
this will be what your package.json will eventually include.
Example
[ 'typescript', '@types/express' ]
devEnginesOptional
public readonly devEngines: DevEngines;
- Type: projen.javascript.DevEngines
Configure the devEngines field in package.json.
The devEngines.packageManager field is automatically populated based on
the resolved packageManager value. Any fields provided here are merged
with the auto-populated packageManager entry.
https://docs.npmjs.com/cli/v10/configuring-npm/package-json#devengines
entrypointOptional
public readonly entrypoint: string;
- Type: string
- Default: "lib/index.js"
Module entrypoint (main in package.json).
Set to an empty string to not include main in your package.json
homepageOptional
public readonly homepage: string;
- Type: string
Package's Homepage / Website.
keywordsOptional
public readonly keywords: string[];
- Type: string[]
Keywords to include in package.json.
licenseOptional
public readonly license: string;
- Type: string
- Default: "Apache-2.0"
License's SPDX identifier.
See https://github.com/projen/projen/tree/main/license-text for a list of supported licenses.
Use the licensed option if you want to no license to be specified.
licensedOptional
public readonly licensed: boolean;
- Type: boolean
- Default: true
Indicates if a license should be added.
maxNodeVersionOptional
public readonly maxNodeVersion: string;
- Type: string
- Default: no maximum version is enforced
The maximum node version supported by this package. Most projects should not use this option.
The value indicates that the package is incompatible with any newer versions of node. This requirement is enforced via the engines field.
You will normally not need to set this option. Consider this option only if your package is known to not function with newer versions of node.
minNodeVersionOptional
public readonly minNodeVersion: string;
- Type: string
- Default: no minimum version is enforced
The minimum node version required by this package to function. Most projects should not use this option.
The value indicates that the package is incompatible with any older versions of node. This requirement is enforced via the engines field.
You will normally not need to set this option, even if your package is incompatible with EOL versions of node. Consider this option only if your package depends on a specific feature, that is not available in other LTS versions. Setting this option has very high impact on the consumers of your package, as package managers will actively prevent usage with node versions you have marked as incompatible.
To change the node version of your CI/CD workflows, use workflowNodeVersion.
npmAccessOptional
public readonly npmAccess: NpmAccess;
- Type: projen.javascript.NpmAccess
- Default: for scoped packages (e.g.
foo@bar), the default isNpmAccess.RESTRICTED, for non-scoped packages, the default isNpmAccess.PUBLIC.
Access level of the npm package.
npmProvenanceOptional
public readonly npmProvenance: boolean;
- Type: boolean
- Default: true for public packages, false otherwise
Should provenance statements be generated when the package is published.
A supported package manager is required to publish a package with npm provenance statements and you will need to use a supported CI/CD provider.
Note that the projen Release and Publisher components are using publib to publish packages,
which is using npm internally and supports provenance statements independently of the package manager used.
npmRegistryUrlOptional
public readonly npmRegistryUrl: string;
- Type: string
- Default: "https://registry.npmjs.org"
The base URL of the npm package registry.
Must be a URL (e.g. start with "https://" or "http://")
npmTokenSecretOptional
public readonly npmTokenSecret: string;
- Type: string
- Default: "NPM_TOKEN"
GitHub secret which contains the NPM token to use when publishing packages.
npmTrustedPublishingOptional
public readonly npmTrustedPublishing: boolean;
- Type: boolean
- Default: false
Use trusted publishing for publishing to npmjs.com Needs to be pre-configured on npm.js to work.
packageManagerOptional
public readonly packageManager: NodePackageManager;
- Type: projen.javascript.NodePackageManager
- Default: Detected from the calling process or
YARN_CLASSICif detection fails.
The Node Package Manager used to execute scripts.
packageNameOptional
public readonly packageName: string;
- Type: string
- Default: defaults to project name
The "name" in package.json.
peerDependencyOptionsOptional
public readonly peerDependencyOptions: PeerDependencyOptions;
- Type: projen.javascript.PeerDependencyOptions
Options for peerDeps.
peerDepsOptional
public readonly peerDeps: string[];
- Type: string[]
- Default: []
Peer dependencies for this module.
Dependencies listed here are required to
be installed (and satisfied) by the consumer of this library. Using peer
dependencies allows you to ensure that only a single module of a certain
library exists in the node_modules tree of your consumers.
Note that prior to npm@7, peer dependencies are not automatically installed, which means that adding peer dependencies to a library will be a breaking change for your customers.
Unless peerDependencyOptions.pinnedDevDependency is disabled (it is
enabled by default), projen will automatically add a dev dependency with a
pinned version for each peer dependency. This will ensure that you build &
test your module against the lowest peer version required.
pnpmOptionsOptional
public readonly pnpmOptions: PnpmOptions;
- Type: projen.javascript.PnpmOptions
- Default: all default options
Options for pnpm.
pnpmVersionOptional
public readonly pnpmVersion: string;
- Type: string
- Default: "10.33.0"
The version of PNPM to use if using PNPM as a package manager.
repositoryOptional
public readonly repository: string;
- Type: string
The repository is the location where the actual code for your package lives.
See https://classic.yarnpkg.com/en/docs/package-json/#toc-repository
repositoryDirectoryOptional
public readonly repositoryDirectory: string;
- Type: string
If the package.json for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives.
scopedPackagesOptionsOptional
public readonly scopedPackagesOptions: ScopedPackagesOptions[];
- Type: projen.javascript.ScopedPackagesOptions[]
- Default: fetch all scoped packages from the public npm registry
Options for privately hosted scoped packages.
stabilityOptional
public readonly stability: string;
- Type: string
Package's Stability.
yarnBerryOptionsOptional
public readonly yarnBerryOptions: YarnBerryOptions;
- Type: projen.javascript.YarnBerryOptions
- Default: Yarn Berry v4 with all default options
Options for Yarn Berry.
bumpPackageOptional
public readonly bumpPackage: string;
- Type: string
- Default: A recent version of "commit-and-tag-version"
The commit-and-tag-version compatible package used to bump the package version, as a dependency string.
This can be any compatible package version, including the deprecated standard-version@9.
jsiiReleaseVersionOptional
public readonly jsiiReleaseVersion: string;
- Type: string
- Default: "latest"
Version requirement of publib which is used to publish modules to npm.
majorVersionOptional
public readonly majorVersion: number;
- Type: number
- Default: Major version is not enforced.
Major version to release from the default branch.
If this is specified, we bump the latest version of this major version line. If not specified, we bump the global latest version.
minMajorVersionOptional
public readonly minMajorVersion: number;
- Type: number
- Default: No minimum version is being enforced
Minimal Major version to release.
This can be useful to set to 1, as breaking changes before the 1.x major release are not incrementing the major version number.
Can not be set together with majorVersion.
nextVersionCommandOptional
public readonly nextVersionCommand: string;
- Type: string
- Default: The next version will be determined based on the commit history and project settings.
A shell command to control the next version to release.
If present, this shell command will be run before the bump is executed, and it determines what version to release. It will be executed in the following environment:
- Working directory: the project directory.
$VERSION: the current version. Looks like1.2.3.$LATEST_TAG: the most recent tag. Looks likeprefix-v1.2.3, or may be unset.$SUGGESTED_BUMP: the suggested bump action based on commits. One ofmajor|minor|patch|none.
The command should print one of the following to stdout:
- Nothing: the next version number will be determined based on commit history.
x.y.z: the next version number will bex.y.z.major|minor|patch: the next version number will be the current version number with the indicated component bumped.
This setting cannot be specified together with minMajorVersion; the invoked
script can be used to achieve the effects of minMajorVersion.
npmDistTagOptional
public readonly npmDistTag: string;
- Type: string
- Default: "latest"
The npmDistTag to use when publishing from the default branch.
To set the npm dist-tag for release branches, set the npmDistTag property
for each branch.
postBuildStepsOptional
public readonly postBuildSteps: JobStep[];
- Type: projen.github.workflows.JobStep[]
- Default: []
Steps to execute after build as part of the release workflow.
prereleaseOptional
public readonly prerelease: string;
- Type: string
- Default: normal semantic versions
Bump versions from the default branch as pre-releases (e.g. "beta", "alpha", "pre").
publishDryRunOptional
public readonly publishDryRun: boolean;
- Type: boolean
- Default: false
Instead of actually publishing to package managers, just print the publishing command.
publishTasksOptional
public readonly publishTasks: boolean;
- Type: boolean
- Default: false
Define publishing tasks that can be executed manually as well as workflows.
Normally, publishing only happens within automated workflows. Enable this in order to create a publishing task for each publishing activity.
releasableCommitsOptional
public readonly releasableCommits: ReleasableCommits;
- Type: projen.ReleasableCommits
- Default: ReleasableCommits.everyCommit()
Find commits that should be considered releasable Used to decide if a release is required.
releaseBranchesOptional
public readonly releaseBranches: {[ key: string ]: BranchOptions};
- Type: {[ key: string ]: projen.release.BranchOptions}
- Default: no additional branches are used for release. you can use
addBranch()to add additional branches.
Defines additional release branches.
A workflow will be created for each
release branch which will publish releases from commits in this branch.
Each release branch must be assigned a major version number which is used
to enforce that versions published from that branch always use that major
version. If multiple branches are used, the majorVersion field must also
be provided for the default branch.
releaseEnvironmentOptional
public readonly releaseEnvironment: string;
- Type: string
- Default: no environment used, unless set at the artifact level
The GitHub Actions environment used for the release.
This can be used to add an explicit approval step to the release or limit who can initiate a release through environment protection rules.
When multiple artifacts are released, the environment can be overwritten on a per artifact basis.
releaseFailureIssueOptional
public readonly releaseFailureIssue: boolean;
- Type: boolean
- Default: false
Create a github issue on every failed publishing task.
releaseFailureIssueLabelOptional
public readonly releaseFailureIssueLabel: string;
- Type: string
- Default: "failed-release"
The label to apply to issues indicating publish failures.
Only applies if releaseFailureIssue is true.
releaseTagPrefixOptional
public readonly releaseTagPrefix: string;
- Type: string
- Default: "v"
Automatically add the given prefix to release tags. Useful if you are releasing on multiple branches with overlapping version numbers.
Note: this prefix is used to detect the latest tagged version when bumping, so if you change this on a project with an existing version history, you may need to manually tag your latest release with the new prefix.
releaseTriggerOptional
public readonly releaseTrigger: ReleaseTrigger;
- Type: projen.release.ReleaseTrigger
- Default: Continuous releases (
ReleaseTrigger.continuous())
The release trigger to use.
releaseWorkflowEnvOptional
public readonly releaseWorkflowEnv: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- Default: {}
Build environment variables for release workflows.
releaseWorkflowNameOptional
public readonly releaseWorkflowName: string;
- Type: string
- Default: "release"
The name of the default release workflow.
releaseWorkflowSetupStepsOptional
public readonly releaseWorkflowSetupSteps: JobStep[];
- Type: projen.github.workflows.JobStep[]
A set of workflow steps to execute in order to setup the workflow container.
versionrcOptionsOptional
public readonly versionrcOptions: {[ key: string ]: any};
- Type: {[ key: string ]: any}
- Default: standard configuration applicable for GitHub repositories
Custom configuration used when creating changelog with commit-and-tag-version package.
Given values either append to default configuration or overwrite values in it.
workflowContainerImageOptional
public readonly workflowContainerImage: string;
- Type: string
- Default: default image
Container image to use for GitHub workflows.
workflowRunsOnOptional
public readonly workflowRunsOn: string[];
- Type: string[]
- Default: ["ubuntu-latest"]
Github Runner selection labels.
workflowRunsOnGroupOptional
public readonly workflowRunsOnGroup: GroupRunnerOptions;
- Type: projen.GroupRunnerOptions
Github Runner Group selection options.
artifactsDirectoryOptional
public readonly artifactsDirectory: string;
- Type: string
- Default: "dist"
A directory which will contain build artifacts.
auditDepsOptional
public readonly auditDeps: boolean;
- Type: boolean
- Default: false
Run security audit on dependencies.
When enabled, creates an "audit" task that checks for known security vulnerabilities in dependencies. By default, runs during every build and checks for "high" severity vulnerabilities or above in all dependencies (including dev dependencies).
auditDepsOptionsOptional
public readonly auditDepsOptions: AuditOptions;
- Type: projen.javascript.AuditOptions
- Default: default options
Security audit options.
autoApproveUpgradesOptional
public readonly autoApproveUpgrades: boolean;
- Type: boolean
- Default: true
Automatically approve deps upgrade PRs, allowing them to be merged by mergify (if configured).
Throw if set to true but autoApproveOptions are not defined.
biomeOptional
public readonly biome: boolean;
- Type: boolean
- Default: false
Setup Biome.
biomeOptionsOptional
public readonly biomeOptions: BiomeOptions;
- Type: projen.javascript.BiomeOptions
- Default: default options
Biome options.
buildWorkflowOptional
public readonly buildWorkflow: boolean;
- Type: boolean
- Default: true if not a subproject
Define a GitHub workflow for building PRs.
buildWorkflowOptionsOptional
public readonly buildWorkflowOptions: BuildWorkflowOptions;
- Type: projen.javascript.BuildWorkflowOptions
Options for PR build workflow.
bundlerOptionsOptional
public readonly bundlerOptions: BundlerOptions;
- Type: projen.javascript.BundlerOptions
Options for Bundler.
checkLicensesOptional
public readonly checkLicenses: LicenseCheckerOptions;
- Type: projen.javascript.LicenseCheckerOptions
- Default: no license checks are run during the build and all licenses will be accepted
Configure which licenses should be deemed acceptable for use by dependencies.
This setting will cause the build to fail, if any prohibited or not allowed licenses ares encountered.
codeCovOptional
public readonly codeCov: boolean;
- Type: boolean
- Default: false
Define a GitHub workflow step for sending code coverage metrics to https://codecov.io/ Uses codecov/codecov-action@v5 By default, OIDC auth is used. Alternatively a token can be provided via codeCovTokenSecret.
codeCovTokenSecretOptional
public readonly codeCovTokenSecret: string;
- Type: string
- Default: OIDC auth is used
Define the secret name for a specified https://codecov.io/ token.
copyrightOwnerOptional
public readonly copyrightOwner: string;
- Type: string
- Default: defaults to the value of authorName or "" if
authorNameis undefined.
License copyright owner.
copyrightPeriodOptional
public readonly copyrightPeriod: string;
- Type: string
- Default: current year
The copyright years to put in the LICENSE file.
defaultReleaseBranchOptional
public readonly defaultReleaseBranch: string;
- Type: string
- Default: "main"
The name of the main release branch.
dependabotOptional
public readonly dependabot: boolean;
- Type: boolean
- Default: false
Use dependabot to handle dependency upgrades.
Cannot be used in conjunction with depsUpgrade.
dependabotOptionsOptional
public readonly dependabotOptions: DependabotOptions;
- Type: projen.github.DependabotOptions
- Default: default options
Options for dependabot.
depsUpgradeOptional
public readonly depsUpgrade: boolean;
- Type: boolean
- Default:
truefor root projects,falsefor subprojects
Use tasks and github workflows to handle dependency upgrades.
Cannot be used in conjunction with dependabot.
depsUpgradeOptionsOptional
public readonly depsUpgradeOptions: UpgradeDependenciesOptions;
- Type: projen.javascript.UpgradeDependenciesOptions
- Default: default options
Options for UpgradeDependencies.
gitignoreOptional
public readonly gitignore: string[];
- Type: string[]
Additional entries to .gitignore.
jestOptional
public readonly jest: boolean;
- Type: boolean
- Default: true
Setup jest unit tests.
jestOptionsOptional
public readonly jestOptions: JestOptions;
- Type: projen.javascript.JestOptions
- Default: default options
Jest options.
npmignoreEnabledOptional
public readonly npmignoreEnabled: boolean;
- Type: boolean
- Default: true
Defines an .npmignore file. Normally this is only needed for libraries that are packaged as tarballs.
npmIgnoreOptionsOptional
public readonly npmIgnoreOptions: IgnoreFileOptions;
- Type: projen.IgnoreFileOptions
Configuration options for .npmignore file.
packageOptional
public readonly package: boolean;
- Type: boolean
- Default: true
Defines a package task that will produce an npm tarball under the artifacts directory (e.g. dist).
prettierOptional
public readonly prettier: boolean;
- Type: boolean
- Default: false
Setup prettier.
prettierOptionsOptional
public readonly prettierOptions: PrettierOptions;
- Type: projen.javascript.PrettierOptions
- Default: default options
Prettier options.
projenDevDependencyOptional
public readonly projenDevDependency: boolean;
- Type: boolean
- Default: true if not a subproject
Indicates of "projen" should be installed as a devDependency.
projenrcJsOptional
public readonly projenrcJs: boolean;
- Type: boolean
- Default: true if projenrcJson is false
Generate (once) .projenrc.js (in JavaScript). Set to false in order to disable .projenrc.js generation.
projenrcJsOptionsOptional
public readonly projenrcJsOptions: ProjenrcOptions;
- Type: projen.javascript.ProjenrcOptions
- Default: default options
Options for .projenrc.js.
projenVersionOptional
public readonly projenVersion: string;
- Type: string
- Default: Defaults to the latest version.
Version of projen to install.
pullRequestTemplateOptional
public readonly pullRequestTemplate: boolean;
- Type: boolean
- Default: true
Include a GitHub pull request template.
pullRequestTemplateContentsOptional
public readonly pullRequestTemplateContents: string[];
- Type: string[]
- Default: default content
The contents of the pull request template.
releaseOptional
public readonly release: boolean;
- Type: boolean
- Default: true (false for subprojects)
Add release management to this project.
releaseToNpmOptional
public readonly releaseToNpm: boolean;
- Type: boolean
- Default: false
Automatically release to npm when new versions are introduced.
workflowBootstrapStepsOptional
public readonly workflowBootstrapSteps: JobStep[];
- Type: projen.github.workflows.JobStep[]
- Default: "yarn install --frozen-lockfile && yarn projen"
Workflow steps to use in order to bootstrap this repo.
workflowGitIdentityOptional
public readonly workflowGitIdentity: GitIdentity;
- Type: projen.github.GitIdentity
- Default: default GitHub Actions user
The git identity to use in workflows.
workflowNodeVersionOptional
public readonly workflowNodeVersion: string;
- Type: string
- Default:
minNodeVersionif set, otherwiselts/*.
The node version used in GitHub Actions workflows.
Always use this option if your GitHub Actions workflows require a specific to run.
workflowPackageCacheOptional
public readonly workflowPackageCache: boolean;
- Type: boolean
- Default: false
Enable Node.js package cache in GitHub workflows.
disableTsconfigOptional
public readonly disableTsconfig: boolean;
- Type: boolean
- Default: false
Do not generate a tsconfig.json file (used by jsii projects since tsconfig.json is generated by the jsii compiler).
disableTsconfigDevOptional
public readonly disableTsconfigDev: boolean;
- Type: boolean
- Default: false
Do not generate a development tsconfig file.
docgenOptional
public readonly docgen: boolean;
- Type: boolean
- Default: false
Docgen by Typedoc.
docsDirectoryOptional
public readonly docsDirectory: string;
- Type: string
- Default: "docs"
Docs directory.
entrypointTypesOptional
public readonly entrypointTypes: string;
- Type: string
- Default: .d.ts file derived from the project's entrypoint (usually lib/index.d.ts)
The .d.ts file that includes the type declarations for this module.
eslintOptional
public readonly eslint: boolean;
- Type: boolean
- Default: true, unless biome is enabled
Setup eslint.
eslintOptionsOptional
public readonly eslintOptions: EslintOptions;
- Type: projen.javascript.EslintOptions
- Default: opinionated default options
Eslint options.
libdirOptional
public readonly libdir: string;
- Type: string
- Default: "lib"
Typescript artifacts output directory.
projenrcTsOptional
public readonly projenrcTs: boolean;
- Type: boolean
- Default: false
Use TypeScript for your projenrc file (.projenrc.ts).
projenrcTsOptionsOptional
public readonly projenrcTsOptions: ProjenrcOptions;
- Type: ProjenrcOptions
Options for .projenrc.ts.
runnerOptional
public readonly runner: TypeScriptRunner;
- Type: TypeScriptRunner
- Default: TypeScriptRunner.tsNode()
The TypeScript runner to use for executing TypeScript files.
This is a project-level setting that components (e.g. projenrc) will use as their default runner.
sampleCodeOptional
public readonly sampleCode: boolean;
- Type: boolean
- Default: true
Generate one-time sample in src/ and test/ if there are no files there.
srcdirOptional
public readonly srcdir: string;
- Type: string
- Default: "src"
Typescript sources directory.
testdirOptional
public readonly testdir: string;
- Type: string
- Default: "test"
Jest tests directory. Tests files should be named xxx.test.ts.
If this directory is under srcdir (e.g. src/test, src/__tests__),
then tests are going to be compiled into lib/ and executed as javascript.
If the test directory is outside of src, then we configure jest to
compile the code in-memory.
tsconfigOptional
public readonly tsconfig: TypescriptConfigOptions;
- Type: projen.javascript.TypescriptConfigOptions
- Default: default options
Custom TSConfig.
tsconfigDevOptional
public readonly tsconfigDev: TypescriptConfigOptions;
- Type: projen.javascript.TypescriptConfigOptions
- Default: use the production tsconfig options
Custom tsconfig options for the development tsconfig.json file (used for testing).
tsconfigDevFileOptional
public readonly tsconfigDevFile: string;
- Type: string
- Default: "{testdir}/tsconfig.json"
The name (and path) of the development tsconfig file.
By default this lives inside the test directory (e.g. test/tsconfig.json)
so that the TypeScript language service resolves it as the nearest config
for test files.
tsJestOptionsOptional
public readonly tsJestOptions: TsJestOptions;
- Type: TsJestOptions
Options for ts-jest.
typescriptVersionOptional
public readonly typescriptVersion: string;
- Type: string
- Default: "latest"
TypeScript version to use.
NOTE: Typescript is not semantically versioned and should remain on the
same minor, so we recommend using a ~ dependency (e.g. ~1.2.3).
TypeScriptRunnerOptions
The options that can be adjusted on any {@link TypeScriptRunner}, regardless of its runtime.
This is the override type for {@link TypeScriptRunner.copy}. Runtime-specific
creation options (such as swc for ts-node) are set via the static factories
and are preserved - but cannot be changed - by copy, so a copy can never
change the runtime of a runner.
Initializer
import { typescript } from 'projen'
const typeScriptRunnerOptions: typescript.TypeScriptRunnerOptions = { ... }
Properties
| Name | Type | Description |
|---|---|---|
| string | Path to the tsconfig file to use. |
| boolean | Whether to type-check the entrypoint. |
tsconfigOptional
public readonly tsconfig: string;
- Type: string
Path to the tsconfig file to use.
typeCheckOptional
public readonly typeCheck: boolean;
- Type: boolean
Whether to type-check the entrypoint.
Classes
TsJestBabelConfig
https://kulshekhar.github.io/ts-jest/docs/getting-started/options/babelConfig/
Static Functions
| Name | Description |
|---|---|
| Enables Babel processing. |
| Inline compiler options. |
| Disables the use of Babel. |
| Path to a babelrc file. |
autoDetectConfig
import { typescript } from 'projen'
typescript.TsJestBabelConfig.autoDetectConfig()
Enables Babel processing.
ts-jest will try to find an existing Babel configuration and pass it to the babel-jest processor.
custom
import { typescript } from 'projen'
typescript.TsJestBabelConfig.custom(config: {[ key: string ]: any})
Inline compiler options.
configRequired
- Type: {[ key: string ]: any}
disabled
import { typescript } from 'projen'
typescript.TsJestBabelConfig.disabled()
Disables the use of Babel.
fromFile
import { typescript } from 'projen'
typescript.TsJestBabelConfig.fromFile(filePath: string)
Path to a babelrc file.
The path should be relative to the current working directory where you start Jest from. You can also use <rootDir> in the path.
filePathRequired
- Type: string
TsJestDiagnostics
https://kulshekhar.github.io/ts-jest/docs/getting-started/options/diagnostics/
Static Functions
| Name | Description |
|---|---|
| Enable all diagnostics. |
| Provide a custom diagnostics configuration. |
| Disable all diagnostics. |
all
import { typescript } from 'projen'
typescript.TsJestDiagnostics.all()
Enable all diagnostics.
custom
import { typescript } from 'projen'
typescript.TsJestDiagnostics.custom(config: {[ key: string ]: any})
Provide a custom diagnostics configuration.
https://kulshekhar.github.io/ts-jest/docs/getting-started/options/diagnostics/
configRequired
- Type: {[ key: string ]: any}
none
import { typescript } from 'projen'
typescript.TsJestDiagnostics.none()
Disable all diagnostics.
TsJestTsconfig
https://kulshekhar.github.io/ts-jest/docs/getting-started/options/tsconfig/
Static Functions
| Name | Description |
|---|---|
| Uses tsconfig.json if found, or the built-in default TypeScript compiler options. |
| Force ts-jest to use its built-in defaults even if there is a tsconfig.json in your project. |
| Inline compiler options. |
| Path to a tsconfig file. |
auto
import { typescript } from 'projen'
typescript.TsJestTsconfig.auto()
Uses tsconfig.json if found, or the built-in default TypeScript compiler options.
builtInDefaults
import { typescript } from 'projen'
typescript.TsJestTsconfig.builtInDefaults()
Force ts-jest to use its built-in defaults even if there is a tsconfig.json in your project.
custom
import { typescript } from 'projen'
typescript.TsJestTsconfig.custom(config: TypeScriptCompilerOptions)
Inline compiler options.
configRequired
- Type: projen.javascript.TypeScriptCompilerOptions
fromFile
import { typescript } from 'projen'
typescript.TsJestTsconfig.fromFile(filePath: string)
Path to a tsconfig file.
The path should be relative to the current working directory where you start Jest from. You can also use <rootDir> in the path to start from the project root dir.
filePathRequired
- Type: string
TypedocDocgen
Adds a simple Typescript documentation generator.
Initializers
import { typescript } from 'projen'
new typescript.TypedocDocgen(project: TypeScriptProject)
| Name | Type | Description |
|---|---|---|
| | No description. |
projectRequired
- Type: TypeScriptProject