Skip to main content

javascript Submodule

Constructs

Bundler

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

In the future, this will also supports bundling websites.

Initializers

import { javascript } from 'projen'

new javascript.Bundler(project: Project, options?: BundlerOptions)
NameTypeDescription
project
projen.ProjectNo description.
options
BundlerOptions
No description.

projectRequired
  • Type: projen.Project

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
addBundle
Adds a task to the project which bundles a specific entrypoint and all of its dependencies into a single javascript output file.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

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

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

entrypointRequired
  • Type: string

The relative path of the artifact within the project.


optionsRequired

Bundling options.


Static Functions

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

isConstruct
import { javascript } from 'projen'

javascript.Bundler.isConstruct(x: any)

Checks if x is a construct.

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

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

xRequired
  • Type: any

Any object.


isComponent
import { javascript } from 'projen'

javascript.Bundler.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

of
import { javascript } from 'projen'

javascript.Bundler.of(project: Project)

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

projectRequired
  • Type: projen.Project

The project.


Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
bundledir
stringRoot bundle directory.
bundleTask
projen.TaskGets or creates the singleton "bundle" task of the project.
esbuildVersion
stringThe semantic version requirement for esbuild (if defined).

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

bundledirRequired
public readonly bundledir: string;
  • Type: string

Root bundle directory.


bundleTaskRequired
public readonly bundleTask: Task;
  • Type: projen.Task

Gets or creates the singleton "bundle" task of the project.

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


esbuildVersionOptional
public readonly esbuildVersion: string;
  • Type: string

The semantic version requirement for esbuild (if defined).


Eslint

Represents eslint configuration.

Initializers

import { javascript } from 'projen'

new javascript.Eslint(project: NodeProject, options: EslintOptions)
NameTypeDescription
project
NodeProject
No description.
options
EslintOptions
No description.

projectRequired

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
addExtends
Adds an extends item to the eslint configuration.
addIgnorePattern
Do not lint these files.
addLintPattern
Add a file, glob pattern or directory with source files to lint (e.g. [ "src" ]).
addOverride
Add an eslint override.
addPlugins
Adds an eslint plugin.
addRules
Add an eslint rule.
allowDevDeps
Add a glob file pattern which allows importing dev dependencies.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

addExtends
public addExtends(extendList: string): void

Adds an extends item to the eslint configuration.

extendListRequired
  • Type: string

The list of "extends" to add.


addIgnorePattern
public addIgnorePattern(pattern: string): void

Do not lint these files.

patternRequired
  • Type: string

addLintPattern
public addLintPattern(pattern: string): void

Add a file, glob pattern or directory with source files to lint (e.g. [ "src" ]).

patternRequired
  • Type: string

addOverride
public addOverride(override: EslintOverride): void

Add an eslint override.

overrideRequired

addPlugins
public addPlugins(plugins: string): void

Adds an eslint plugin.

pluginsRequired
  • Type: string

The names of plugins to add.


addRules
public addRules(rules: {[ key: string ]: any}): void

Add an eslint rule.

rulesRequired
  • Type: {[ key: string ]: any}

allowDevDeps
public allowDevDeps(pattern: string): void

Add a glob file pattern which allows importing dev dependencies.

patternRequired
  • Type: string

glob pattern.


Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.
of
Returns the singletone Eslint component of a project or undefined if there is none.

isConstruct
import { javascript } from 'projen'

javascript.Eslint.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 { javascript } from 'projen'

javascript.Eslint.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

of
import { javascript } from 'projen'

javascript.Eslint.of(project: Project)

Returns the singletone Eslint component of a project or undefined if there is none.

projectRequired
  • Type: projen.Project

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
config
anyDirect access to the eslint configuration (escape hatch).
eslintTask
projen.Taskeslint task.
ignorePatterns
string[]File patterns that should not be linted.
lintPatterns
string[]Returns an immutable copy of the lintPatterns being used by this eslint configuration.
overrides
EslintOverride[]
eslint overrides.
rules
{[ key: string ]: any[]}eslint rules.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

configRequired
public readonly config: any;
  • Type: any

Direct access to the eslint configuration (escape hatch).


eslintTaskRequired
public readonly eslintTask: Task;
  • Type: projen.Task

eslint task.


ignorePatternsRequired
public readonly ignorePatterns: string[];
  • Type: string[]

File patterns that should not be linted.


lintPatternsRequired
public readonly lintPatterns: string[];
  • Type: string[]

Returns an immutable copy of the lintPatterns being used by this eslint configuration.


overridesRequired
public readonly overrides: EslintOverride[];

eslint overrides.


rulesRequired
public readonly rules: {[ key: string ]: any[]};
  • Type: {[ key: string ]: any[]}

eslint rules.


Jest

Installs the following npm scripts:.

test, intended for testing locally and in CI. Will update snapshots unless updateSnapshot: UpdateSnapshot: NEVER is set.

  • test:watch, intended for automatically rerunning tests when files change.
  • test:update, intended for testing locally and updating snapshots to match the latest unit under test. Only available when updateSnapshot: UpdateSnapshot: NEVER.

Initializers

import { javascript } from 'projen'

new javascript.Jest(project: NodeProject, options?: JestOptions)
NameTypeDescription
project
NodeProject
No description.
options
JestOptions
No description.

projectRequired

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
addIgnorePattern
No description.
addModuleNameMappers
Adds one or more moduleNameMapper entries to Jest's configuration.
addModulePaths
Adds one or more modulePaths to Jest's configuration.
addReporter
No description.
addRoots
Adds one or more roots to Jest's configuration.
addSetupFile
Adds a a setup file to Jest's setupFiles configuration.
addSetupFileAfterEnv
Adds a a setup file to Jest's setupFilesAfterEnv configuration.
addSnapshotResolver
No description.
addTestMatch
Adds a test match pattern.
addWatchIgnorePattern
Adds a watch ignore pattern.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

addIgnorePattern
public addIgnorePattern(pattern: string): void
patternRequired
  • Type: string

addModuleNameMappers
public addModuleNameMappers(moduleNameMapperAdditions: {[ key: string ]: string | string[]}): void

Adds one or more moduleNameMapper entries to Jest's configuration.

Will overwrite if the same key is used as a pre-existing one.

moduleNameMapperAdditionsRequired
  • Type: {[ key: string ]: string | string[]}

A map from regular expressions to module names or to arrays of module names that allow to stub out resources, like images or styles with a single module.


addModulePaths
public addModulePaths(modulePaths: string): void

Adds one or more modulePaths to Jest's configuration.

modulePathsRequired
  • Type: string

An array of absolute paths to additional locations to search when resolving modules *.


addReporter
public addReporter(reporter: JestReporter): void
reporterRequired

addRoots
public addRoots(roots: string): void

Adds one or more roots to Jest's configuration.

rootsRequired
  • Type: string

A list of paths to directories that Jest should use to search for files in.


addSetupFile
public addSetupFile(file: string): void

Adds a a setup file to Jest's setupFiles configuration.

fileRequired
  • Type: string

File path to setup file.


addSetupFileAfterEnv
public addSetupFileAfterEnv(file: string): void

Adds a a setup file to Jest's setupFilesAfterEnv configuration.

fileRequired
  • Type: string

File path to setup file.


addSnapshotResolver
public addSnapshotResolver(file: string): void
fileRequired
  • Type: string

addTestMatch
public addTestMatch(pattern: string): void

Adds a test match pattern.

patternRequired
  • Type: string

glob pattern to match for tests.


addWatchIgnorePattern
public addWatchIgnorePattern(pattern: string): void

Adds a watch ignore pattern.

patternRequired
  • Type: string

The pattern (regular expression).


Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.
of
Returns the singleton Jest component of a project or undefined if there is none.

isConstruct
import { javascript } from 'projen'

javascript.Jest.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 { javascript } from 'projen'

javascript.Jest.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

of
import { javascript } from 'projen'

javascript.Jest.of(project: Project)

Returns the singleton Jest component of a project or undefined if there is none.

projectRequired
  • Type: projen.Project

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
config
anyEscape hatch.
jestVersion
stringJest version, including @ symbol, like @^29.
file
projen.JsonFileJest config file.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

configRequired
public readonly config: any;
  • Type: any

Escape hatch.


jestVersionRequired
public readonly jestVersion: string;
  • Type: string

Jest version, including @ symbol, like @^29.


fileOptional
public readonly file: JsonFile;
  • Type: projen.JsonFile

Jest config file.

undefined if settings are written to package.json


LicenseChecker

Enforces allowed licenses used by dependencies.

Initializers

import { javascript } from 'projen'

new javascript.LicenseChecker(scope: Construct, options: LicenseCheckerOptions)
NameTypeDescription
scope
constructs.ConstructNo description.
options
LicenseCheckerOptions
No description.

scopeRequired
  • Type: constructs.Construct

optionsRequired

Methods

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

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

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

isConstruct
import { javascript } from 'projen'

javascript.LicenseChecker.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 { javascript } from 'projen'

javascript.LicenseChecker.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
task
projen.TaskNo description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

taskRequired
public readonly task: Task;
  • Type: projen.Task

NodePackage

Represents the npm package.json file.

Initializers

import { javascript } from 'projen'

new javascript.NodePackage(project: Project, options?: NodePackageOptions)
NameTypeDescription
project
projen.ProjectNo description.
options
NodePackageOptions
No description.

projectRequired
  • Type: projen.Project

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
addBin
No description.
addBundledDeps
Defines bundled dependencies.
addDeps
Defines normal dependencies.
addDevDeps
Defines development/test dependencies.
addEngine
Adds an engines requirement to your package.
addField
Directly set fields in package.json.
addKeywords
Adds keywords to package.json (deduplicated).
addPackageResolutions
Defines resolutions for dependencies to change the normally resolved version of a dependency to something else.
addPeerDeps
Defines peer dependencies.
addVersion
Sets the package version.
hasScript
Indicates if a script by the given name is defined.
removeScript
Removes an npm script (always successful).
setScript
Add a npm package.json script.
tryResolveDependencyVersion
Attempt to resolve the currently installed version for a given dependency.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

addBin
public addBin(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 npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


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 npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addDevDeps
public addDevDeps(deps: string): void

Defines development/test dependencies.

depsRequired
  • Type: string

Names modules to install.

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


addEngine
public addEngine(engine: string, version: string): void

Adds an engines requirement to your package.

engineRequired
  • Type: string

The engine (e.g. node).


versionRequired
  • Type: string

The semantic version requirement (e.g. ^10).


addField
public addField(name: string, value: any): void

Directly set fields in package.json.

nameRequired
  • Type: string

field name.


valueRequired
  • Type: any

field value.


addKeywords
public addKeywords(keywords: string): void

Adds keywords to package.json (deduplicated).

keywordsRequired
  • Type: string

The keywords to add.


addPackageResolutions
public addPackageResolutions(resolutions: string): void

Defines resolutions for dependencies to change the normally resolved version of a dependency to something else.

resolutionsRequired
  • Type: string

Names resolutions to be added.

Specify a version or range with this syntax: module@^7


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 npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addVersion
public addVersion(version: string): void

Sets the package version.

versionRequired
  • Type: string

Package version.


hasScript
public hasScript(name: string): boolean

Indicates if a script by the given name is defined.

nameRequired
  • Type: string

The name of the script.


removeScript
public removeScript(name: string): void

Removes an npm script (always successful).

nameRequired
  • Type: string

The name of the script.


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

Add a npm package.json script.

nameRequired
  • Type: string

The script name.


commandRequired
  • Type: string

The command to execute.


tryResolveDependencyVersion
public tryResolveDependencyVersion(dependencyName: string): string

Attempt to resolve the currently installed version for a given dependency.

dependencyNameRequired
  • Type: string

Dependency to resolve for.


Static Functions

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

isConstruct
import { javascript } from 'projen'

javascript.NodePackage.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 { javascript } from 'projen'

javascript.NodePackage.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

of
import { javascript } from 'projen'

javascript.NodePackage.of(project: Project)

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

projectRequired
  • Type: projen.Project

The project.


Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
allowLibraryDependencies
booleanAllow project to take library dependencies.
entrypoint
stringThe module's entrypoint (e.g. lib/index.js).
file
projen.JsonFileThe package.json file.
installAndUpdateLockfileCommand
stringRenders yarn install or npm install with lockfile update (not frozen).
installCiTask
projen.TaskThe task for installing project dependencies (frozen).
installCommand
stringReturns the command to execute in order to install all dependencies (always frozen).
installTask
projen.TaskThe task for installing project dependencies (non-frozen).
lockFile
stringThe name of the lock file.
manifest
anyNo description.
npmAccess
NpmAccess
npm package access level.
npmProvenance
booleanShould provenance statements be generated when package is published.
npmRegistry
stringThe npm registry host (e.g. registry.npmjs.org).
npmRegistryUrl
stringnpm registry (e.g. https://registry.npmjs.org). Use npmRegistryHost to get just the host name.
packageManager
NodePackageManager
The package manager to use.
packageName
stringThe name of the npm package.
projenCommand
stringThe command which executes "projen".
codeArtifactOptions
CodeArtifactOptions
Options for npm packages using AWS CodeArtifact.
license
stringThe SPDX license of this module.
maxNodeVersion
stringMaximum node version required by this package.
minNodeVersion
stringMinimum node.js version required by this package.
npmTokenSecret
stringGitHub secret which contains the NPM token to use when publishing packages.
pnpmVersion
stringThe version of PNPM to use if using PNPM as a package manager.
scopedPackagesOptions
ScopedPackagesOptions[]
Options for privately hosted scoped packages.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

allowLibraryDependenciesRequired
public readonly allowLibraryDependencies: boolean;
  • Type: boolean

Allow project to take library dependencies.


entrypointRequired
public readonly entrypoint: string;
  • Type: string

The module's entrypoint (e.g. lib/index.js).


fileRequired
public readonly file: JsonFile;
  • Type: projen.JsonFile

The package.json file.


installAndUpdateLockfileCommandRequired
public readonly installAndUpdateLockfileCommand: string;
  • Type: string

Renders yarn install or npm install with lockfile update (not frozen).


installCiTaskRequired
public readonly installCiTask: Task;
  • Type: projen.Task

The task for installing project dependencies (frozen).


installCommandRequired
public readonly installCommand: string;
  • Type: string

Returns the command to execute in order to install all dependencies (always frozen).


installTaskRequired
public readonly installTask: Task;
  • Type: projen.Task

The task for installing project dependencies (non-frozen).


lockFileRequired
public readonly lockFile: string;
  • Type: string

The name of the lock file.


manifestRequired
  • Deprecated: use addField(x, y)
public readonly manifest: any;
  • Type: any

npmAccessRequired
public readonly npmAccess: NpmAccess;

npm package access level.


npmProvenanceRequired
public readonly npmProvenance: boolean;
  • Type: boolean

Should provenance statements be generated when package is published.


npmRegistryRequired
public readonly npmRegistry: string;
  • Type: string

The npm registry host (e.g. registry.npmjs.org).


npmRegistryUrlRequired
public readonly npmRegistryUrl: string;
  • Type: string

npm registry (e.g. https://registry.npmjs.org). Use npmRegistryHost to get just the host name.


packageManagerRequired
public readonly packageManager: NodePackageManager;

The package manager to use.


packageNameRequired
public readonly packageName: string;
  • Type: string

The name of the npm package.


projenCommandRequired
  • Deprecated: use project.projenCommand instead.
public readonly projenCommand: string;
  • Type: string

The command which executes "projen".


codeArtifactOptionsOptional
public readonly codeArtifactOptions: CodeArtifactOptions;

Options for npm packages using AWS CodeArtifact.

This is required if publishing packages to, or installing scoped packages from AWS CodeArtifact


licenseOptional
public readonly license: string;
  • Type: string

The SPDX license of this module.

undefined if this package is not licensed.


maxNodeVersionOptional
public readonly maxNodeVersion: string;
  • Type: string
  • Default: no maximum.

Maximum node version required by this package.


minNodeVersionOptional
public readonly minNodeVersion: string;
  • Type: string
  • Default: no minimum

Minimum node.js version required by this package.


npmTokenSecretOptional
public readonly npmTokenSecret: string;
  • Type: string

GitHub secret which contains the NPM token to use when publishing packages.


pnpmVersionOptional
public readonly pnpmVersion: string;
  • Type: string
  • Default: "7"

The version of PNPM to use if using PNPM as a package manager.


scopedPackagesOptionsOptional
public readonly scopedPackagesOptions: ScopedPackagesOptions[];

Options for privately hosted scoped packages.


NodeProject

Node.js project.

Initializers

import { javascript } from 'projen'

new javascript.NodeProject(options: NodeProjectOptions)
NameTypeDescription
options
NodeProjectOptions
No description.

optionsRequired

Methods

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

toString
public toString(): string

Returns a string representation of this construct.

addExcludeFromCleanup
public addExcludeFromCleanup(globs: string): void

Exclude the matching files from pre-synth cleanup.

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

globsRequired
  • 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.


addTip
public addTip(message: string): void

Prints a "tip" message during synthesis.

messageRequired
  • Type: string

The message.


annotateGenerated
public annotateGenerated(glob: string): void

Marks the provided file(s) as being generated.

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

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

globRequired
  • 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 npx projen TASK.

taskRequired
  • Type: projen.Task

The task for which the command is required.


synth
public synth(): void

Synthesize all project files into outdir.

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

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

filePathRequired
  • Type: string

The file path.

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


tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile

Finds a json file by name.

filePathRequired
  • Type: string

The file path.


tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile

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

filePathRequired
  • Type: string

The file path.


tryRemoveFile
public tryRemoveFile(filePath: string): FileBase

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

filePathRequired
  • Type: string

The file path.

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


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 npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addCompileCommand
public addCompileCommand(commands: string): void

DEPRECATED.

commandsRequired
  • Type: string

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 npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


addDevDeps
public addDevDeps(deps: string): void

Defines development/test dependencies.

depsRequired
  • Type: string

Names modules to install.

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


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

Directly set fields in package.json.

fieldsRequired
  • 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 npx projen run and the version will be recorded in your package.json file. You can upgrade manually or using yarn add/upgrade. If you wish to specify a version range use this syntax: module@^7.


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

Replaces the contents of multiple npm package.json scripts.

scriptsRequired
  • Type: {[ key: string ]: string}

The scripts to set.


addTestCommand
public addTestCommand(commands: string): void

DEPRECATED.

commandsRequired
  • Type: string

hasScript
public hasScript(name: string): boolean

Indicates if a script by the name name is defined.

nameRequired
  • Type: string

The name of the script.


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

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

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

isConstruct
import { javascript } from 'projen'

javascript.NodeProject.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 { javascript } from 'projen'

javascript.NodeProject.isProject(x: any)

Test whether the given construct is a project.

xRequired
  • Type: any

of
import { javascript } from 'projen'

javascript.NodeProject.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

NameTypeDescription
node
constructs.NodeThe tree node.
buildTask
projen.TaskNo description.
commitGenerated
booleanWhether to commit the managed files by default.
compileTask
projen.TaskNo description.
components
projen.Component[]Returns all the components within this project.
deps
projen.DependenciesProject dependencies.
ejected
booleanWhether or not the project is being ejected.
files
projen.FileBase[]All files in this project.
gitattributes
projen.GitAttributesFileThe .gitattributes file for this repository.
gitignore
projen.IgnoreFile.gitignore.
logger
projen.LoggerLogging utilities.
name
stringProject name.
outdir
stringAbsolute output directory of this project.
packageTask
projen.TaskNo description.
postCompileTask
projen.TaskNo description.
preCompileTask
projen.TaskNo description.
projectBuild
projen.ProjectBuildManages the build process of the project.
projenCommand
stringThe command to use in order to run the projen CLI.
root
projen.ProjectThe root project.
subprojects
projen.Project[]Returns all the subprojects within this project.
tasks
projen.TasksProject tasks.
testTask
projen.TaskNo description.
defaultTask
projen.TaskThis is the "default" task, the one that executes "projen".
initProject
projen.InitProjectThe options used when this project is bootstrapped via projen new.
parent
projen.ProjectA parent project.
projectType
projen.ProjectTypeNo description.
autoApprove
projen.github.AutoApproveAuto approve set up for this project.
devContainer
projen.vscode.DevContainerAccess for .devcontainer.json (used for GitHub Codespaces).
github
projen.github.GitHubAccess all github components.
gitpod
projen.GitpodAccess for Gitpod.
vscode
projen.vscode.VsCodeAccess all VSCode components.
allowLibraryDependencies
booleanNo description.
artifactsDirectory
stringThe build output directory.
artifactsJavascriptDirectory
stringThe location of the npm tarball after build (${artifactsDirectory}/js).
bundler
Bundler
No description.
entrypoint
stringNo description.
manifest
anyNo description.
npmrc
NpmConfig
The .npmrc file.
package
NodePackage
API for managing the node package.
packageManager
NodePackageManager
The package manager to use.
runScriptCommand
stringThe command to use to run scripts (e.g. yarn run or npm run depends on the package manager).
autoMerge
projen.github.AutoMergeComponent that sets up mergify for merging approved pull requests.
buildWorkflow
projen.build.BuildWorkflowThe PR build GitHub workflow.
buildWorkflowJobId
stringThe job ID of the build workflow.
jest
Jest
The Jest configuration (if enabled).
maxNodeVersion
stringMaximum node version required by this package.
minNodeVersion
stringMinimum node.js version required by this package.
npmignore
projen.IgnoreFileThe .npmignore file.
prettier
Prettier
No description.
publisher
projen.release.PublisherPackage publisher.
release
projen.release.ReleaseRelease management.
upgradeWorkflow
UpgradeDependencies
The upgrade workflow.

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
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.


projectTypeRequired
public readonly projectType: ProjectType;
  • Type: projen.ProjectType

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.


allowLibraryDependenciesRequired
  • Deprecated: use package.allowLibraryDependencies
public readonly allowLibraryDependencies: boolean;
  • Type: boolean

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;

entrypointRequired
  • Deprecated: use package.entrypoint
public readonly entrypoint: string;
  • Type: string

manifestRequired
  • Deprecated: use package.addField(x, y)
public readonly manifest: any;
  • Type: any

npmrcRequired
public readonly npmrc: NpmConfig;

The .npmrc file.


packageRequired
public readonly package: NodePackage;

API for managing the node package.


packageManagerRequired
  • Deprecated: use package.packageManager
public readonly packageManager: NodePackageManager;

The package manager to use.


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.


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;

The Jest configuration (if enabled).


maxNodeVersionOptional
public readonly maxNodeVersion: string;
  • Type: string

Maximum node version required by this package.


minNodeVersionOptional
public readonly minNodeVersion: string;
  • Type: string

Minimum node.js version required by this package.


npmignoreOptional
public readonly npmignore: IgnoreFile;
  • Type: projen.IgnoreFile

The .npmignore file.


prettierOptional
public readonly prettier: Prettier;

publisherOptional
  • Deprecated: use release.publisher.
public readonly publisher: Publisher;
  • Type: projen.release.Publisher

Package publisher.

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


releaseOptional
public readonly release: Release;
  • Type: projen.release.Release

Release management.


upgradeWorkflowOptional
public readonly upgradeWorkflow: UpgradeDependencies;

The upgrade workflow.


Constants

NameTypeDescription
DEFAULT_TASK
stringThe name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
public readonly DEFAULT_TASK: string;
  • Type: string

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

Normally this task should synthesize the project files.


NpmConfig

File representing the local NPM config in .npmrc.

Initializers

import { javascript } from 'projen'

new javascript.NpmConfig(project: NodeProject, options?: NpmConfigOptions)
NameTypeDescription
project
NodeProject
No description.
options
NpmConfigOptions
No description.

projectRequired

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
addConfig
configure a generic property.
addRegistry
configure a scoped registry.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

addConfig
public addConfig(name: string, value: string): void

configure a generic property.

nameRequired
  • Type: string

the name of the property.


valueRequired
  • Type: string

the value of the property.


addRegistry
public addRegistry(url: string, scope?: string): void

configure a scoped registry.

urlRequired
  • Type: string

the URL of the registry to use.


scopeOptional
  • Type: string

the scope the registry is used for;

leave empty for the default registry


Static Functions

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

isConstruct
import { javascript } from 'projen'

javascript.NpmConfig.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 { javascript } from 'projen'

javascript.NpmConfig.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

Prettier

Represents prettier configuration.

Initializers

import { javascript } from 'projen'

new javascript.Prettier(project: NodeProject, options: PrettierOptions)
NameTypeDescription
project
NodeProject
No description.
options
PrettierOptions
No description.

projectRequired

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
addIgnorePattern
Defines Prettier ignore Patterns these patterns will be added to the file .prettierignore.
addOverride
Add a prettier override.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

addIgnorePattern
public addIgnorePattern(pattern: string): void

Defines Prettier ignore Patterns these patterns will be added to the file .prettierignore.

patternRequired
  • Type: string

filepatterns so exclude from prettier formatting.


addOverride
public addOverride(override: PrettierOverride): void

Add a prettier override.

https://prettier.io/docs/en/configuration.html#configuration-overrides

overrideRequired

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.
of
No description.

isConstruct
import { javascript } from 'projen'

javascript.Prettier.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 { javascript } from 'projen'

javascript.Prettier.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

of
import { javascript } from 'projen'

javascript.Prettier.of(project: Project)
projectRequired
  • Type: projen.Project

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
overrides
PrettierOverride[]
Returns all Prettier overrides.
settings
PrettierSettings
Direct access to the prettier settings.
ignoreFile
projen.IgnoreFileThe .prettierIgnore file.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

overridesRequired
public readonly overrides: PrettierOverride[];

Returns all Prettier overrides.


settingsRequired
public readonly settings: PrettierSettings;

Direct access to the prettier settings.


ignoreFileOptional
public readonly ignoreFile: IgnoreFile;
  • Type: projen.IgnoreFile

The .prettierIgnore file.


Projenrc

Sets up a javascript project to use TypeScript for projenrc.

Initializers

import { javascript } from 'projen'

new javascript.Projenrc(project: Project, options?: ProjenrcOptions)
NameTypeDescription
project
projen.ProjectNo description.
options
ProjenrcOptions
No description.

projectRequired
  • Type: projen.Project

optionsOptional

Methods

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

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

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

isConstruct
import { javascript } from 'projen'

javascript.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 { javascript } from 'projen'

javascript.Projenrc.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

of
import { javascript } from 'projen'

javascript.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

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
filePath
stringThe path of the projenrc file.

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.


TypescriptConfig

Initializers

import { javascript } from 'projen'

new javascript.TypescriptConfig(project: Project, options: TypescriptConfigOptions)
NameTypeDescription
project
projen.ProjectNo description.
options
TypescriptConfigOptions
No description.

projectRequired
  • Type: projen.Project

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
addExclude
No description.
addExtends
Extend from base TypescriptConfig instance.
addInclude
No description.
resolveExtendsPath
Resolve valid TypeScript extends paths relative to this config.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

addExclude
public addExclude(pattern: string): void
patternRequired
  • Type: string

addExtends
public addExtends(value: TypescriptConfig): void

Extend from base TypescriptConfig instance.

valueRequired

Base TypescriptConfig instance.


addInclude
public addInclude(pattern: string): void
patternRequired
  • Type: string

resolveExtendsPath
public resolveExtendsPath(configPath: string): string

Resolve valid TypeScript extends paths relative to this config.

configPathRequired
  • Type: string

Path to resolve against.


Static Functions

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

isConstruct
import { javascript } from 'projen'

javascript.TypescriptConfig.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 { javascript } from 'projen'

javascript.TypescriptConfig.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
exclude
string[]No description.
extends
string[]Array of base tsconfig.json paths. Any absolute paths are resolved relative to this instance, while any relative paths are used as is.
file
projen.JsonFileNo description.
fileName
stringNo description.
include
string[]No description.
compilerOptions
TypeScriptCompilerOptions
No description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

excludeRequired
public readonly exclude: string[];
  • Type: string[]

extendsRequired
public readonly extends: string[];
  • Type: string[]

Array of base tsconfig.json paths. Any absolute paths are resolved relative to this instance, while any relative paths are used as is.


fileRequired
public readonly file: JsonFile;
  • Type: projen.JsonFile

fileNameRequired
public readonly fileName: string;
  • Type: string

includeRequired
public readonly include: string[];
  • Type: string[]

compilerOptionsOptional
public readonly compilerOptions: TypeScriptCompilerOptions;

UpgradeDependencies

Upgrade node project dependencies.

Initializers

import { javascript } from 'projen'

new javascript.UpgradeDependencies(project: NodeProject, options?: UpgradeDependenciesOptions)
NameTypeDescription
project
NodeProject
No description.
options
UpgradeDependenciesOptions
No description.

projectRequired

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
addPostBuildSteps
Add steps to execute a successful build.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

addPostBuildSteps
public addPostBuildSteps(steps: JobStep): void

Add steps to execute a successful build.

stepsRequired
  • Type: projen.github.workflows.JobStep

workflow steps.


Static Functions

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

isConstruct
import { javascript } from 'projen'

javascript.UpgradeDependencies.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 { javascript } from 'projen'

javascript.UpgradeDependencies.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
postUpgradeTask
projen.TaskA task run after the upgrade task.
upgradeTask
projen.TaskThe upgrade task.
workflows
projen.github.GithubWorkflow[]The workflows that execute the upgrades.
containerOptions
projen.github.workflows.ContainerOptionsContainer definitions for the upgrade workflow.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

postUpgradeTaskRequired
public readonly postUpgradeTask: Task;
  • Type: projen.Task

A task run after the upgrade task.


upgradeTaskRequired
public readonly upgradeTask: Task;
  • Type: projen.Task

The upgrade task.


workflowsRequired
public readonly workflows: GithubWorkflow[];
  • Type: projen.github.GithubWorkflow[]

The workflows that execute the upgrades.

One workflow per branch.


containerOptionsOptional
public readonly containerOptions: ContainerOptions;
  • Type: projen.github.workflows.ContainerOptions

Container definitions for the upgrade workflow.


Yarnrc

Initializers

import { javascript } from 'projen'

new javascript.Yarnrc(project: Project, version: string, options?: YarnrcOptions)
NameTypeDescription
project
projen.ProjectNo description.
version
stringNo description.
options
YarnrcOptions
No description.

projectRequired
  • Type: projen.Project

versionRequired
  • Type: string

optionsOptional

Methods

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

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

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

isConstruct
import { javascript } from 'projen'

javascript.Yarnrc.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 { javascript } from 'projen'

javascript.Yarnrc.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

Structs

AddBundleOptions

Options for addBundle().

Initializer

import { javascript } from 'projen'

const addBundleOptions: javascript.AddBundleOptions = { ... }

Properties

NameTypeDescription
externals
string[]You can mark a file or a package as external to exclude it from your build.
sourcemap
booleanInclude a source map in the bundle.
watchTask
booleanIn addition to the bundle:xyz task, creates bundle:xyz:watch task which will invoke the same esbuild command with the --watch flag.
platform
stringesbuild platform.
target
stringesbuild target.
banner
stringUse this to insert an arbitrary string at the beginning of generated JavaScript files.
charset
Charset
The charset to use for esbuild's output.
define
{[ key: string ]: string}Replace global identifiers with constant expressions.
esbuildArgs
{[ key: string ]: string | boolean}Build arguments to pass into esbuild.
executable
booleanMark the output file as executable.
footer
stringUse this to insert an arbitrary string at the end of generated JavaScript files.
format
stringOutput format for the generated JavaScript files.
inject
string[]This option allows you to automatically replace a global variable with an import from another file.
keepNames
booleanWhether to preserve the original name values even in minified code.
loaders
{[ key: string ]: string}Map of file extensions (without dot) and loaders to use for this file type.
logLevel
BundleLogLevel
Log level for esbuild.
mainFields
string[]How to determine the entry point for modules.
metafile
booleanThis option tells esbuild to write out a JSON file relative to output directory with metadata about the build.
minify
booleanWhether to minify files when bundling.
outfile
stringBundler output path relative to the asset's output directory.
sourceMapMode
SourceMapMode
Source map mode to be used when bundling.
sourcesContent
booleanWhether to include original source code in source maps when bundling.
tsconfigPath
stringThe path of the tsconfig.json file to use for bundling.

externalsOptional
public readonly externals: string[];
  • Type: string[]
  • Default: []

You can mark a file or a package as external to exclude it from your build.

Instead of being bundled, the import will be preserved (using require for the iife and cjs formats and using import for the esm format) and will be evaluated at run time instead.

This has several uses. First of all, it can be used to trim unnecessary code from your bundle for a code path that you know will never be executed. For example, a package may contain code that only runs in node but you will only be using that package in the browser. It can also be used to import code in node at run time from a package that cannot be bundled. For example, the fsevents package contains a native extension, which esbuild doesn't support.


sourcemapOptional
public readonly sourcemap: boolean;
  • Type: boolean
  • Default: false

Include a source map in the bundle.


watchTaskOptional
public readonly watchTask: boolean;
  • Type: boolean
  • Default: true

In addition to the bundle:xyz task, creates bundle:xyz:watch task which will invoke the same esbuild command with the --watch flag.

This can be used to continusouly watch for changes.


platformRequired
public readonly platform: string;
  • Type: string

esbuild platform.


Example

"node"
targetRequired
public readonly target: string;
  • Type: string

esbuild target.


Example

"node12"
bannerOptional
public readonly banner: string;
  • Type: string
  • Default: no comments are passed

Use this to insert an arbitrary string at the beginning of generated JavaScript files.

This is similar to footer which inserts at the end instead of the beginning.

This is commonly used to insert comments:


charsetOptional
public readonly charset: Charset;
  • Type: Charset
  • Default: Charset.ASCII

The charset to use for esbuild's output.

By default esbuild's output is ASCII-only. Any non-ASCII characters are escaped using backslash escape sequences. Using escape sequences makes the generated output slightly bigger, and also makes it harder to read. If you would like for esbuild to print the original characters without using escape sequences, use Charset.UTF8.

https://esbuild.github.io/api/#charset


defineOptional
public readonly define: {[ key: string ]: string};
  • Type: {[ key: string ]: string}
  • Default: no replacements are made

Replace global identifiers with constant expressions.

For example, { 'process.env.DEBUG': 'true' }.

Another example, { 'process.env.API_KEY': JSON.stringify('xxx-xxxx-xxx') }.


esbuildArgsOptional
public readonly esbuildArgs: {[ key: string ]: string | boolean};
  • Type: {[ key: string ]: string | boolean}
  • Default: no additional esbuild arguments are passed

Build arguments to pass into esbuild.

For example, to add the --log-limit flag:

project.bundler.addBundle("./src/hello.ts", {
platform: "node",
target: "node18",
sourcemap: true,
format: "esm",
esbuildArgs: {
"--log-limit": "0",
},
});

executableOptional
public readonly executable: boolean;
  • Type: boolean
  • Default: false

Mark the output file as executable.


footerOptional
public readonly footer: string;
  • Type: string
  • Default: no comments are passed

Use this to insert an arbitrary string at the end of generated JavaScript files.

This is similar to banner which inserts at the beginning instead of the end.

This is commonly used to insert comments


formatOptional
public readonly format: string;
  • Type: string
  • Default: undefined

Output format for the generated JavaScript files.

There are currently three possible values that can be configured: "iife", "cjs", and "esm".

If not set (undefined), esbuild picks an output format for you based on platform:

  • "cjs" if platform is "node"
  • "iife" if platform is "browser"
  • "esm" if platform is "neutral"

Note: If making a bundle to run under node with ESM, set format to "esm" instead of setting platform to "neutral".

https://esbuild.github.io/api/#format


injectOptional
public readonly inject: string[];
  • Type: string[]
  • Default: no code is injected

This option allows you to automatically replace a global variable with an import from another file.

https://esbuild.github.io/api/#inject


keepNamesOptional
public readonly keepNames: boolean;
  • Type: boolean
  • Default: false

Whether to preserve the original name values even in minified code.

In JavaScript the name property on functions and classes defaults to a nearby identifier in the source code.

However, minification renames symbols to reduce code size and bundling sometimes need to rename symbols to avoid collisions. That changes value of the name property for many of these cases. This is usually fine because the name property is normally only used for debugging. However, some frameworks rely on the name property for registration and binding purposes. If this is the case, you can enable this option to preserve the original name values even in minified code.


loadersOptional
public readonly loaders: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Map of file extensions (without dot) and loaders to use for this file type.

Loaders are appended to the esbuild command by --loader:.extension=loader


logLevelOptional
public readonly logLevel: BundleLogLevel;

Log level for esbuild.

This is also propagated to the package manager and applies to its specific install command.


mainFieldsOptional
public readonly mainFields: string[];
  • Type: string[]
  • Default: []

How to determine the entry point for modules.

Try ['module', 'main'] to default to ES module versions.


metafileOptional
public readonly metafile: boolean;
  • Type: boolean
  • Default: false

This option tells esbuild to write out a JSON file relative to output directory with metadata about the build.

The metadata in this JSON file follows this schema (specified using TypeScript syntax):

{
outputs: {
[path: string]: {
bytes: number
inputs: {
[path: string]: { bytesInOutput: number }
}
imports: { path: string }[]
exports: string[]
}
}
}

This data can then be analyzed by other tools. For example, bundle buddy can consume esbuild's metadata format and generates a treemap visualization of the modules in your bundle and how much space each one takes up.

https://esbuild.github.io/api/#metafile


minifyOptional
public readonly minify: boolean;
  • Type: boolean
  • Default: false

Whether to minify files when bundling.


outfileOptional
public readonly outfile: string;
  • Type: string
  • Default: "index.js"

Bundler output path relative to the asset's output directory.


sourceMapModeOptional
public readonly sourceMapMode: SourceMapMode;

Source map mode to be used when bundling.

https://esbuild.github.io/api/#sourcemap


sourcesContentOptional
public readonly sourcesContent: boolean;
  • Type: boolean
  • Default: true

Whether to include original source code in source maps when bundling.

https://esbuild.github.io/api/#sources-content


tsconfigPathOptional
public readonly tsconfigPath: string;
  • Type: string
  • Default: "tsconfig.json"

The path of the tsconfig.json file to use for bundling.


BuildWorkflowOptions

Build workflow options for NodeProject.

Initializer

import { javascript } from 'projen'

const buildWorkflowOptions: javascript.BuildWorkflowOptions = { ... }

Properties

NameTypeDescription
name
stringName of the buildfile (e.g. "build" becomes "build.yml").
permissions
projen.github.workflows.JobPermissionsPermissions granted to the build job To limit job permissions for contents, the desired permissions have to be explicitly set, e.g.: { contents: JobPermission.NONE }.
preBuildSteps
projen.github.workflows.JobStep[]Steps to execute before the build.
workflowTriggers
projen.github.workflows.TriggersBuild workflow triggers.
mutableBuild
booleanAutomatically update files modified during builds to pull-request branches.

nameOptional
public readonly name: string;
  • Type: string
  • Default: "build"

Name of the buildfile (e.g. "build" becomes "build.yml").


permissionsOptional
public readonly permissions: JobPermissions;
  • Type: projen.github.workflows.JobPermissions
  • Default: { contents: JobPermission.WRITE }

Permissions granted to the build job To limit job permissions for contents, the desired permissions have to be explicitly set, e.g.: { contents: JobPermission.NONE }.


preBuildStepsOptional
public readonly preBuildSteps: JobStep[];
  • Type: projen.github.workflows.JobStep[]
  • Default: []

Steps to execute before the build.


workflowTriggersOptional
public readonly workflowTriggers: Triggers;
  • Type: projen.github.workflows.Triggers
  • Default: "{ pullRequest: {}, workflowDispatch: {} }"

Build workflow triggers.


mutableBuildOptional
public readonly mutableBuild: boolean;
  • Type: boolean
  • Default: true

Automatically update files modified during builds to pull-request branches.

This means that any files synthesized by projen or e.g. test snapshots will always be up-to-date before a PR is merged.

Implies that PR builds do not have anti-tamper checks.


Bundle

Initializer

import { javascript } from 'projen'

const bundle: javascript.Bundle = { ... }

Properties

NameTypeDescription
bundleTask
projen.TaskThe task that produces this bundle.
outdir
stringBase directory containing the output file (relative to project root).
outfile
stringLocation of the output file (relative to project root).
watchTask
projen.TaskThe "watch" task for this bundle.

bundleTaskRequired
public readonly bundleTask: Task;
  • Type: projen.Task

The task that produces this bundle.


outdirRequired
public readonly outdir: string;
  • Type: string

Base directory containing the output file (relative to project root).


outfileRequired
public readonly outfile: string;
  • Type: string

Location of the output file (relative to project root).


watchTaskOptional
public readonly watchTask: Task;
  • Type: projen.Task

The "watch" task for this bundle.


BundlerOptions

Options for Bundler.

Initializer

import { javascript } from 'projen'

const bundlerOptions: javascript.BundlerOptions = { ... }

Properties

NameTypeDescription
addToPreCompile
booleanInstall the bundle command as a pre-compile phase.
assetsDir
stringOutput directory for all bundles.
esbuildVersion
stringThe semantic version requirement for esbuild.
loaders
{[ key: string ]: string}Map of file extensions (without dot) and loaders to use for this file type.
runBundleTask
RunBundleTask
Choose which phase (if any) to add the bundle command to.

addToPreCompileOptional
  • Deprecated: Use runBundleTask instead.
public readonly addToPreCompile: boolean;
  • Type: boolean
  • Default: true

Install the bundle command as a pre-compile phase.


assetsDirOptional
public readonly assetsDir: string;
  • Type: string
  • Default: "assets"

Output directory for all bundles.


esbuildVersionOptional
public readonly esbuildVersion: string;
  • Type: string
  • Default: no specific version (implies latest)

The semantic version requirement for esbuild.


loadersOptional
public readonly loaders: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Map of file extensions (without dot) and loaders to use for this file type.

Loaders are appended to the esbuild command by --loader:.extension=loader


runBundleTaskOptional
public readonly runBundleTask: RunBundleTask;

Choose which phase (if any) to add the bundle command to.

Note: If using addBundle() with the bundleCompiledResults, this option must be set to RunBundleTask.POST_COMPILE or RunBundleTask.MANUAL.

[AddBundleOptions.bundleCompiledResults *](AddBundleOptions.bundleCompiledResults *)


BundlingOptions

Options for bundling.

Initializer

import { javascript } from 'projen'

const bundlingOptions: javascript.BundlingOptions = { ... }

Properties

NameTypeDescription
externals
string[]You can mark a file or a package as external to exclude it from your build.
sourcemap
booleanInclude a source map in the bundle.
watchTask
booleanIn addition to the bundle:xyz task, creates bundle:xyz:watch task which will invoke the same esbuild command with the --watch flag.

externalsOptional
public readonly externals: string[];
  • Type: string[]
  • Default: []

You can mark a file or a package as external to exclude it from your build.

Instead of being bundled, the import will be preserved (using require for the iife and cjs formats and using import for the esm format) and will be evaluated at run time instead.

This has several uses. First of all, it can be used to trim unnecessary code from your bundle for a code path that you know will never be executed. For example, a package may contain code that only runs in node but you will only be using that package in the browser. It can also be used to import code in node at run time from a package that cannot be bundled. For example, the fsevents package contains a native extension, which esbuild doesn't support.


sourcemapOptional
public readonly sourcemap: boolean;
  • Type: boolean
  • Default: false

Include a source map in the bundle.


watchTaskOptional
public readonly watchTask: boolean;
  • Type: boolean
  • Default: true

In addition to the bundle:xyz task, creates bundle:xyz:watch task which will invoke the same esbuild command with the --watch flag.

This can be used to continusouly watch for changes.


CodeArtifactOptions

Options for publishing npm packages to AWS CodeArtifact.

Initializer

import { javascript } from 'projen'

const codeArtifactOptions: javascript.CodeArtifactOptions = { ... }

Properties

NameTypeDescription
accessKeyIdSecret
stringGitHub secret which contains the AWS access key ID to use when publishing packages to AWS CodeArtifact.
authProvider
CodeArtifactAuthProvider
Provider to use for authorizing requests to AWS CodeArtifact.
roleToAssume
stringARN of AWS role to be assumed prior to get authorization token from AWS CodeArtifact This property must be specified only when publishing to AWS CodeArtifact (registry contains AWS CodeArtifact URL).
secretAccessKeySecret
stringGitHub secret which contains the AWS secret access key to use when publishing packages to AWS CodeArtifact.

accessKeyIdSecretOptional
public readonly accessKeyIdSecret: string;
  • Type: string
  • Default: When the authProvider value is set to CodeArtifactAuthProvider.ACCESS_AND_SECRET_KEY_PAIR, the default is "AWS_ACCESS_KEY_ID". For CodeArtifactAuthProvider.GITHUB_OIDC, this value must be left undefined.

GitHub secret which contains the AWS access key ID to use when publishing packages to AWS CodeArtifact.

This property must be specified only when publishing to AWS CodeArtifact (npmRegistryUrl contains AWS CodeArtifact URL).


authProviderOptional
public readonly authProvider: CodeArtifactAuthProvider;

Provider to use for authorizing requests to AWS CodeArtifact.


roleToAssumeOptional
public readonly roleToAssume: string;
  • Type: string
  • Default: undefined

ARN of AWS role to be assumed prior to get authorization token from AWS CodeArtifact This property must be specified only when publishing to AWS CodeArtifact (registry contains AWS CodeArtifact URL).

When using the CodeArtifactAuthProvider.GITHUB_OIDC auth provider, this value must be defined.


secretAccessKeySecretOptional
public readonly secretAccessKeySecret: string;
  • Type: string
  • Default: When the authProvider value is set to CodeArtifactAuthProvider.ACCESS_AND_SECRET_KEY_PAIR, the default is "AWS_SECRET_ACCESS_KEY". For CodeArtifactAuthProvider.GITHUB_OIDC, this value must be left undefined.

GitHub secret which contains the AWS secret access key to use when publishing packages to AWS CodeArtifact.

This property must be specified only when publishing to AWS CodeArtifact (npmRegistryUrl contains AWS CodeArtifact URL).


CoverageThreshold

Initializer

import { javascript } from 'projen'

const coverageThreshold: javascript.CoverageThreshold = { ... }

Properties

NameTypeDescription
branches
numberNo description.
functions
numberNo description.
lines
numberNo description.
statements
numberNo description.

branchesOptional
public readonly branches: number;
  • Type: number

functionsOptional
public readonly functions: number;
  • Type: number

linesOptional
public readonly lines: number;
  • Type: number

statementsOptional
public readonly statements: number;
  • Type: number

EslintOptions

Initializer

import { javascript } from 'projen'

const eslintOptions: javascript.EslintOptions = { ... }

Properties

NameTypeDescription
dirs
string[]Files or glob patterns or directories with source files to lint (e.g. [ "src" ]).
aliasExtensions
string[]Enable import alias for module paths.
aliasMap
{[ key: string ]: string}Enable import alias for module paths.
devdirs
string[]Files or glob patterns or directories with source files that include tests and build tools.
fileExtensions
string[]File types that should be linted (e.g. [ ".js", ".ts" ]).
ignorePatterns
string[]List of file patterns that should not be linted, using the same syntax as .gitignore patterns.
lintProjenRc
booleanShould we lint .projenrc.js.
lintProjenRcFile
stringProjenrc file to lint.
prettier
booleanEnable prettier for code formatting.
tsAlwaysTryTypes
booleanAlways try to resolve types under <root>@types directory even it doesn't contain any source code.
tsconfigPath
stringPath to tsconfig.json which should be used by eslint.
yaml
booleanWrite eslint configuration as YAML instead of JSON.

dirsRequired
public readonly dirs: string[];
  • Type: string[]

Files or glob patterns or directories with source files to lint (e.g. [ "src" ]).


aliasExtensionsOptional
public readonly aliasExtensions: string[];
  • Type: string[]
  • Default: undefined

Enable import alias for module paths.


aliasMapOptional
public readonly aliasMap: {[ key: string ]: string};
  • Type: {[ key: string ]: string}
  • Default: undefined

Enable import alias for module paths.


devdirsOptional
public readonly devdirs: string[];
  • Type: string[]
  • Default: []

Files or glob patterns or directories with source files that include tests and build tools.

These sources are linted but may also import packages from devDependencies.


fileExtensionsOptional
public readonly fileExtensions: string[];
  • Type: string[]
  • Default: [".ts"]

File types that should be linted (e.g. [ ".js", ".ts" ]).


ignorePatternsOptional
public readonly ignorePatterns: string[];
  • Type: string[]
  • Default: [ '.js', '.d.ts', 'node_modules/', '*.generated.ts', 'coverage' ]

List of file patterns that should not be linted, using the same syntax as .gitignore patterns.


lintProjenRcOptional
  • Deprecated: set to false to remove any automatic rules and add manually
public readonly lintProjenRc: boolean;
  • Type: boolean
  • Default: true

Should we lint .projenrc.js.


lintProjenRcFileOptional
  • Deprecated: provide as devdirs
public readonly lintProjenRcFile: string;
  • Type: string
  • Default: "projenrc.js"

Projenrc file to lint.

Use empty string to disable.


prettierOptional
public readonly prettier: boolean;
  • Type: boolean
  • Default: false

Enable prettier for code formatting.


tsAlwaysTryTypesOptional
public readonly tsAlwaysTryTypes: boolean;
  • Type: boolean
  • Default: true

Always try to resolve types under <root>@types directory even it doesn't contain any source code.

This prevents import/no-unresolved eslint errors when importing a @types/* module that would otherwise remain unresolved.


tsconfigPathOptional
public readonly tsconfigPath: string;
  • Type: string
  • Default: "./tsconfig.json"

Path to tsconfig.json which should be used by eslint.


yamlOptional
public readonly yaml: boolean;
  • Type: boolean
  • Default: false

Write eslint configuration as YAML instead of JSON.


EslintOverride

eslint rules override.

Initializer

import { javascript } from 'projen'

const eslintOverride: javascript.EslintOverride = { ... }

Properties

NameTypeDescription
files
string[]Files or file patterns on which to apply the override.
excludedFiles
string[]Pattern(s) to exclude from this override.
extends
string[]Config(s) to extend in this override.
parser
stringThe overridden parser.
plugins
string[]plugins override.
rules
{[ key: string ]: any}The overriden rules.

filesRequired
public readonly files: string[];
  • Type: string[]

Files or file patterns on which to apply the override.


excludedFilesOptional
public readonly excludedFiles: string[];
  • Type: string[]

Pattern(s) to exclude from this override.

If a file matches any of the excluded patterns, the configuration won’t apply.


extendsOptional
public readonly extends: string[];
  • Type: string[]

Config(s) to extend in this override.


parserOptional
public readonly parser: string;
  • Type: string

The overridden parser.


pluginsOptional
public readonly plugins: string[];
  • Type: string[]

plugins override.


rulesOptional
public readonly rules: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

The overriden rules.


HasteConfig

Initializer

import { javascript } from 'projen'

const hasteConfig: javascript.HasteConfig = { ... }

Properties

NameTypeDescription
computeSha1
booleanNo description.
defaultPlatform
stringNo description.
hasteImplModulePath
stringNo description.
platforms
string[]No description.
throwOnModuleCollision
booleanNo description.

computeSha1Optional
public readonly computeSha1: boolean;
  • Type: boolean

defaultPlatformOptional
public readonly defaultPlatform: string;
  • Type: string

hasteImplModulePathOptional
public readonly hasteImplModulePath: string;
  • Type: string

platformsOptional
public readonly platforms: string[];
  • Type: string[]

throwOnModuleCollisionOptional
public readonly throwOnModuleCollision: boolean;
  • Type: boolean

JestConfigOptions

Initializer

import { javascript } from 'projen'

const jestConfigOptions: javascript.JestConfigOptions = { ... }

Properties

NameTypeDescription
additionalOptions
{[ key: string ]: any}Escape hatch to allow any value.
automock
booleanThis option tells Jest that all imported modules in your tests should be mocked automatically.
bail
number | booleanBy default, Jest runs all tests and produces all errors into the console upon completion.
cacheDirectory
stringThe directory where Jest should store its cached dependency information.
clearMocks
booleanAutomatically clear mock calls and instances before every test.
collectCoverage
booleanIndicates whether the coverage information should be collected while executing the test.
collectCoverageFrom
string[]An array of glob patterns indicating a set of files for which coverage information should be collected.
coverageDirectory
stringThe directory where Jest should output its coverage files.
coveragePathIgnorePatterns
string[]An array of regexp pattern strings that are matched against all file paths before executing the test.
coverageProvider
stringIndicates which provider should be used to instrument code for coverage.
coverageReporters
string[]A list of reporter names that Jest uses when writing coverage reports.
coverageThreshold
CoverageThreshold
Specify the global coverage thresholds.
dependencyExtractor
stringThis option allows the use of a custom dependency extractor.
displayName
anyAllows for a label to be printed alongside a test while it is running.
errorOnDeprecated
booleanMake calling deprecated APIs throw helpful error messages.
extraGlobals
string[]Test files run inside a vm, which slows calls to global context properties (e.g. Math). With this option you can specify extra properties to be defined inside the vm for faster lookups.
forceCoverageMatch
string[]Test files are normally ignored from collecting code coverage.
globals
anyA set of global variables that need to be available in all test environments.
globalSetup
stringThis option allows the use of a custom global setup module which exports an async function that is triggered once before all test suites.
globalTeardown
stringThis option allows the use of a custom global teardown module which exports an async function that is triggered once after all test suites.
haste
HasteConfig
This will be used to configure the behavior of jest-haste-map, Jest's internal file crawler/cache system.
injectGlobals
booleanInsert Jest's globals (expect, test, describe, beforeEach etc.) into the global environment. If you set this to false, you should import from.
maxConcurrency
numberA number limiting the number of tests that are allowed to run at the same time when using test.concurrent. Any test above this limit will be queued and executed once a slot is released.
maxWorkers
string | numberSpecifies the maximum number of workers the worker-pool will spawn for running tests.
moduleDirectories
string[]An array of directory names to be searched recursively up from the requiring module's location.
moduleFileExtensions
string[]An array of file extensions your modules use.
moduleNameMapper
{[ key: string ]: string | string[]}A map from regular expressions to module names or to arrays of module names that allow to stub out resources, like images or styles with a single module.
modulePathIgnorePatterns
string[]An array of regexp pattern strings that are matched against all module paths before those paths are to be considered 'visible' to the module loader.
modulePaths
string[]An alternative API to setting the NODE_PATH env variable, modulePaths is an array of absolute paths to additional locations to search when resolving modules.
notify
booleanActivates notifications for test results.
notifyMode
stringSpecifies notification mode.
preset
stringA preset that is used as a base for Jest's configuration.
prettierPath
stringSets the path to the prettier node module used to update inline snapshots.
projects
string | {[ key: string ]: any}[]When the projects configuration is provided with an array of paths or glob patterns, Jest will run tests in all of the specified projects at the same time.
reporters
JestReporter[]
Use this configuration option to add custom reporters to Jest.