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)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Optional
- Type: BundlerOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| Adds a 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.
entrypoint
Required
- Type: string
The relative path of the artifact within the project.
options
Required
- Type: AddBundleOptions
Bundling options.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { javascript } from 'projen'
javascript.Bundler.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- 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.
project
Required
- Type: projen.Project
The project.
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| string | Root bundle directory. |
| projen.Task | Gets or creates the singleton "bundle" task of the project. |
| string | The semantic version requirement for esbuild (if defined). |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
bundledir
Required
public readonly bundledir: string;
- Type: string
Root bundle directory.
bundleTask
Required
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.
esbuildVersion
Optional
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)
Name | Type | Description |
---|---|---|
|
| No description. |
|
| No description. |
project
Required
- Type: NodeProject
options
Required
- Type: EslintOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| Adds an extends item to the eslint configuration. |
| Do not lint these files. |
| Add a file, glob pattern or directory with source files to lint (e.g. [ "src" ]). |
| Add an eslint override. |
| Adds an eslint plugin. |
| Add an eslint rule. |
| 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.
extendList
Required
- Type: ...string[]
The list of "extends" to add.
addIgnorePattern
public addIgnorePattern(pattern: string): void
Do not lint these files.
pattern
Required
- Type: string
addLintPattern
public addLintPattern(pattern: string): void
Add a file, glob pattern or directory with source files to lint (e.g. [ "src" ]).
pattern
Required
- Type: string
addOverride
public addOverride(override: EslintOverride): void
Add an eslint override.
override
Required
- Type: EslintOverride
addPlugins
public addPlugins(plugins: ...string[]): void
Adds an eslint plugin.
plugins
Required
- Type: ...string[]
The names of plugins to add.
addRules
public addRules(rules: {[ key: string ]: any}): void
Add an eslint rule.
rules
Required
- Type: {[ key: string ]: any}
allowDevDeps
public allowDevDeps(pattern: string): void
Add a glob file pattern which allows importing dev dependencies.
pattern
Required
- Type: string
glob pattern.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| Returns the singleton 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.
x
Required
- Type: any
Any object.
isComponent
import { javascript } from 'projen'
javascript.Eslint.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
of
import { javascript } from 'projen'
javascript.Eslint.of(project: Project)
Returns the singleton Eslint component of a project or undefined if there is none.
project
Required
- Type: projen.Project
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| any | Direct access to the eslint configuration (escape hatch). |
| projen.Task | eslint task. |
| string[] | File patterns that should not be linted. |
| string[] | Returns an immutable copy of the lintPatterns being used by this eslint configuration. |
|
| eslint overrides. |
| {[ key: string ]: any[]} | eslint rules. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
config
Required
public readonly config: any;
- Type: any
Direct access to the eslint configuration (escape hatch).
eslintTask
Required
public readonly eslintTask: Task;
- Type: projen.Task
eslint task.
ignorePatterns
Required
public readonly ignorePatterns: string[];
- Type: string[]
File patterns that should not be linted.
lintPatterns
Required
public readonly lintPatterns: string[];
- Type: string[]
Returns an immutable copy of the lintPatterns being used by this eslint configuration.
overrides
Required
public readonly overrides: EslintOverride[];
- Type: EslintOverride[]
eslint overrides.
rules
Required
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 whenupdateSnapshot: UpdateSnapshot: NEVER
.
Initializers
import { javascript } from 'projen'
new javascript.Jest(project: NodeProject, options?: JestOptions)
Name | Type | Description |
---|---|---|
|
| No description. |
|
| No description. |
project
Required
- Type: NodeProject
options
Optional
- Type: JestOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| No description. |
| Adds one or more moduleNameMapper entries to Jest's configuration. |
| Adds one or more modulePaths to Jest's configuration. |
| No description. |
| Adds one or more roots to Jest's configuration. |
| Adds a a setup file to Jest's setupFiles configuration. |
| Adds a a setup file to Jest's setupFilesAfterEnv configuration. |
| No description. |
| Adds a test match pattern. |
| Adds a watch ignore pattern. |
| Build standard test match patterns for a 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.
addIgnorePattern
public addIgnorePattern(pattern: string): void
pattern
Required
- 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.
moduleNameMapperAdditions
Required
- 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.
modulePaths
Required
- Type: ...string[]
An array of absolute paths to additional locations to search when resolving modules *.
addReporter
public addReporter(reporter: JestReporter): void
reporter
Required
- Type: JestReporter
addRoots
public addRoots(roots: ...string[]): void
Adds one or more roots to Jest's configuration.
roots
Required
- 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.
file
Required
- Type: string
File path to setup file.
addSetupFileAfterEnv
public addSetupFileAfterEnv(file: string): void
Adds a a setup file to Jest's setupFilesAfterEnv configuration.
file
Required
- Type: string
File path to setup file.
addSnapshotResolver
public addSnapshotResolver(file: string): void
file
Required
- Type: string
addTestMatch
public addTestMatch(pattern: string): void
Adds a test match pattern.
pattern
Required
- Type: string
glob pattern to match for tests.
addWatchIgnorePattern
public addWatchIgnorePattern(pattern: string): void
Adds a watch ignore pattern.
pattern
Required
- Type: string
The pattern (regular expression).
discoverTestMatchPatternsForDirs
public discoverTestMatchPatternsForDirs(dirs: string[], options?: JestDiscoverTestMatchPatternsForDirsOptions): void
Build standard test match patterns for a directory.
dirs
Required
- Type: string[]
The directories to add test matches for.
Matches any folder if not specified or an empty array.
options
Optional
Options for building test match patterns.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { javascript } from 'projen'
javascript.Jest.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- 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.
project
Required
- Type: projen.Project
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| any | Escape hatch. |
| string | Jest version, including @ symbol, like @^29 . |
| projen.JsonFile | Jest config file. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
config
Required
public readonly config: any;
- Type: any
Escape hatch.
jestVersion
Required
public readonly jestVersion: string;
- Type: string
Jest version, including @
symbol, like @^29
.
file
Optional
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)
Name | Type | Description |
---|---|---|
| constructs.Construct | No description. |
|
| No description. |
scope
Required
- Type: constructs.Construct
options
Required
- Type: LicenseCheckerOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
isConstruct
import { 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.
x
Required
- Type: any
Any object.
isComponent
import { javascript } from 'projen'
javascript.LicenseChecker.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| projen.Task | No description. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
task
Required
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)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Optional
- Type: NodePackageOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| No description. |
| Defines bundled dependencies. |
| Defines normal dependencies. |
| Defines development/test dependencies. |
| Adds an engines requirement to your package. |
| Directly set fields in package.json . |
| Adds keywords to package.json (deduplicated). |
| Defines resolutions for dependencies to change the normally resolved version of a dependency to something else. |
| Defines peer dependencies. |
| Sets the package version. |
| Indicates if a script by the given name is defined. |
| Removes an npm script (always successful). |
| Add a npm package.json script. |
| 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
bins
Required
- 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
.
deps
Required
- 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.
deps
Required
- 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.
deps
Required
- 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.
engine
Required
- Type: string
The engine (e.g. node
).
version
Required
- Type: string
The semantic version requirement (e.g. ^10
).
addField
public addField(name: string, value: any): void
Directly set fields in package.json
.
name
Required
- Type: string
field name.
value
Required
- Type: any
field value.
addKeywords
public addKeywords(keywords: ...string[]): void
Adds keywords to package.json (deduplicated).
keywords
Required
- 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.
resolutions
Required
- 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.
deps
Required
- 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.
version
Required
- Type: string
Package version.
hasScript
hasScript
public hasScript(name: string): boolean
Indicates if a script by the given name is defined.
name
Required
- Type: string
The name of the script.
removeScript
public removeScript(name: string): void
Removes an npm script (always successful).
name
Required
- Type: string
The name of the script.
setScript
public setScript(name: string, command: string): void
Add a npm package.json script.
name
Required
- Type: string
The script name.
command
Required
- Type: string
The command to execute.
tryResolveDependencyVersion
public tryResolveDependencyVersion(dependencyName: string): string
Attempt to resolve the currently installed version for a given dependency.
dependencyName
Required
- Type: string
Dependency to resolve for.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { javascript } from 'projen'
javascript.NodePackage.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- 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.
project
Required
- Type: projen.Project
The project.
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| boolean | Allow project to take library dependencies. |
| string | The module's entrypoint (e.g. lib/index.js ). |
| projen.JsonFile | The package.json file. |
| string | Renders yarn install or npm install with lockfile update (not frozen). |
| projen.Task | The task for installing project dependencies (frozen). |
| string | Returns the command to execute in order to install all dependencies (always frozen). |
| projen.Task | The task for installing project dependencies (non-frozen). |
| string | The name of the lock file. |
| any | No description. |
|
| npm package access level. |
| boolean | Should provenance statements be generated when package is published. |
| string | The npm registry host (e.g. registry.npmjs.org ). |
| string | npm registry (e.g. https://registry.npmjs.org ). Use npmRegistryHost to get just the host name. |
|
| The package manager to use. |
| string | The name of the npm package. |
| string | The command which executes "projen". |
|
| Options for npm packages using AWS CodeArtifact. |
| string | The SPDX license of this module. |
| string | Maximum node version supported by this package. |
| string | The minimum node version required by this package to function. |
| string | GitHub secret which contains the NPM token to use when publishing packages. |
| string | The version of PNPM to use if using PNPM as a package manager. |
|
| Options for privately hosted scoped packages. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
allowLibraryDependencies
Required
public readonly allowLibraryDependencies: boolean;
- Type: boolean
Allow project to take library dependencies.
entrypoint
Required
public readonly entrypoint: string;
- Type: string
The module's entrypoint (e.g. lib/index.js
).
file
Required
public readonly file: JsonFile;
- Type: projen.JsonFile
The package.json file.
installAndUpdateLockfileCommand
Required
public readonly installAndUpdateLockfileCommand: string;
- Type: string
Renders yarn install
or npm install
with lockfile update (not frozen).
installCiTask
Required
public readonly installCiTask: Task;
- Type: projen.Task
The task for installing project dependencies (frozen).
installCommand
Required
public readonly installCommand: string;
- Type: string
Returns the command to execute in order to install all dependencies (always frozen).
installTask
Required
public readonly installTask: Task;
- Type: projen.Task
The task for installing project dependencies (non-frozen).
lockFile
Required
public readonly lockFile: string;
- Type: string
The name of the lock file.
manifest
Required
manifest
- Deprecated: use
addField(x, y)
public readonly manifest: any;
- Type: any
npmAccess
Required
public readonly npmAccess: NpmAccess;
- Type: NpmAccess
npm package access level.
npmProvenance
Required
public readonly npmProvenance: boolean;
- Type: boolean
Should provenance statements be generated when package is published.
npmRegistry
Required
public readonly npmRegistry: string;
- Type: string
The npm registry host (e.g. registry.npmjs.org
).
npmRegistryUrl
Required
public readonly npmRegistryUrl: string;
- Type: string
npm registry (e.g. https://registry.npmjs.org
). Use npmRegistryHost
to get just the host name.
packageManager
Required
public readonly packageManager: NodePackageManager;
- Type: NodePackageManager
The package manager to use.
packageName
Required
public readonly packageName: string;
- Type: string
The name of the npm package.
projenCommand
Required
projenCommand
- Deprecated: use
project.projenCommand
instead.
public readonly projenCommand: string;
- Type: string
The command which executes "projen".
codeArtifactOptions
Optional
public readonly codeArtifactOptions: CodeArtifactOptions;
- Type: CodeArtifactOptions
- Default: undefined
Options for npm packages using AWS CodeArtifact.
This is required if publishing packages to, or installing scoped packages from AWS CodeArtifact
license
Optional
public readonly license: string;
- Type: string
The SPDX license of this module.
undefined
if this package is not licensed.
maxNodeVersion
Optional
public readonly maxNodeVersion: string;
- Type: string
Maximum node version supported by this package.
The value indicates the package is incompatible with newer versions.
minNodeVersion
Optional
public readonly minNodeVersion: string;
- Type: string
The minimum node version required by this package to function.
This value indicates the package is incompatible with older versions.
npmTokenSecret
Optional
public readonly npmTokenSecret: string;
- Type: string
GitHub secret which contains the NPM token to use when publishing packages.
pnpmVersion
Optional
public readonly pnpmVersion: string;
- Type: string
- Default: "7"
The version of PNPM to use if using PNPM as a package manager.
scopedPackagesOptions
Optional
public readonly scopedPackagesOptions: ScopedPackagesOptions[];
- Type: ScopedPackagesOptions[]
- Default: undefined
Options for privately hosted scoped packages.
NodeProject
Node.js project.
Initializers
import { javascript } from 'projen'
new javascript.NodeProject(options: NodeProjectOptions)
Name | Type | Description |
---|---|---|
|
| No description. |
options
Required
- Type: NodeProjectOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Exclude the matching files from pre-synth cleanup. |
| Adds a .gitignore pattern. |
| Adds patterns to be ignored by npm. |
| Adds a new task to this project. |
| Prints a "tip" message during synthesis. |
| Marks the provided file(s) as being generated. |
| Called after all components are synthesized. |
| Called before all components are synthesized. |
| Removes a task from a project. |
| Returns the shell command to execute in order to run a task. |
| Synthesize all project files into outdir . |
| Finds a file at the specified relative path within this project and all its subprojects. |
| Finds a json file by name. |
| Finds an object file (like JsonFile, YamlFile, etc.) by name. |
| Finds a file at the specified relative path within this project and removes it. |
| No description. |
| Defines bundled dependencies. |
| DEPRECATED. |
| Defines normal dependencies. |
| Defines development/test dependencies. |
| Directly set fields in package.json . |
| Adds keywords to package.json (deduplicated). |
| Defines peer dependencies. |
| Replaces the contents of multiple npm package.json scripts. |
| DEPRECATED. |
| Indicates if a script by the name name is defined. |
| Removes the npm script (always successful). |
| Returns the set of workflow steps which should be executed to bootstrap a workflow. |
| Replaces the contents of an npm package.json script. |
toString
public toString(): string
Returns a string representation of this construct.
addExcludeFromCleanup
public addExcludeFromCleanup(globs: ...string[]): void
Exclude the matching files from pre-synth cleanup.
Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.
globs
Required
- Type: ...string[]
The glob patterns to match.
addGitIgnore
public addGitIgnore(pattern: string): void
Adds a .gitignore pattern.
pattern
Required
- Type: string
The glob pattern to ignore.
addPackageIgnore
public addPackageIgnore(pattern: string): void
Adds patterns to be ignored by npm.
pattern
Required
- 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.
name
Required
- Type: string
The task name to add.
props
Optional
- Type: projen.TaskOptions
Task properties.
addTip
addTip
public addTip(message: string): void
Prints a "tip" message during synthesis.
message
Required
- Type: string
The message.
annotateGenerated
public annotateGenerated(glob: string): void
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
glob
Required
- Type: string
the glob pattern to match (could be a file path).
postSynthesize
public postSynthesize(): void
Called after all components are synthesized.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before all components are synthesized.
removeTask
public removeTask(name: string): Task
Removes a task from a project.
name
Required
- Type: string
The name of the task to remove.
runTaskCommand
public runTaskCommand(task: Task): string
Returns the shell command to execute in order to run a task.
This will
typically be npx projen TASK
.
task
Required
- Type: projen.Task
The task for which the command is required.
synth
public synth(): void
Synthesize all project files into outdir
.
- Call "this.preSynthesize()"
- Delete all generated files
- Synthesize all subprojects
- Synthesize all components of this project
- Call "postSynthesize()" for all components of this project
- Call "this.postSynthesize()"
tryFindFile
public tryFindFile(filePath: string): FileBase
Finds a file at the specified relative path within this project and all its subprojects.
filePath
Required
- Type: string
The file path.
If this path is relative, it will be resolved from the root of this project.
tryFindJsonFile
tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile
Finds a json file by name.
filePath
Required
- Type: string
The file path.
tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile
Finds an object file (like JsonFile, YamlFile, etc.) by name.
filePath
Required
- Type: string
The file path.
tryRemoveFile
public tryRemoveFile(filePath: string): FileBase
Finds a file at the specified relative path within this project and removes it.
filePath
Required
- Type: string
The file path.
If this path is relative, it will be resolved from the root of this project.
addBins
public addBins(bins: {[ key: string ]: string}): void
bins
Required
- 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
.
deps
Required
- 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
addCompileCommand
public addCompileCommand(commands: ...string[]): void
DEPRECATED.
commands
Required
- Type: ...string[]
addDeps
public addDeps(deps: ...string[]): void
Defines normal dependencies.
deps
Required
- 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.
deps
Required
- 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
.
fields
Required
- Type: {[ key: string ]: any}
The fields to set.
addKeywords
public addKeywords(keywords: ...string[]): void
Adds keywords to package.json (deduplicated).
keywords
Required
- 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.
deps
Required
- 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.
scripts
Required
- Type: {[ key: string ]: string}
The scripts to set.
addTestCommand
addTestCommand
public addTestCommand(commands: ...string[]): void
DEPRECATED.
commands
Required
- Type: ...string[]
hasScript
hasScript
public hasScript(name: string): boolean
Indicates if a script by the name name is defined.
name
Required
- Type: string
The name of the script.
removeScript
public removeScript(name: string): void
Removes the npm script (always successful).
name
Required
- 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.
options
Optional
Options.
setScript
public setScript(name: string, command: string): void
Replaces the contents of an npm package.json script.
name
Required
- Type: string
The script name.
command
Required
- Type: string
The command to execute.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a project. |
| Find the closest ancestor project for given construct. |
isConstruct
import { 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.
x
Required
- Type: any
Any object.
isProject
import { javascript } from 'projen'
javascript.NodeProject.isProject(x: any)
Test whether the given construct is a project.
x
Required
- 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.
construct
Required
- Type: constructs.IConstruct
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Task | No description. |
| boolean | Whether to commit the managed files by default. |
| projen.Task | No description. |
| projen.Component[] | Returns all the components within this project. |
| projen.Dependencies | Project dependencies. |
| boolean | Whether or not the project is being ejected. |
| projen.FileBase[] | All files in this project. |
| projen.GitAttributesFile | The .gitattributes file for this repository. |
| projen.IgnoreFile | .gitignore. |
| projen.Logger | Logging utilities. |
| string | Project name. |
| string | Absolute output directory of this project. |
| projen.Task | No description. |
| projen.Task | No description. |
| projen.Task | No description. |
| projen.ProjectBuild | Manages the build process of the project. |
| string | The command to use in order to run the projen CLI. |
| projen.Project | The root project. |
| projen.Project[] | Returns all the subprojects within this project. |
| projen.Tasks | Project tasks. |
| projen.Task | No description. |
| projen.Task | This is the "default" task, the one that executes "projen". |
| projen.InitProject | The options used when this project is bootstrapped via projen new . |
| projen.Project | A parent project. |
| projen.ProjectType | No description. |
| projen.github.AutoApprove | Auto approve set up for this project. |
| projen.vscode.DevContainer | Access for .devcontainer.json (used for GitHub Codespaces). |
| projen.github.GitHub | Access all github components. |
| projen.Gitpod | Access for Gitpod. |
| projen.vscode.VsCode | Access all VSCode components. |
| boolean | No description. |
| string | The build output directory. |
| string | The location of the npm tarball after build (${artifactsDirectory}/js ). |
|
| No description. |
| string | No description. |
| any | No description. |
|
| The .npmrc file. |
|
| API for managing the node package. |
|
| The package manager to use. |
| string | The command to use to run scripts (e.g. yarn run or npm run depends on the package manager). |
| projen.github.AutoMerge | Component that sets up mergify for merging approved pull requests. |
| projen.build.BuildWorkflow | The PR build GitHub workflow. |
| string | The job ID of the build workflow. |
|
| The Jest configuration (if enabled). |
| string | Maximum node version supported by this package. |
| string | The minimum node version required by this package to function. |
| projen.IgnoreFile | The .npmignore file. |
|
| No description. |
| projen.release.Publisher | Package publisher. |
| projen.release.Release | Release management. |
|
| The upgrade workflow. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
buildTask
Required
public readonly buildTask: Task;
- Type: projen.Task
commitGenerated
Required
public readonly commitGenerated: boolean;
- Type: boolean
Whether to commit the managed files by default.
compileTask
Required
public readonly compileTask: Task;
- Type: projen.Task
components
Required
public readonly components: Component[];
- Type: projen.Component[]
Returns all the components within this project.
deps
Required
public readonly deps: Dependencies;
- Type: projen.Dependencies
Project dependencies.
ejected
Required
public readonly ejected: boolean;
- Type: boolean
Whether or not the project is being ejected.
files
Required
public readonly files: FileBase[];
- Type: projen.FileBase[]
All files in this project.
gitattributes
Required
public readonly gitattributes: GitAttributesFile;
- Type: projen.GitAttributesFile
The .gitattributes file for this repository.
gitignore
Required
public readonly gitignore: IgnoreFile;
- Type: projen.IgnoreFile
.gitignore.
logger
Required
public readonly logger: Logger;
- Type: projen.Logger
Logging utilities.
name
Required
public readonly name: string;
- Type: string
Project name.
outdir
Required
public readonly outdir: string;
- Type: string
Absolute output directory of this project.
packageTask
Required
public readonly packageTask: Task;
- Type: projen.Task
postCompileTask
Required
public readonly postCompileTask: Task;
- Type: projen.Task
preCompileTask
Required
public readonly preCompileTask: Task;
- Type: projen.Task
projectBuild
Required
public readonly projectBuild: ProjectBuild;
- Type: projen.ProjectBuild
Manages the build process of the project.
projenCommand
Required
public readonly projenCommand: string;
- Type: string
The command to use in order to run the projen CLI.
root
Required
public readonly root: Project;
- Type: projen.Project
The root project.
subprojects
Required
public readonly subprojects: Project[];
- Type: projen.Project[]
Returns all the subprojects within this project.
tasks
Required
public readonly tasks: Tasks;
- Type: projen.Tasks
Project tasks.
testTask
Required
public readonly testTask: Task;
- Type: projen.Task
defaultTask
Optional
public readonly defaultTask: Task;
- Type: projen.Task
This is the "default" task, the one that executes "projen".
Undefined if the project is being ejected.
initProject
Optional
public readonly initProject: InitProject;
- Type: 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.
parent
Optional
public readonly parent: Project;
- Type: projen.Project
A parent project.
If undefined, this is the root project.
projectType
Required
public readonly projectType: ProjectType;
- Type: projen.ProjectType
autoApprove
Optional
public readonly autoApprove: AutoApprove;
- Type: projen.github.AutoApprove
Auto approve set up for this project.
devContainer
Optional
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
github
Optional
public readonly github: GitHub;
- Type: projen.github.GitHub
Access all github components.
This will be undefined
for subprojects.
gitpod
Optional
public readonly gitpod: Gitpod;
- Type: projen.Gitpod
Access for Gitpod.
This will be undefined
if gitpod boolean is false
vscode
Optional
public readonly vscode: VsCode;
- Type: projen.vscode.VsCode
Access all VSCode components.
This will be undefined
for subprojects.
allowLibraryDependencies
Required
allowLibraryDependencies
- Deprecated: use
package.allowLibraryDependencies
public readonly allowLibraryDependencies: boolean;
- Type: boolean
artifactsDirectory
Required
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
.
artifactsJavascriptDirectory
Required
public readonly artifactsJavascriptDirectory: string;
- Type: string
The location of the npm tarball after build (${artifactsDirectory}/js
).
bundler
Required
public readonly bundler: Bundler;
- Type: Bundler
entrypoint
Required
entrypoint
- Deprecated: use
package.entrypoint
public readonly entrypoint: string;
- Type: string
manifest
Required
manifest
- Deprecated: use
package.addField(x, y)
public readonly manifest: any;
- Type: any
npmrc
Required
public readonly npmrc: NpmConfig;
- Type: NpmConfig
The .npmrc file.
package
Required
public readonly package: NodePackage;
- Type: NodePackage
API for managing the node package.
packageManager
Required
packageManager
- Deprecated: use
package.packageManager
public readonly packageManager: NodePackageManager;
- Type: NodePackageManager
The package manager to use.
runScriptCommand
Required
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).
autoMerge
Optional
public readonly autoMerge: AutoMerge;
- Type: projen.github.AutoMerge
Component that sets up mergify for merging approved pull requests.
buildWorkflow
Optional
public readonly buildWorkflow: BuildWorkflow;
- Type: projen.build.BuildWorkflow
The PR build GitHub workflow.
undefined
if buildWorkflow
is disabled.
buildWorkflowJobId
Optional
public readonly buildWorkflowJobId: string;
- Type: string
The job ID of the build workflow.
jest
Optional
public readonly jest: Jest;
- Type: Jest
The Jest configuration (if enabled).
maxNodeVersion
Optional
public readonly maxNodeVersion: string;
- Type: string
Maximum node version supported by this package.
The value indicates the package is incompatible with newer versions.
minNodeVersion
Optional
public readonly minNodeVersion: string;
- Type: string
The minimum node version required by this package to function.
This value indicates the package is incompatible with older versions.
npmignore
Optional
public readonly npmignore: IgnoreFile;
- Type: projen.IgnoreFile
The .npmignore file.
prettier
Optional
public readonly prettier: Prettier;
- Type: Prettier
publisher
Optional
publisher
- 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.
release
Optional
public readonly release: Release;
- Type: projen.release.Release
Release management.
upgradeWorkflow
Optional
public readonly upgradeWorkflow: UpgradeDependencies;
- Type: UpgradeDependencies
The upgrade workflow.
Constants
Name | Type | Description |
---|---|---|
| string | The name of the default task (the task executed when projen is run without arguments). |
DEFAULT_TASK
Required
public readonly DEFAULT_TASK: string;
- Type: string
The name of the default task (the task executed when projen
is run without arguments).
Normally this task should synthesize the project files.
NpmConfig
File representing the local NPM config in .npmrc.
Initializers
import { javascript } from 'projen'
new javascript.NpmConfig(project: NodeProject, options?: NpmConfigOptions)
Name | Type | Description |
---|---|---|
|
| No description. |
|
| No description. |
project
Required
- Type: NodeProject
options
Optional
- Type: NpmConfigOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| configure a generic property. |
| 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.
name
Required
- Type: string
the name of the property.
value
Required
- Type: string
the value of the property.
addRegistry
public addRegistry(url: string, scope?: string): void
configure a scoped registry.
url
Required
- Type: string
the URL of the registry to use.
scope
Optional
- Type: string
the scope the registry is used for;
leave empty for the default registry
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { javascript } from 'projen'
javascript.NpmConfig.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
Prettier
Represents prettier configuration.
Initializers
import { javascript } from 'projen'
new javascript.Prettier(project: NodeProject, options: PrettierOptions)
Name | Type | Description |
---|---|---|
|
| No description. |
|
| No description. |
project
Required
- Type: NodeProject
options
Required
- Type: PrettierOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| Defines Prettier ignore Patterns these patterns will be added to the file .prettierignore. |
| 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.
pattern
Required
- 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
override
Required
- Type: PrettierOverride
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { javascript } from 'projen'
javascript.Prettier.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
of
import { javascript } from 'projen'
javascript.Prettier.of(project: Project)
project
Required
- Type: projen.Project
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
|
| Returns all Prettier overrides. |
|
| Direct access to the prettier settings. |
| projen.IgnoreFile | The .prettierIgnore file. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
overrides
Required
public readonly overrides: PrettierOverride[];
- Type: PrettierOverride[]
Returns all Prettier overrides.
settings
Required
public readonly settings: PrettierSettings;
- Type: PrettierSettings
Direct access to the prettier settings.
ignoreFile
Optional
public readonly ignoreFile: IgnoreFile;
- Type: projen.IgnoreFile
The .prettierIgnore file.
Projenrc
A projenrc file written in JavaScript.
This component can be instantiated in any type of project and has no expectations around the project's main language.
Initializers
import { javascript } from 'projen'
new javascript.Projenrc(project: Project, options?: ProjenrcOptions)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Optional
- Type: ProjenrcOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| Returns the Projenrc instance associated with a project or undefined if there is no Projenrc. |
isConstruct
import { 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.
x
Required
- Type: any
Any object.
isComponent
import { javascript } from 'projen'
javascript.Projenrc.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- 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.
project
Required
- Type: projen.Project
The project.
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| string | The path of the projenrc file. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
filePath
Required
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)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Required
- Type: TypescriptConfigOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| Add an exclude pattern to the exclude array of the TSConfig. |
| Extend from base TypescriptConfig instance. |
| Add an include pattern to the include array of the TSConfig. |
| Remove an exclude pattern from the exclude array of the TSConfig. |
| Remove an include pattern from the include array of the TSConfig. |
| 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
Add an exclude pattern to the exclude
array of the TSConfig.
pattern
Required
- Type: string
The pattern to add.
addExtends
public addExtends(value: TypescriptConfig): void
Extend from base TypescriptConfig
instance.
value
Required
- Type: TypescriptConfig
Base TypescriptConfig
instance.
addInclude
public addInclude(pattern: string): void
Add an include pattern to the include
array of the TSConfig.
pattern
Required
- Type: string
The pattern to add.
removeExclude
public removeExclude(pattern: string): void
Remove an exclude pattern from the exclude
array of the TSConfig.
pattern
Required
- Type: string
The pattern to remove.
removeInclude
public removeInclude(pattern: string): void
Remove an include pattern from the include
array of the TSConfig.
pattern
Required
- Type: string
The pattern to remove.
resolveExtendsPath
public resolveExtendsPath(configPath: string): string
Resolve valid TypeScript extends paths relative to this config.
configPath
Required
- Type: string
Path to resolve against.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { javascript } from 'projen'
javascript.TypescriptConfig.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| string[] | No description. |
| string[] | Array of base tsconfig.json paths. Any absolute paths are resolved relative to this instance, while any relative paths are used as is. |
| projen.JsonFile | No description. |
| string | No description. |
| string[] | No description. |
|
| No description. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
exclude
Required
public readonly exclude: string[];
- Type: string[]
extends
Required
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.
file
Required
public readonly file: JsonFile;
- Type: projen.JsonFile
fileName
Required
public readonly fileName: string;
- Type: string
include
Required
public readonly include: string[];
- Type: string[]
compilerOptions
Optional
public readonly compilerOptions: TypeScriptCompilerOptions;
UpgradeDependencies
Upgrade node project dependencies.
Initializers
import { javascript } from 'projen'
new javascript.UpgradeDependencies(project: NodeProject, options?: UpgradeDependenciesOptions)
Name | Type | Description |
---|---|---|
|
| No description. |
|
| No description. |
project
Required
- Type: NodeProject
options
Optional
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| 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.
steps
Required
- Type: ...projen.github.workflows.JobStep[]
workflow steps.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { javascript } from 'projen'
javascript.UpgradeDependencies.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| projen.Task | A task run after the upgrade task. |
| projen.Task | The upgrade task. |
| projen.github.GithubWorkflow[] | The workflows that execute the upgrades. |
| projen.github.workflows.ContainerOptions | Container definitions for the upgrade workflow. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
postUpgradeTask
Required
public readonly postUpgradeTask: Task;
- Type: projen.Task
A task run after the upgrade task.
upgradeTask
Required
public readonly upgradeTask: Task;
- Type: projen.Task
The upgrade task.
workflows
Required
public readonly workflows: GithubWorkflow[];
- Type: projen.github.GithubWorkflow[]
The workflows that execute the upgrades.
One workflow per branch.
containerOptions
Optional
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)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
| string | No description. |
|
| No description. |
project
Required
- Type: projen.Project
version
Required
- Type: string
options
Optional
- Type: YarnrcOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
isConstruct
import { 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.
x
Required
- Type: any
Any object.
isComponent
import { javascript } from 'projen'
javascript.Yarnrc.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
Structs
AddBundleOptions
Options for addBundle()
.
Initializer
import { javascript } from 'projen'
const addBundleOptions: javascript.AddBundleOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string[] | You can mark a file or a package as external to exclude it from your build. |
| boolean | Include a source map in the bundle. |
| boolean | In addition to the bundle:xyz task, creates bundle:xyz:watch task which will invoke the same esbuild command with the --watch flag. |
| string | esbuild platform. |
| string | esbuild target. |
| string | Use this to insert an arbitrary string at the beginning of generated JavaScript files. |
|
| The charset to use for esbuild's output. |
| {[ key: string ]: string} | Replace global identifiers with constant expressions. |
| {[ key: string ]: string | boolean} | Build arguments to pass into esbuild. |
| boolean | Mark the output file as executable. |
| string | Use this to insert an arbitrary string at the end of generated JavaScript files. |
| string | Output format for the generated JavaScript files. |
| string[] | This option allows you to automatically replace a global variable with an import from another file. |
| boolean | Whether to preserve the original name values even in minified code. |
| {[ key: string ]: string} | Map of file extensions (without dot) and loaders to use for this file type. |
|
| Log level for esbuild. |
| string[] | How to determine the entry point for modules. |
| boolean | This option tells esbuild to write out a JSON file relative to output directory with metadata about the build. |
| boolean | Whether to minify files when bundling. |
| string | Bundler output path relative to the asset's output directory. |
|
| Source map mode to be used when bundling. |
| boolean | Whether to include original source code in source maps when bundling. |
| string | The path of the tsconfig.json file to use for bundling. |
externals
Optional
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.
sourcemap
Optional
public readonly sourcemap: boolean;
- Type: boolean
- Default: false
Include a source map in the bundle.
watchTask
Optional
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.
platform
Required
public readonly platform: string;
- Type: string
esbuild platform.
Example
"node"
target
Required
public readonly target: string;
- Type: string
esbuild target.
Example
"node12"
banner
Optional
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:
charset
Optional
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
.
define
Optional
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') }
.
esbuildArgs
Optional
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",
},
});
executable
Optional
public readonly executable: boolean;
- Type: boolean
- Default: false
Mark the output file as executable.
footer
Optional
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
format
Optional
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"
ifplatform
is"node"
"iife"
ifplatform
is"browser"
"esm"
ifplatform
is"neutral"
Note: If making a bundle to run under node with ESM, set format
to "esm"
instead of setting platform
to "neutral"
.
inject
Optional
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.
keepNames
Optional
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.
loaders
Optional
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
logLevel
Optional
public readonly logLevel: BundleLogLevel;
- Type: BundleLogLevel
- Default: LogLevel.WARNING
Log level for esbuild.
This is also propagated to the package manager and applies to its specific install command.
mainFields
Optional
public readonly mainFields: string[];
- Type: string[]
- Default: []
How to determine the entry point for modules.
Try ['module', 'main'] to default to ES module versions.
metafile
Optional
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.
minify
Optional
public readonly minify: boolean;
- Type: boolean
- Default: false
Whether to minify files when bundling.
outfile
Optional
public readonly outfile: string;
- Type: string
- Default: "index.js"
Bundler output path relative to the asset's output directory.
sourceMapMode
Optional
public readonly sourceMapMode: SourceMapMode;
- Type: SourceMapMode
- Default: SourceMapMode.DEFAULT
Source map mode to be used when bundling.
sourcesContent
Optional
public readonly sourcesContent: boolean;
- Type: boolean
- Default: true
Whether to include original source code in source maps when bundling.
tsconfigPath
Optional
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
Name | Type | Description |
---|---|---|
| string | Name of the buildfile (e.g. "build" becomes "build.yml"). |
| projen.github.workflows.JobPermissions | 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 } . |
| projen.github.workflows.JobStep[] | Steps to execute before the build. |
| projen.github.workflows.Triggers | Build workflow triggers. |
| boolean | Automatically update files modified during builds to pull-request branches. |
name
Optional
public readonly name: string;
- Type: string
- Default: "build"
Name of the buildfile (e.g. "build" becomes "build.yml").
permissions
Optional
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 }
.
preBuildSteps
Optional
public readonly preBuildSteps: JobStep[];
- Type: projen.github.workflows.JobStep[]
- Default: []
Steps to execute before the build.
workflowTriggers
Optional
public readonly workflowTriggers: Triggers;
- Type: projen.github.workflows.Triggers
- Default: "{ pullRequest: {}, workflowDispatch: {} }"
Build workflow triggers.
mutableBuild
Optional
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
Name | Type | Description |
---|---|---|
| projen.Task | The task that produces this bundle. |
| string | Base directory containing the output file (relative to project root). |
| string | Location of the output file (relative to project root). |
| projen.Task | The "watch" task for this bundle. |
bundleTask
Required
public readonly bundleTask: Task;
- Type: projen.Task
The task that produces this bundle.
outdir
Required
public readonly outdir: string;
- Type: string
Base directory containing the output file (relative to project root).
outfile
Required
public readonly outfile: string;
- Type: string
Location of the output file (relative to project root).
watchTask
Optional
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
Name | Type | Description |
---|---|---|
| boolean | Install the bundle command as a pre-compile phase. |
| string | Output directory for all bundles. |
| string | The semantic version requirement for esbuild . |
| {[ key: string ]: string} | Map of file extensions (without dot) and loaders to use for this file type. |
|
| Choose which phase (if any) to add the bundle command to. |
addToPreCompile
Optional
addToPreCompile
- Deprecated: Use
runBundleTask
instead.
public readonly addToPreCompile: boolean;
- Type: boolean
- Default: true
Install the bundle
command as a pre-compile phase.
assetsDir
Optional
public readonly assetsDir: string;
- Type: string
- Default: "assets"
Output directory for all bundles.
esbuildVersion
Optional
public readonly esbuildVersion: string;
- Type: string
- Default: no specific version (implies latest)
The semantic version requirement for esbuild
.
loaders
Optional
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
runBundleTask
Optional
public readonly runBundleTask: RunBundleTask;
- Type: RunBundleTask
- Default: RunBundleTask.PRE_COMPILE
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
Name | Type | Description |
---|---|---|
| string[] | You can mark a file or a package as external to exclude it from your build. |
| boolean | Include a source map in the bundle. |
| boolean | In addition to the bundle:xyz task, creates bundle:xyz:watch task which will invoke the same esbuild command with the --watch flag. |
externals
Optional
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.
sourcemap
Optional
public readonly sourcemap: boolean;
- Type: boolean
- Default: false
Include a source map in the bundle.
watchTask
Optional
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
Name | Type | Description |
---|---|---|
| string | GitHub secret which contains the AWS access key ID to use when publishing packages to AWS CodeArtifact. |
|
| Provider to use for authorizing requests to AWS CodeArtifact. |
| string | 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). |
| string | GitHub secret which contains the AWS secret access key to use when publishing packages to AWS CodeArtifact. |
accessKeyIdSecret
Optional
public readonly accessKeyIdSecret: string;
- Type: string
- Default: When the
authProvider
value is set toCodeArtifactAuthProvider.ACCESS_AND_SECRET_KEY_PAIR
, the default is "AWS_ACCESS_KEY_ID". ForCodeArtifactAuthProvider.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).
authProvider
Optional
public readonly authProvider: CodeArtifactAuthProvider;
- Type: CodeArtifactAuthProvider
- Default: CodeArtifactAuthProvider.ACCESS_AND_SECRET_KEY_PAIR
Provider to use for authorizing requests to AWS CodeArtifact.
roleToAssume
Optional
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.
secretAccessKeySecret
Optional
public readonly secretAccessKeySecret: string;
- Type: string
- Default: When the
authProvider
value is set toCodeArtifactAuthProvider.ACCESS_AND_SECRET_KEY_PAIR
, the default is "AWS_SECRET_ACCESS_KEY". ForCodeArtifactAuthProvider.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
Name | Type | Description |
---|---|---|
| number | No description. |
| number | No description. |
| number | No description. |
| number | No description. |
branches
Optional
public readonly branches: number;
- Type: number
functions
Optional
public readonly functions: number;
- Type: number
lines
Optional
public readonly lines: number;
- Type: number
statements
Optional
public readonly statements: number;
- Type: number
EslintCommandOptions
Initializer
import { javascript } from 'projen'
const eslintCommandOptions: javascript.EslintCommandOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string[] | Extra flag arguments to pass to eslint command. |
| boolean | Whether to fix eslint issues when running the eslint task. |
extraArgs
Optional
public readonly extraArgs: string[];
- Type: string[]
Extra flag arguments to pass to eslint command.
fix
Optional
public readonly fix: boolean;
- Type: boolean
- Default: true
Whether to fix eslint issues when running the eslint task.
EslintOptions
Initializer
import { javascript } from 'projen'
const eslintOptions: javascript.EslintOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string[] | Files or glob patterns or directories with source files to lint (e.g. [ "src" ]). |
| string[] | Enable import alias for module paths. |
| {[ key: string ]: string} | Enable import alias for module paths. |
|
| Options for eslint command executed by eslint task. |
| string[] | Files or glob patterns or directories with source files that include tests and build tools. |
| string[] | File types that should be linted (e.g. [ ".js", ".ts" ]). |
| string[] | List of file patterns that should not be linted, using the same syntax as .gitignore patterns. |
| boolean | Should we lint .projenrc.js. |
| string | Projenrc file to lint. |
| boolean | Enable prettier for code formatting. |
| projen.ICompareString | The extends array in eslint is order dependent. |
| boolean | Always try to resolve types under <root>@types directory even it doesn't contain any source code. |
| string | Path to tsconfig.json which should be used by eslint. |
| boolean | Write eslint configuration as YAML instead of JSON. |
dirs
Required
public readonly dirs: string[];
- Type: string[]
Files or glob patterns or directories with source files to lint (e.g. [ "src" ]).
aliasExtensions
Optional
public readonly aliasExtensions: string[];
- Type: string[]
- Default: undefined
Enable import alias for module paths.
aliasMap
Optional
public readonly aliasMap: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- Default: undefined
Enable import alias for module paths.
commandOptions
Optional
public readonly commandOptions: EslintCommandOptions;
- Type: EslintCommandOptions
Options for eslint command executed by eslint task.
devdirs
Optional
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
.
fileExtensions
Optional
public readonly fileExtensions: string[];
- Type: string[]
- Default: [".ts"]
File types that should be linted (e.g. [ ".js", ".ts" ]).
ignorePatterns
Optional
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.
lintProjenRc
Optional
lintProjenRc
- 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.
lintProjenRcFile
Optional
lintProjenRcFile
- Deprecated: provide as
devdirs
public readonly lintProjenRcFile: string;
- Type: string
- Default: "projenrc.js"
Projenrc file to lint.
Use empty string to disable.
prettier
Optional
public readonly prettier: boolean;
- Type: boolean
- Default: false
Enable prettier for code formatting.
sortExtends
Optional
public readonly sortExtends: ICompareString;
- Type: projen.ICompareString
- Default: Use known ESLint best practices to place "prettier" plugins at the end of the array
The extends array in eslint is order dependent.
This option allows to sort the extends array in any way seen fit.
tsAlwaysTryTypes
Optional
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.
tsconfigPath
Optional
public readonly tsconfigPath: string;
- Type: string
- Default: "./tsconfig.json"
Path to tsconfig.json
which should be used by eslint.
yaml
Optional
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
Name | Type | Description |
---|---|---|
| string[] | Files or file patterns on which to apply the override. |
| string[] | Pattern(s) to exclude from this override. |
| string[] | Config(s) to extend in this override. |
| string | The overridden parser. |
| string[] | plugins override. |
| {[ key: string ]: any} | The overridden rules. |
files
Required
public readonly files: string[];
- Type: string[]
Files or file patterns on which to apply the override.
excludedFiles
Optional
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.
extends
Optional
public readonly extends: string[];
- Type: string[]
Config(s) to extend in this override.
parser
Optional
public readonly parser: string;
- Type: string
The overridden parser.
plugins
Optional
public readonly plugins: string[];
- Type: string[]
plugins
override.
rules
Optional
public readonly rules: {[ key: string ]: any};
- Type: {[ key: string ]: any}
The overridden rules.
HasteConfig
Initializer
import { javascript } from 'projen'
const hasteConfig: javascript.HasteConfig = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | No description. |
| string | No description. |
| string | No description. |
| string[] | No description. |
| boolean | No description. |
computeSha1
Optional
public readonly computeSha1: boolean;
- Type: boolean
defaultPlatform
Optional
public readonly defaultPlatform: string;
- Type: string
hasteImplModulePath
Optional
public readonly hasteImplModulePath: string;
- Type: string
platforms
Optional
public readonly platforms: string[];
- Type: string[]
throwOnModuleCollision
Optional
public readonly throwOnModuleCollision: boolean;
- Type: boolean
JestConfigOptions
Initializer
import { javascript } from 'projen'
const jestConfigOptions: javascript.JestConfigOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| {[ key: string ]: any} | Escape hatch to allow any value. |
| boolean | This option tells Jest that all imported modules in your tests should be mocked automatically. |
| number | boolean | By default, Jest runs all tests and produces all errors into the console upon completion. |
| string | The directory where Jest should store its cached dependency information. |
| boolean | Automatically clear mock calls and instances before every test. |
| boolean | Indicates whether the coverage information should be collected while executing the test. |
| string[] | An array of glob patterns indicating a set of files for which coverage information should be collected. |
| string | The directory where Jest should output its coverage files. |
| string[] | An array of regexp pattern strings that are matched against all file paths before executing the test. |
| string | Indicates which provider should be used to instrument code for coverage. |
| string[] | A list of reporter names that Jest uses when writing coverage reports. |
|
| Specify the global coverage thresholds. |
| string | This option allows the use of a custom dependency extractor. |
| any | Allows for a label to be printed alongside a test while it is running. |
| boolean | Make calling deprecated APIs throw helpful error messages. |
| 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. |
| string[] | Test files are normally ignored from collecting code coverage. |
| any | A set of global variables that need to be available in all test environments. |
| string | This option allows the use of a custom global setup module which exports an async function that is triggered once before all test suites. |
| string | This option allows the use of a custom global teardown module which exports an async function that is triggered once after all test suites. |
|
| This will be used to configure the behavior of jest-haste-map, Jest's internal file crawler/cache system. |
| boolean | Insert Jest's globals (expect, test, describe, beforeEach etc.) into the global environment. If you set this to false, you should import from. |
| number | A 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. |
| string | number | Specifies the maximum number of workers the worker-pool will spawn for running tests. |
| string[] | An array of directory names to be searched recursively up from the requiring module's location. |
| string[] | An array of file extensions your modules use. |
| {[ 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. |
| 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. |
| 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. |
| boolean | Activates notifications for test results. |
| string | Specifies notification mode. |
| string | A preset that is used as a base for Jest's configuration. |
| string | Sets the path to the prettier node module used to update inline snapshots. |
| 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. |
|
| Use this configuration option to add custom reporters to Jest. |
| boolean | Automatically reset mock state before every test. |
| boolean | By default, each test file gets its own independent module registry. |
| string | This option allows the use of a custom resolver. |
| boolean | Automatically restore mock state before every test. |
| string | The root directory that Jest should scan for tests and modules within. |
| string[] | A list of paths to directories that Jest should use to search for files in. |
| string | This option allows you to use a custom runner instead of Jest's default test runner. |
| string[] | A list of paths to modules that run some code to configure or set up the testing environment. |
| string[] | A list of paths to modules that run some code to configure or set up the testing framework before each test file in the suite is executed. |
| number | The number of seconds after which a test is considered as slow and reported as such in the results. |
| string | The path to a module that can resolve test<->snapshot path. |
| string[] | A list of paths to snapshot serializer modules Jest should use for snapshot testing. |
| string | The test environment that will be used for testing. |
| any | Test environment options that will be passed to the testEnvironment. |
| number | The exit code Jest returns on test failure. |
| string[] | The glob patterns Jest uses to detect test files. |
| string[] | An array of regexp pattern strings that are matched against all test paths before executing the test. |
| string | string[] | The pattern or patterns Jest uses to detect test files. |
| string | This option allows the use of a custom results processor. |
| string | This option allows the use of a custom test runner. |
| string | This option allows you to use a custom sequencer instead of Jest's default. |
| number | Default timeout of a test in milliseconds. |
| string | This option sets the URL for the jsdom environment. |
| string | Setting this value to legacy or fake allows the use of fake timers for functions such as setTimeout. |
|
| A map from regular expressions to paths to transformers. |
| string[] | An array of regexp pattern strings that are matched against all source file paths before transformation. |
| string[] | An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them. |
| boolean | Indicates whether each individual test should be reported during the run. |
| boolean | Whether to use watchman for file crawling. |
| string[] | An array of RegExp patterns that are matched against all source file paths before re-running tests in watch mode. |
|
| No description. |
additionalOptions
Optional
public readonly additionalOptions: {[ key: string ]: any};
- Type: {[ key: string ]: any}
Escape hatch to allow any value.
automock
Optional
public readonly automock: boolean;
- Type: boolean
- Default: false
This option tells Jest that all imported modules in your tests should be mocked automatically.
All modules used in your tests will have a replacement implementation, keeping the API surface
bail
Optional
public readonly bail: number | boolean;
- Type: number | boolean
- Default: 0
By default, Jest runs all tests and produces all errors into the console upon completion.
The bail config option can be used here to have Jest stop running tests after n failures. Setting bail to true is the same as setting bail to 1.
cacheDirectory
Optional
public readonly cacheDirectory: string;
- Type: string
- Default: "/tmp/
"
The directory where Jest should store its cached dependency information.
clearMocks
Optional
public readonly clearMocks: boolean;
- Type: boolean
- Default: true
Automatically clear mock calls and instances before every test.
Equivalent to calling jest.clearAllMocks() before each test. This does not remove any mock implementation that may have been provided
collectCoverage
Optional
public readonly collectCoverage: boolean;
- Type: boolean
- Default: true
Indicates whether the coverage information should be collected while executing the test.
Because this retrofits all executed files with coverage collection statements, it may significantly slow down your tests
collectCoverageFrom
Optional
public readonly collectCoverageFrom: string[];
- Type: string[]
- Default: undefined
An array of glob patterns indicating a set of files for which coverage information should be collected.
coverageDirectory
Optional
public readonly coverageDirectory: string;
- Type: string
- Default: "coverage"
The directory where Jest should output its coverage files.
coveragePathIgnorePatterns
Optional
public readonly coveragePathIgnorePatterns: string[];
- Type: string[]
- Default: "/node_modules/"
An array of regexp pattern strings that are matched against all file paths before executing the test.
If the file path matches any of the patterns, coverage information will be skipped
coverageProvider
Optional
public readonly coverageProvider: string;
- Type: string
- Default: "v8"
Indicates which provider should be used to instrument code for coverage.
Allowed values are v8 (default) or babel
coverageReporters
Optional
public readonly coverageReporters: string[];
- Type: string[]
- Default: ["json", "lcov", "text", "clover", "cobertura"]
A list of reporter names that Jest uses when writing coverage reports.
Any istanbul reporter can be used
coverageThreshold
Optional
public readonly coverageThreshold: CoverageThreshold;
- Type: CoverageThreshold
- Default: undefined
Specify the global coverage thresholds.
This will be used to configure minimum threshold enforcement for coverage results. Thresholds can be specified as global, as a glob, and as a directory or file path. If thresholds aren't met, jest will fail.
dependencyExtractor
Optional
public readonly dependencyExtractor: string;
- Type: string
- Default: undefined
This option allows the use of a custom dependency extractor.
It must be a node module that exports an object with an extract function
displayName
Optional
public readonly displayName: any;
- Type: any
- Default: undefined
Allows for a label to be printed alongside a test while it is running.
errorOnDeprecated
Optional
public readonly errorOnDeprecated: boolean;
- Type: boolean
- Default: false
Make calling deprecated APIs throw helpful error messages.
Useful for easing the upgrade process.
extraGlobals
Optional
public readonly extraGlobals: string[];
- Type: string[]
- Default: undefined
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
Optional
public readonly forceCoverageMatch: string[];
- Type: string[]
- Default: ['']
Test files are normally ignored from collecting code coverage.
With this option, you can overwrite this behavior and include otherwise ignored files in code coverage.
globals
Optional
public readonly globals: any;
- Type: any
- Default: {}
A set of global variables that need to be available in all test environments.
globalSetup
Optional
public readonly globalSetup: string;
- Type: string
- Default: undefined
This option allows the use of a custom global setup module which exports an async function that is triggered once before all test suites.
This function gets Jest's globalConfig object as a parameter.
globalTeardown
Optional
public readonly globalTeardown: string;
- Type: string
- Default: undefined
This option allows the use of a custom global teardown module which exports an async function that is triggered once after all test suites.
This function gets Jest's globalConfig object as a parameter.
haste
Optional
public readonly haste: HasteConfig;
- Type: HasteConfig
- Default: {}
This will be used to configure the behavior of jest-haste-map, Jest's internal file crawler/cache system.
injectGlobals
Optional
public readonly injectGlobals: boolean;
- Type: boolean
- Default: true
Insert Jest's globals (expect, test, describe, beforeEach etc.) into the global environment. If you set this to false, you should import from.
maxConcurrency
Optional
public readonly maxConcurrency: number;
- Type: number
- Default: 5
A 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
Optional
public readonly maxWorkers: string | number;
- Type: string | number
- Default: the number of the cores available on your machine minus one for the main thread
Specifies the maximum number of workers the worker-pool will spawn for running tests.
In single run mode, this defaults to the number of the cores available on your machine minus one for the main thread In watch mode, this defaults to half of the available cores on your machine. For environments with variable CPUs available, you can use percentage based configuration: "maxWorkers": "50%"
moduleDirectories
Optional
public readonly moduleDirectories: string[];
- Type: string[]
- Default: ["node_modules"]
An array of directory names to be searched recursively up from the requiring module's location.
Setting this option will override the default, if you wish to still search node_modules for packages include it along with any other options: ["node_modules", "bower_components"]
moduleFileExtensions
Optional
public readonly moduleFileExtensions: string[];
- Type: string[]
- Default: ["js", "json", "jsx", "ts", "tsx", "node"]
An array of file extensions your modules use.
If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order.
moduleNameMapper
Optional
public readonly moduleNameMapper: {[ key: string ]: string | string[]};
- Type: {[ key: string ]: string | string[]}
- Default: null
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
Optional
public readonly modulePathIgnorePatterns: string[];
- Type: string[]
- Default: []
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.
If a given module's path matches any of the patterns, it will not be require()-able in the test environment.
modulePaths
Optional
public readonly modulePaths: string[];
- Type: string[]
- Default: []
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.
Use the
notify
Optional
public readonly notify: boolean;
- Type: boolean
- Default: false
Activates notifications for test results.
notifyMode
Optional
public readonly notifyMode: string;
- Type: string
- Default: failure-change
Specifies notification mode.
Requires notify: true
preset
Optional
public readonly preset: string;
- Type: string
- Default: undefined
A preset that is used as a base for Jest's configuration.
A preset should point to an npm module that has a jest-preset.json or jest-preset.js file at the root.
prettierPath
Optional
public readonly prettierPath: string;
- Type: string
- Default: "prettier"
Sets the path to the prettier node module used to update inline snapshots.
projects
Optional
public readonly projects: string | {[ key: string ]: any}[];
- Type: string | {[ key: string ]: any}[]
- Default: undefined
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.
This is great for monorepos or when working on multiple projects at the same time.
reporters
Optional
public readonly reporters: JestReporter[];
- Type: JestReporter[]
- Default: undefined
Use this configuration option to add custom reporters to Jest.
A custom reporter is a class that implements onRunStart, onTestStart, onTestResult, onRunComplete methods that will be called when any of those events occurs.
resetMocks
Optional
public readonly resetMocks: boolean;
- Type: boolean
- Default: false
Automatically reset mock state before every test.
Equivalent to calling jest.resetAllMocks() before each test. This will lead to any mocks having their fake implementations removed but does not restore their initial implementation.
resetModules
Optional
public readonly resetModules: boolean;
- Type: boolean
- Default: false
By default, each test file gets its own independent module registry.
Enabling resetModules goes a step further and resets the module registry before running each individual test.
resolver
Optional
public readonly resolver: string;
- Type: string
- Default: undefined
This option allows the use of a custom resolver.
https://jestjs.io/docs/en/configuration#resolver-string
restoreMocks
Optional
public readonly restoreMocks: boolean;
- Type: boolean
- Default: false
Automatically restore mock state before every test.
Equivalent to calling jest.restoreAllMocks() before each test. This will lead to any mocks having their fake implementations removed and restores their initial implementation.
rootDir
Optional
public readonly rootDir: string;
- Type: string
- Default: directory of the package.json
The root directory that Jest should scan for tests and modules within.
If you put your Jest config inside your package.json and want the root directory to be the root of your repo, the value for this config param will default to the directory of the package.json.
roots
Optional
public readonly roots: string[];
- Type: string[]
- Default: ["
"]
A list of paths to directories that Jest should use to search for files in.
runner
Optional
public readonly runner: string;
- Type: string
- Default: "jest-runner"
This option allows you to use a custom runner instead of Jest's default test runner.
setupFiles
Optional
public readonly setupFiles: string[];
- Type: string[]
- Default: []
A list of paths to modules that run some code to configure or set up the testing environment.
Each setupFile will be run once per test file. Since every test runs in its own environment, these scripts will be executed in the testing environment immediately before executing the test code itself.
setupFilesAfterEnv
Optional
public readonly setupFilesAfterEnv: string[];
- Type: string[]
- Default: []
A list of paths to modules that run some code to configure or set up the testing framework before each test file in the suite is executed.
Since setupFiles executes before the test framework is installed in the environment, this script file presents you the opportunity of running some code immediately after the test framework has been installed in the environment.
slowTestThreshold
Optional
public readonly slowTestThreshold: number;
- Type: number
- Default: 5
The number of seconds after which a test is considered as slow and reported as such in the results.
snapshotResolver
Optional
public readonly snapshotResolver: string;
- Type: string
- Default: undefined
The path to a module that can resolve test<->snapshot path.
This config option lets you customize where Jest stores snapshot files on disk.
snapshotSerializers
Optional
public readonly snapshotSerializers: string[];
- Type: string[]
- Default: = []
A list of paths to snapshot serializer modules Jest should use for snapshot testing.
testEnvironment
Optional
public readonly testEnvironment: string;
- Type: string
- Default: "jsdom"
The test environment that will be used for testing.
The default environment in Jest is a browser-like environment through jsdom. If you are building a node service, you can use the node option to use a node-like environment instead.
testEnvironmentOptions
Optional
public readonly testEnvironmentOptions: any;
- Type: any
- Default: {}
Test environment options that will be passed to the testEnvironment.
The relevant options depend on the environment.
testFailureExitCode
Optional
public readonly testFailureExitCode: number;
- Type: number
- Default: 1
The exit code Jest returns on test failure.
testMatch
Optional
public readonly testMatch: string[];
- Type: string[]
- Default: ['/tests//.[jt]s?(x)', '**/(*.)@(spec|test).[tj]s?(x)']
The glob patterns Jest uses to detect test files.
By default it looks for .js, .jsx, .ts and .tsx files inside of tests folders, as well as any files with a suffix of .test or .spec (e.g. Component.test.js or Component.spec.js). It will also find files called test.js or spec.js.
testPathIgnorePatterns
Optional
public readonly testPathIgnorePatterns: string[];
- Type: string[]
- Default: ["/node_modules/"]
An array of regexp pattern strings that are matched against all test paths before executing the test.
If the test path matches any of the patterns, it will be skipped.
testRegex
Optional
public readonly testRegex: string | string[];
- Type: string | string[]
- Default: (/tests/.*|(\.|/)(test|spec))\.[jt]sx?$
The pattern or patterns Jest uses to detect test files.
By default it looks for .js, .jsx, .ts and .tsx files inside of tests folders, as well as any files with a suffix of .test or .spec (e.g. Component.test.js or Component.spec.js). It will also find files called test.js or spec.js.
testResultsProcessor
Optional
public readonly testResultsProcessor: string;
- Type: string
- Default: undefined
This option allows the use of a custom results processor.
testRunner
Optional
public readonly testRunner: string;
- Type: string
- Default: "jasmine2"
This option allows the use of a custom test runner.
The default is jasmine2. A custom test runner can be provided by specifying a path to a test runner implementation.
testSequencer
Optional
public readonly testSequencer: string;
- Type: string
- Default: "@jest/test-sequencer"
This option allows you to use a custom sequencer instead of Jest's default.
Sort may optionally return a Promise.
testTimeout
Optional
public readonly testTimeout: number;
- Type: number
- Default: 5000
Default timeout of a test in milliseconds.
testURL
Optional
public readonly testURL: string;
- Type: string
- Default: "http://localhost"
This option sets the URL for the jsdom environment.
It is reflected in properties such as location.href.
timers
Optional
public readonly timers: string;
- Type: string
- Default: "real"
Setting this value to legacy or fake allows the use of fake timers for functions such as setTimeout.
Fake timers are useful when a piece of code sets a long timeout that we don't want to wait for in a test.
transform
Optional
public readonly transform: {[ key: string ]: Transform};
- Type: {[ key: string ]: Transform}
- Default: {"\.[jt]sx?$": "babel-jest"}
A map from regular expressions to paths to transformers.
A transformer is a module that provides a synchronous function for transforming source files.
transformIgnorePatterns
Optional
public readonly transformIgnorePatterns: string[];
- Type: string[]
- Default: ["/node_modules/", "\.pnp\.[^\/]+$"]
An array of regexp pattern strings that are matched against all source file paths before transformation.
If the test path matches any of the patterns, it will not be transformed.
unmockedModulePathPatterns
Optional
public readonly unmockedModulePathPatterns: string[];
- Type: string[]
- Default: []
An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them.
If a module's path matches any of the patterns in this list, it will not be automatically mocked by the module loader.
verbose
Optional
public readonly verbose: boolean;
- Type: boolean
- Default: false
Indicates whether each individual test should be reported during the run.
All errors will also still be shown on the bottom after execution. Note that if there is only one test file being run it will default to true.
watchman
Optional
public readonly watchman: boolean;
- Type: boolean
- Default: true
Whether to use watchman for file crawling.
watchPathIgnorePatterns
Optional
public readonly watchPathIgnorePatterns: string[];
- Type: string[]
- Default: []
An array of RegExp patterns that are matched against all source file paths before re-running tests in watch mode.
If the file path matches any of the patterns, when it is updated, it will not trigger a re-run of tests.
watchPlugins
Optional
public readonly watchPlugins: WatchPlugin[];
- Type: WatchPlugin[]
- Default:
JestDiscoverTestMatchPatternsForDirsOptions
Options for discoverTestMatchPatternsForDirs.
Initializer
import { javascript } from 'projen'
const jestDiscoverTestMatchPatternsForDirsOptions: javascript.JestDiscoverTestMatchPatternsForDirsOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | The file extension pattern to use. |
fileExtensionPattern
Optional
public readonly fileExtensionPattern: string;
- Type: string
The file extension pattern to use.
Defaults to "[jt]s?(x)".
JestOptions
Initializer
import { javascript } from 'projen'
const jestOptions: javascript.JestOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | Path to JSON config file for Jest. |
| boolean | Collect coverage. |
| boolean | Include the text coverage reporter, which means that coverage summary is printed at the end of the jest execution. |
| string[] | Additional options to pass to the Jest CLI invocation. |
| string[] | Defines testPathIgnorePatterns and coveragePathIgnorePatterns . |
|
| Jest configuration. |
| string | The version of jest to use. |
| boolean | Result processing with jest-junit. |
| boolean | Pass with no tests. |
| boolean | Preserve the default Jest reporter when additional reporters are added. |
|
| Whether to update snapshots in task "test" (which is executed in task "build" and build workflows), or create a separate task "test:update" for updating snapshots. |
configFilePath
Optional
public readonly configFilePath: string;
- Type: string
- Default: No separate config file, jest settings are stored in package.json
Path to JSON config file for Jest.
coverage
Optional
coverage
- Deprecated: use jestConfig.collectCoverage
public readonly coverage: boolean;
- Type: boolean
- Default: true
Collect coverage.
Deprecated
coverageText
Optional
public readonly coverageText: boolean;
- Type: boolean
- Default: true
Include the text
coverage reporter, which means that coverage summary is printed at the end of the jest execution.
extraCliOptions
Optional
public readonly extraCliOptions: string[];
- Type: string[]
- Default: no extra options
Additional options to pass to the Jest CLI invocation.
ignorePatterns
Optional
ignorePatterns
- Deprecated: use jestConfig.coveragePathIgnorePatterns or jestConfig.testPathIgnorePatterns respectively
public readonly ignorePatterns: string[];
- Type: string[]
- Default: ["/node_modules/"]
Defines testPathIgnorePatterns
and coveragePathIgnorePatterns
.
jestConfig
Optional
public readonly jestConfig: JestConfigOptions;
- Type: JestConfigOptions
- Default: default jest configuration
Jest configuration.
jestVersion
Optional
public readonly jestVersion: string;
- Type: string
- Default: installs the latest jest version
The version of jest to use.
Note that same version is used as version of @types/jest
and ts-jest
(if Typescript in use), so given version should work also for those.
junitReporting
Optional
public readonly junitReporting: boolean;
- Type: boolean
- Default: true
Result processing with jest-junit.
Output directory is test-reports/
.
passWithNoTests
Optional
public readonly passWithNoTests: boolean;
- Type: boolean
- Default: true
Pass with no tests.
preserveDefaultReporters
Optional
public readonly preserveDefaultReporters: boolean;
- Type: boolean
- Default: true
Preserve the default Jest reporter when additional reporters are added.
updateSnapshot
Optional
public readonly updateSnapshot: UpdateSnapshot;
- Type: UpdateSnapshot
- Default: ALWAYS
Whether to update snapshots in task "test" (which is executed in task "build" and build workflows), or create a separate task "test:update" for updating snapshots.
LicenseCheckerOptions
Options to configure the license checker.
Initializer
import { javascript } from 'projen'
const licenseCheckerOptions: javascript.LicenseCheckerOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string[] | List of SPDX license identifiers that are allowed to be used. |
| string[] | List of SPDX license identifiers that are prohibited to be used. |
| boolean | Check development dependencies. |
| boolean | Check production dependencies. |
| string | The name of the task that is added to check licenses. |
allow
Optional
public readonly allow: string[];
- Type: string[]
- Default: no licenses are allowed
List of SPDX license identifiers that are allowed to be used.
For the license check to pass, all detected licenses MUST be in this list.
Only one of allowedLicenses
and prohibitedLicenses
can be provided and must not be empty.
deny
Optional
public readonly deny: string[];
- Type: string[]
- Default: no licenses are prohibited
List of SPDX license identifiers that are prohibited to be used.
For the license check to pass, no detected licenses can be in this list.
Only one of allowedLicenses
and prohibitedLicenses
can be provided and must not be empty.
development
Optional
public readonly development: boolean;
- Type: boolean
- Default: false
Check development dependencies.
production
Optional
public readonly production: boolean;
- Type: boolean
- Default: true
Check production dependencies.
taskName
Optional
public readonly taskName: string;
- Type: string
- Default: "check-licenses"
The name of the task that is added to check licenses.
NodePackageOptions
Initializer
import { javascript } from 'projen'
const nodePackageOptions: javascript.NodePackageOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | Allow the project to include peerDependencies and bundledDependencies . |
| string | Author's e-mail. |
| string | Author's name. |
| boolean | Is the author an organization. |
| string | Author's URL / Website. |
| boolean | Automatically add all executables under the bin directory to your package.json file under the bin section. |
| {[ key: string ]: string} | Binary programs vended with your module. |
| string | The email address to which issues should be reported. |
| string | The url to your project's issue tracker. |
| string[] | List of dependencies to bundle into this module. |
|
| Options for npm packages using AWS CodeArtifact. |
| string[] | Runtime dependencies of this module. |
| string | The description is just a string that helps people understand the purpose of the package. |
| string[] | Build dependencies for this module. |
| string | Module entrypoint (main in package.json ). |
| string | Package's Homepage / Website. |
| string[] | Keywords to include in package.json . |
| string | License's SPDX identifier. |
| boolean | Indicates if a license should be added. |
| string | The maximum node version supported by this package. Most projects should not use this option. |
| string | The minimum node version required by this package to function. Most projects should not use this option. |
|
| Access level of the npm package. |
| boolean | Should provenance statements be generated when the package is published. |
| string | The host name of the npm registry to publish to. |
| string | The base URL of the npm package registry. |
| string | GitHub secret which contains the NPM token to use when publishing packages. |
|
| The Node Package Manager used to execute scripts. |
| string | The "name" in package.json. |
|
| Options for peerDeps . |
| string[] | Peer dependencies for this module. |
| string | The version of PNPM to use if using PNPM as a package manager. |
| string | The repository is the location where the actual code for your package lives. |
| string | If the package.json for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives. |
|
| Options for privately hosted scoped packages. |
| {[ key: string ]: string} | npm scripts to include. |
| string | Package's Stability. |
|
| Options for Yarn Berry. |
allowLibraryDependencies
Optional
public readonly allowLibraryDependencies: boolean;
- Type: boolean
- Default: true
Allow the project to include peerDependencies
and bundledDependencies
.
This is normally only allowed for libraries. For apps, there's no meaning for specifying these.
authorEmail
Optional
public readonly authorEmail: string;
- Type: string
Author's e-mail.
authorName
Optional
public readonly authorName: string;
- Type: string
Author's name.
authorOrganization
Optional
public readonly authorOrganization: boolean;
- Type: boolean
Is the author an organization.
authorUrl
Optional
public readonly authorUrl: string;
- Type: string
Author's URL / Website.
autoDetectBin
Optional
public readonly autoDetectBin: boolean;
- Type: boolean
- Default: true
Automatically add all executables under the bin
directory to your package.json
file under the bin
section.
bin
Optional
public readonly bin: {[ key: string ]: string};
- Type: {[ key: string ]: string}
Binary programs vended with your module.
You can use this option to add/customize how binaries are represented in
your package.json
, but unless autoDetectBin
is false
, every
executable file under bin
will automatically be added to this section.
bugsEmail
Optional
public readonly bugsEmail: string;
- Type: string
The email address to which issues should be reported.
bugsUrl
Optional
public readonly bugsUrl: string;
- Type: string
The url to your project's issue tracker.
bundledDeps
Optional
public readonly bundledDeps: string[];
- Type: string[]
List of dependencies to bundle into this module.
These modules will be
added both to the dependencies
section and bundledDependencies
section of
your package.json
.
The recommendation is to only specify the module name here (e.g.
express
). This will behave similar to yarn add
or npm install
in the
sense that it will add the module as a dependency to your package.json
file with the latest version (^
). You can specify semver requirements in
the same syntax passed to npm i
or yarn add
(e.g. express@^2
) and
this will be what you package.json
will eventually include.
codeArtifactOptions
Optional
public readonly codeArtifactOptions: CodeArtifactOptions;
- Type: CodeArtifactOptions
- Default: undefined
Options for npm packages using AWS CodeArtifact.
This is required if publishing packages to, or installing scoped packages from AWS CodeArtifact
deps
Optional
public readonly deps: string[];
- Type: string[]
- Default: []
Runtime dependencies of this module.
The recommendation is to only specify the module name here (e.g.
express
). This will behave similar to yarn add
or npm install
in the
sense that it will add the module as a dependency to your package.json
file with the latest version (^
). You can specify semver requirements in
the same syntax passed to npm i
or yarn add
(e.g. express@^2
) and
this will be what you package.json
will eventually include.
Example
[ 'express', 'lodash', 'foo@^2' ]
description
Optional
public readonly description: string;
- Type: string
The description is just a string that helps people understand the purpose of the package.
It can be used when searching for packages in a package manager as well. See https://classic.yarnpkg.com/en/docs/package-json/#toc-description
devDeps
Optional
public readonly devDeps: string[];
- Type: string[]
- Default: []
Build dependencies for this module.
These dependencies will only be available in your build environment but will not be fetched when this module is consumed.
The recommendation is to only specify the module name here (e.g.
express
). This will behave similar to yarn add
or npm install
in the
sense that it will add the module as a dependency to your package.json
file with the latest version (^
). You can specify semver requirements in
the same syntax passed to npm i
or yarn add
(e.g. express@^2
) and
this will be what you package.json
will eventually include.
Example
[ 'typescript', '@types/express' ]
entrypoint
Optional
public readonly entrypoint: string;
- Type: string
- Default: "lib/index.js"
Module entrypoint (main
in package.json
).
Set to an empty string to not include main
in your package.json
homepage
Optional
public readonly homepage: string;
- Type: string
Package's Homepage / Website.
keywords
Optional
public readonly keywords: string[];
- Type: string[]
Keywords to include in package.json
.
license
Optional
public readonly license: string;
- Type: string
- Default: "Apache-2.0"
License's SPDX identifier.
See https://github.com/projen/projen/tree/main/license-text for a list of supported licenses.
Use the licensed
option if you want to no license to be specified.
licensed
Optional
public readonly licensed: boolean;
- Type: boolean
- Default: true
Indicates if a license should be added.
maxNodeVersion
Optional
public readonly maxNodeVersion: string;
- Type: string
- Default: no maximum version is enforced
The maximum node version supported by this package. Most projects should not use this option.
The value indicates that the package is incompatible with any newer versions of node. This requirement is enforced via the engines field.
You will normally not need to set this option. Consider this option only if your package is known to not function with newer versions of node.
minNodeVersion
Optional
public readonly minNodeVersion: string;
- Type: string
- Default: no minimum version is enforced
The minimum node version required by this package to function. Most projects should not use this option.
The value indicates that the package is incompatible with any older versions of node. This requirement is enforced via the engines field.
You will normally not need to set this option, even if your package is incompatible with EOL versions of node. Consider this option only if your package depends on a specific feature, that is not available in other LTS versions. Setting this option has very high impact on the consumers of your package, as package managers will actively prevent usage with node versions you have marked as incompatible.
To change the node version of your CI/CD workflows, use workflowNodeVersion
.
npmAccess
Optional
public readonly npmAccess: NpmAccess;
- Type: NpmAccess
- Default: for scoped packages (e.g.
foo@bar
), the default isNpmAccess.RESTRICTED
, for non-scoped packages, the default isNpmAccess.PUBLIC
.
Access level of the npm package.
npmProvenance
Optional
public readonly npmProvenance: boolean;
- Type: boolean
- Default: true for public packages, false otherwise
Should provenance statements be generated when the package is published.
A supported package manager is required to publish a package with npm provenance statements and you will need to use a supported CI/CD provider.
Note that the projen Release
and Publisher
components are using publib
to publish packages,
which is using npm internally and supports provenance statements independently of the package manager used.
npmRegistry
Optional
npmRegistry
- Deprecated: use
npmRegistryUrl
instead
public readonly npmRegistry: string;
- Type: string
The host name of the npm registry to publish to.
Cannot be set together with npmRegistryUrl
.
npmRegistryUrl
Optional
public readonly npmRegistryUrl: string;
- Type: string
- Default: "https://registry.npmjs.org"
The base URL of the npm package registry.
Must be a URL (e.g. start with "https://" or "http://")
npmTokenSecret
Optional
public readonly npmTokenSecret: string;
- Type: string
- Default: "NPM_TOKEN"
GitHub secret which contains the NPM token to use when publishing packages.
packageManager
Optional
public readonly packageManager: NodePackageManager;
- Type: NodePackageManager
- Default: NodePackageManager.YARN_CLASSIC
The Node Package Manager used to execute scripts.
packageName
Optional
public readonly packageName: string;
- Type: string
- Default: defaults to project name
The "name" in package.json.
peerDependencyOptions
Optional
public readonly peerDependencyOptions: PeerDependencyOptions;
- Type: PeerDependencyOptions
Options for peerDeps
.
peerDeps
Optional
public readonly peerDeps: string[];
- Type: string[]
- Default: []
Peer dependencies for this module.
Dependencies listed here are required to
be installed (and satisfied) by the consumer of this library. Using peer
dependencies allows you to ensure that only a single module of a certain
library exists in the node_modules
tree of your consumers.
Note that prior to npm@7, peer dependencies are not automatically installed, which means that adding peer dependencies to a library will be a breaking change for your customers.
Unless peerDependencyOptions.pinnedDevDependency
is disabled (it is
enabled by default), projen will automatically add a dev dependency with a
pinned version for each peer dependency. This will ensure that you build &
test your module against the lowest peer version required.
pnpmVersion
Optional
public readonly pnpmVersion: string;
- Type: string
- Default: "7"
The version of PNPM to use if using PNPM as a package manager.
repository
Optional
public readonly repository: string;
- Type: string
The repository is the location where the actual code for your package lives.
See https://classic.yarnpkg.com/en/docs/package-json/#toc-repository
repositoryDirectory
Optional
public readonly repositoryDirectory: string;
- Type: string
If the package.json for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives.
scopedPackagesOptions
Optional
public readonly scopedPackagesOptions: ScopedPackagesOptions[];
- Type: ScopedPackagesOptions[]
- Default: fetch all scoped packages from the public npm registry
Options for privately hosted scoped packages.
scripts
Optional
scripts
- Deprecated: use
project.addTask()
orpackage.setScript()
public readonly scripts: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- Default: {}
npm scripts to include.
If a script has the same name as a standard script, the standard script will be overwritten. Also adds the script as a task.
stability
Optional
public readonly stability: string;
- Type: string
Package's Stability.
yarnBerryOptions
Optional
public readonly yarnBerryOptions: YarnBerryOptions;
- Type: YarnBerryOptions
- Default: Yarn Berry v4 with all default options
Options for Yarn Berry.
NodeProjectOptions
Initializer
import { javascript } from 'projen'
const nodeProjectOptions: javascript.NodeProjectOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | This is the name of your project. |
| boolean | Whether to commit the managed files by default. |
| projen.IgnoreFileOptions | Configuration options for .gitignore file. |
| projen.GitOptions | Configuration options for git. |
| projen.LoggerOptions | Configure logging options such as verbosity. |
| string | The root directory of the project. |
| projen.Project | The parent project, if this project is part of a bigger project. |
| string | The shell command to use in order to run the projen CLI. |
| boolean | Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation. |
| projen.ProjenrcJsonOptions | Options for .projenrc.json. |
| boolean | Use renovatebot to handle dependency upgrades. |
| projen.RenovatebotOptions | Options for renovatebot. |
| projen.github.AutoApproveOptions | Enable and configure the 'auto approve' workflow. |
| boolean | Enable automatic merging on GitHub. |
| projen.github.AutoMergeOptions | Configure options for automatic merging on GitHub. |
| boolean | Add a clobber task which resets the repo to origin. |
| boolean | Add a VSCode development environment (used for GitHub Codespaces). |
| boolean | Enable GitHub integration. |
| projen.github.GitHubOptions | Options for GitHub integration. |
| boolean | Add a Gitpod development environment. |
| boolean | Whether mergify should be enabled on this repository or not. |
| projen.github.MergifyOptions | Options for mergify. |
| projen.ProjectType | Which type of project this is (library/app). |
| projen.github.GithubCredentials | Choose a method of providing GitHub API access for projen workflows. |
| string | The name of a secret which includes a GitHub Personal Access Token to be used by projen workflows. |
| projen.SampleReadmeProps | The README setup. |
| boolean | Auto-close of stale issues and pull request. |
| projen.github.StaleOptions | Auto-close stale issues and pull requests. |
| boolean | Enable VSCode integration. |
| boolean | Allow the project to include peerDependencies and bundledDependencies . |
| string | Author's e-mail. |
| string | Author's name. |
| boolean | Is the author an organization. |
| string | Author's URL / Website. |
| boolean | Automatically add all executables under the bin directory to your package.json file under the bin section. |
| {[ key: string ]: string} | Binary programs vended with your module. |
| string | The email address to which issues should be reported. |
| string | The url to your project's issue tracker. |
| string[] | List of dependencies to bundle into this module. |
|
| Options for npm packages using AWS CodeArtifact. |
| string[] | Runtime dependencies of this module. |
| string | The description is just a string that helps people understand the purpose of the package. |
| string[] | Build dependencies for this module. |
| string | Module entrypoint (main in package.json ). |
| string | Package's Homepage / Website. |
| string[] | Keywords to include in package.json . |
| string | License's SPDX identifier. |
| boolean | Indicates if a license should be added. |
| string | The maximum node version supported by this package. Most projects should not use this option. |
| string | The minimum node version required by this package to function. Most projects should not use this option. |
|
| Access level of the npm package. |
| boolean | Should provenance statements be generated when the package is published. |
| string | The host name of the npm registry to publish to. |
| string | The base URL of the npm package registry. |
| string | GitHub secret which contains the NPM token to use when publishing packages. |
|
| The Node Package Manager used to execute scripts. |
| string | The "name" in package.json. |
|
| Options for peerDeps . |
| string[] | Peer dependencies for this module. |
| string | The version of PNPM to use if using PNPM as a package manager. |
| string | The repository is the location where the actual code for your package lives. |
| string | If the package.json for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives. |
|
| Options for privately hosted scoped packages. |
| {[ key: string ]: string} | npm scripts to include. |
| string | Package's Stability. |
|
| Options for Yarn Berry. |
| string | The commit-and-tag-version compatible package used to bump the package version, as a dependency string. |
| string | Version requirement of publib which is used to publish modules to npm. |
| number | Major version to release from the default branch. |
| number | Minimal Major version to release. |
| string | A shell command to control the next version to release. |
| string | The npmDistTag to use when publishing from the default branch. |
| projen.github.workflows.JobStep[] | Steps to execute after build as part of the release workflow. |
| string | Bump versions from the default branch as pre-releases (e.g. "beta", "alpha", "pre"). |
| boolean | Instead of actually publishing to package managers, just print the publishing command. |
| boolean | Define publishing tasks that can be executed manually as well as workflows. |
| projen.ReleasableCommits | Find commits that should be considered releasable Used to decide if a release is required. |
| {[ key: string ]: projen.release.BranchOptions} | Defines additional release branches. |
| boolean | Automatically release new versions every commit to one of branches in releaseBranches . |
| boolean | Create a github issue on every failed publishing task. |
| string | The label to apply to issues indicating publish failures. |
| string | CRON schedule to trigger new releases. |
| string | Automatically add the given prefix to release tags. Useful if you are releasing on multiple branches with overlapping version numbers. |
| projen.release.ReleaseTrigger | The release trigger to use. |
| string | The name of the default release workflow. |
| projen.github.workflows.JobStep[] | A set of workflow steps to execute in order to setup the workflow container. |
| {[ key: string ]: any} | Custom configuration used when creating changelog with commit-and-tag-version package. |
| string | Container image to use for GitHub workflows. |
| string[] | Github Runner selection labels. |
| projen.GroupRunnerOptions | Github Runner Group selection options. |
| string | The name of the main release branch. |
| string | A directory which will contain build artifacts. |
| boolean | Automatically approve deps upgrade PRs, allowing them to be merged by mergify (if configued). |
| boolean | Define a GitHub workflow for building PRs. |
|
| Options for PR build workflow. |
| projen.github.workflows.Triggers | Build workflow triggers. |
|
| Options for Bundler . |
|
| Configure which licenses should be deemed acceptable for use by dependencies. |
| boolean | Define a GitHub workflow step for sending code coverage metrics to https://codecov.io/ Uses codecov/codecov-action@v4 A secret is required for private repos. Configured with @codeCovTokenSecret . |
| string | Define the secret name for a specified https://codecov.io/ token A secret is required to send coverage for private repositories. |
| string | License copyright owner. |
| string | The copyright years to put in the LICENSE file. |
| boolean | Use dependabot to handle dependency upgrades. |
| projen.github.DependabotOptions | Options for dependabot. |
| boolean | Use tasks and github workflows to handle dependency upgrades. |
|
| Options for UpgradeDependencies . |
| string[] | Additional entries to .gitignore. |
| boolean | Setup jest unit tests. |
|
| Jest options. |
| boolean | Automatically update files modified during builds to pull-request branches. |
| string[] | Additional entries to .npmignore. |
| boolean | Defines an .npmignore file. Normally this is only needed for libraries that are packaged as tarballs. |
| projen.IgnoreFileOptions | Configuration options for .npmignore file. |
| boolean | Defines a package task that will produce an npm tarball under the artifacts directory (e.g. dist ). |
| boolean | Setup prettier. |
|
| Prettier options. |
| boolean | Indicates of "projen" should be installed as a devDependency. |
| boolean | Generate (once) .projenrc.js (in JavaScript). Set to false in order to disable .projenrc.js generation. |
|
| Options for .projenrc.js. |
| string | Version of projen to install. |
| boolean | Include a GitHub pull request template. |
| string[] | The contents of the pull request template. |
| boolean | Add release management to this project. |
| boolean | Automatically release to npm when new versions are introduced. |
| boolean | DEPRECATED: renamed to release . |
| projen.github.workflows.JobStep[] | Workflow steps to use in order to bootstrap this repo. |
| projen.github.GitIdentity | The git identity to use in workflows. |
| string | The node version used in GitHub Actions workflows. |
| boolean | Enable Node.js package cache in GitHub workflows. |
name
Required
public readonly name: string;
- Type: string
- Default: $BASEDIR
This is the name of your project.
commitGenerated
Optional
public readonly commitGenerated: boolean;
- Type: boolean
- Default: true
Whether to commit the managed files by default.
gitIgnoreOptions
Optional
public readonly gitIgnoreOptions: IgnoreFileOptions;
- Type: projen.IgnoreFileOptions
Configuration options for .gitignore file.
gitOptions
Optional
public readonly gitOptions: GitOptions;
- Type: projen.GitOptions
Configuration options for git.
logging
Optional
public readonly logging: LoggerOptions;
- Type: projen.LoggerOptions
- Default: {}
Configure logging options such as verbosity.
outdir
Optional
public readonly outdir: string;
- Type: string
- Default: "."
The root directory of the project.
Relative to this directory, all files are synthesized.
If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.
parent
Optional
public readonly parent: Project;
- Type: projen.Project
The parent project, if this project is part of a bigger project.
projenCommand
Optional
public readonly projenCommand: string;
- Type: string
- Default: "npx projen"
The shell command to use in order to run the projen CLI.
Can be used to customize in special environments.
projenrcJson
Optional
public readonly projenrcJson: boolean;
- Type: boolean
- Default: false
Generate (once) .projenrc.json (in JSON). Set to false
in order to disable .projenrc.json generation.
projenrcJsonOptions
Optional
public readonly projenrcJsonOptions: ProjenrcJsonOptions;
- Type: projen.ProjenrcJsonOptions
- Default: default options
Options for .projenrc.json.
renovatebot
Optional
public readonly renovatebot: boolean;
- Type: boolean
- Default: false
Use renovatebot to handle dependency upgrades.
renovatebotOptions
Optional
public readonly renovatebotOptions: RenovatebotOptions;
- Type: projen.RenovatebotOptions
- Default: default options
Options for renovatebot.
autoApproveOptions
Optional
public readonly autoApproveOptions: AutoApproveOptions;
- Type: projen.github.AutoApproveOptions
- Default: auto approve is disabled
Enable and configure the 'auto approve' workflow.
autoMerge
Optional
public readonly autoMerge: boolean;
- Type: boolean
- Default: true
Enable automatic merging on GitHub.
Has no effect if github.mergify
is set to false.
autoMergeOptions
Optional
public readonly autoMergeOptions: AutoMergeOptions;
- Type: projen.github.AutoMergeOptions
- Default: see defaults in
AutoMergeOptions
Configure options for automatic merging on GitHub.
Has no effect if
github.mergify
or autoMerge
is set to false.
clobber
Optional
public readonly clobber: boolean;
- Type: boolean
- Default: true, but false for subprojects
Add a clobber
task which resets the repo to origin.
devContainer
Optional
public readonly devContainer: boolean;
- Type: boolean
- Default: false
Add a VSCode development environment (used for GitHub Codespaces).
github
Optional
public readonly github: boolean;
- Type: boolean
- Default: true
Enable GitHub integration.
Enabled by default for root projects. Disabled for non-root projects.
githubOptions
Optional
public readonly githubOptions: GitHubOptions;
- Type: projen.github.GitHubOptions
- Default: see GitHubOptions
Options for GitHub integration.
gitpod
Optional
public readonly gitpod: boolean;
- Type: boolean
- Default: false
Add a Gitpod development environment.
mergify
Optional
mergify
- Deprecated: use
githubOptions.mergify
instead
public readonly mergify: boolean;
- Type: boolean
- Default: true
Whether mergify should be enabled on this repository or not.
mergifyOptions
Optional
mergifyOptions
- Deprecated: use
githubOptions.mergifyOptions
instead
public readonly mergifyOptions: MergifyOptions;
- Type: projen.github.MergifyOptions
- Default: default options
Options for mergify.
projectType
Optional
projectType
- Deprecated: no longer supported at the base project level
public readonly projectType: ProjectType;
- Type: projen.ProjectType
- Default: ProjectType.UNKNOWN
Which type of project this is (library/app).
projenCredentials
Optional
public readonly projenCredentials: GithubCredentials;
- Type: projen.github.GithubCredentials
- Default: use a personal access token named PROJEN_GITHUB_TOKEN
Choose a method of providing GitHub API access for projen workflows.
projenTokenSecret
Optional
projenTokenSecret
- Deprecated: use
projenCredentials
public readonly projenTokenSecret: string;
- Type: string
- Default: "PROJEN_GITHUB_TOKEN"
The name of a secret which includes a GitHub Personal Access Token to be used by projen workflows.
This token needs to have the repo
, workflows
and packages
scope.
readme
Optional
public readonly readme: SampleReadmeProps;
- Type: projen.SampleReadmeProps
- Default: { filename: 'README.md', contents: '# replace this' }
The README setup.
Example
"{ filename: 'readme.md', contents: '# title' }"
stale
Optional
public readonly stale: boolean;
- Type: boolean
- Default: false
Auto-close of stale issues and pull request.
See staleOptions
for options.
staleOptions
Optional
public readonly staleOptions: StaleOptions;
- Type: projen.github.StaleOptions
- Default: see defaults in
StaleOptions
Auto-close stale issues and pull requests.
To disable set stale
to false
.
vscode
Optional
public readonly vscode: boolean;
- Type: boolean
- Default: true
Enable VSCode integration.
Enabled by default for root projects. Disabled for non-root projects.
allowLibraryDependencies
Optional
public readonly allowLibraryDependencies: boolean;
- Type: boolean
- Default: true
Allow the project to include peerDependencies
and bundledDependencies
.
This is normally only allowed for libraries. For apps, there's no meaning for specifying these.
authorEmail
Optional
public readonly authorEmail: string;
- Type: string
Author's e-mail.
authorName
Optional
public readonly authorName: string;
- Type: string
Author's name.
authorOrganization
Optional
public readonly authorOrganization: boolean;
- Type: boolean
Is the author an organization.
authorUrl
Optional
public readonly authorUrl: string;
- Type: string
Author's URL / Website.
autoDetectBin
Optional
public readonly autoDetectBin: boolean;
- Type: boolean
- Default: true
Automatically add all executables under the bin
directory to your package.json
file under the bin
section.
bin
Optional
public readonly bin: {[ key: string ]: string};
- Type: {[ key: string ]: string}
Binary programs vended with your module.
You can use this option to add/customize how binaries are represented in
your package.json
, but unless autoDetectBin
is false
, every
executable file under bin
will automatically be added to this section.
bugsEmail
Optional
public readonly bugsEmail: string;
- Type: string
The email address to which issues should be reported.
bugsUrl
Optional
public readonly bugsUrl: string;
- Type: string
The url to your project's issue tracker.
bundledDeps
Optional
public readonly bundledDeps: string[];
- Type: string[]
List of dependencies to bundle into this module.
These modules will be
added both to the dependencies
section and bundledDependencies
section of
your package.json
.
The recommendation is to only specify the module name here (e.g.
express
). This will behave similar to yarn add
or npm install
in the
sense that it will add the module as a dependency to your package.json
file with the latest version (^
). You can specify semver requirements in
the same syntax passed to npm i
or yarn add
(e.g. express@^2
) and
this will be what you package.json
will eventually include.
codeArtifactOptions
Optional
public readonly codeArtifactOptions: CodeArtifactOptions;
- Type: CodeArtifactOptions
- Default: undefined
Options for npm packages using AWS CodeArtifact.
This is required if publishing packages to, or installing scoped packages from AWS CodeArtifact
deps
Optional
public readonly deps: string[];
- Type: string[]
- Default: []
Runtime dependencies of this module.
The recommendation is to only specify the module name here (e.g.
express
). This will behave similar to yarn add
or npm install
in the
sense that it will add the module as a dependency to your package.json
file with the latest version (^
). You can specify semver requirements in
the same syntax passed to npm i
or yarn add
(e.g. express@^2
) and
this will be what you package.json
will eventually include.
Example
[ 'express', 'lodash', 'foo@^2' ]
description
Optional
public readonly description: string;
- Type: string
The description is just a string that helps people understand the purpose of the package.
It can be used when searching for packages in a package manager as well. See https://classic.yarnpkg.com/en/docs/package-json/#toc-description
devDeps
Optional
public readonly devDeps: string[];
- Type: string[]
- Default: []
Build dependencies for this module.
These dependencies will only be available in your build environment but will not be fetched when this module is consumed.
The recommendation is to only specify the module name here (e.g.
express
). This will behave similar to yarn add
or npm install
in the
sense that it will add the module as a dependency to your package.json
file with the latest version (^
). You can specify semver requirements in
the same syntax passed to npm i
or yarn add
(e.g. express@^2
) and
this will be what you package.json
will eventually include.
Example
[ 'typescript', '@types/express' ]
entrypoint
Optional
public readonly entrypoint: string;
- Type: string
- Default: "lib/index.js"
Module entrypoint (main
in package.json
).
Set to an empty string to not include main
in your package.json
homepage
Optional
public readonly homepage: string;
- Type: string
Package's Homepage / Website.
keywords
Optional
public readonly keywords: string[];
- Type: string[]
Keywords to include in package.json
.
license
Optional
public readonly license: string;
- Type: string
- Default: "Apache-2.0"
License's SPDX identifier.
See https://github.com/projen/projen/tree/main/license-text for a list of supported licenses.
Use the licensed
option if you want to no license to be specified.
licensed
Optional
public readonly licensed: boolean;
- Type: boolean
- Default: true
Indicates if a license should be added.
maxNodeVersion
Optional
public readonly maxNodeVersion: string;
- Type: string
- Default: no maximum version is enforced
The maximum node version supported by this package. Most projects should not use this option.
The value indicates that the package is incompatible with any newer versions of node. This requirement is enforced via the engines field.
You will normally not need to set this option. Consider this option only if your package is known to not function with newer versions of node.
minNodeVersion
Optional
public readonly minNodeVersion: string;
- Type: string
- Default: no minimum version is enforced
The minimum node version required by this package to function. Most projects should not use this option.
The value indicates that the package is incompatible with any older versions of node. This requirement is enforced via the engines field.
You will normally not need to set this option, even if your package is incompatible with EOL versions of node. Consider this option only if your package depends on a specific feature, that is not available in other LTS versions. Setting this option has very high impact on the consumers of your package, as package managers will actively prevent usage with node versions you have marked as incompatible.
To change the node version of your CI/CD workflows, use workflowNodeVersion
.
npmAccess
Optional
public readonly npmAccess: NpmAccess;
- Type: NpmAccess
- Default: for scoped packages (e.g.
foo@bar
), the default isNpmAccess.RESTRICTED
, for non-scoped packages, the default isNpmAccess.PUBLIC
.
Access level of the npm package.
npmProvenance
Optional
public readonly npmProvenance: boolean;
- Type: boolean
- Default: true for public packages, false otherwise
Should provenance statements be generated when the package is published.
A supported package manager is required to publish a package with npm provenance statements and you will need to use a supported CI/CD provider.
Note that the projen Release
and Publisher
components are using publib
to publish packages,
which is using npm internally and supports provenance statements independently of the package manager used.
npmRegistry
Optional
npmRegistry
- Deprecated: use
npmRegistryUrl
instead
public readonly npmRegistry: string;
- Type: string
The host name of the npm registry to publish to.
Cannot be set together with npmRegistryUrl
.
npmRegistryUrl
Optional
public readonly npmRegistryUrl: string;
- Type: string
- Default: "https://registry.npmjs.org"
The base URL of the npm package registry.
Must be a URL (e.g. start with "https://" or "http://")
npmTokenSecret
Optional
public readonly npmTokenSecret: string;
- Type: string
- Default: "NPM_TOKEN"
GitHub secret which contains the NPM token to use when publishing packages.
packageManager
Optional
public readonly packageManager: NodePackageManager;
- Type: NodePackageManager
- Default: NodePackageManager.YARN_CLASSIC
The Node Package Manager used to execute scripts.
packageName
Optional
public readonly packageName: string;
- Type: string
- Default: defaults to project name
The "name" in package.json.
peerDependencyOptions
Optional
public readonly peerDependencyOptions: PeerDependencyOptions;
- Type: PeerDependencyOptions
Options for peerDeps
.
peerDeps
Optional
public readonly peerDeps: string[];
- Type: string[]
- Default: []
Peer dependencies for this module.
Dependencies listed here are required to
be installed (and satisfied) by the consumer of this library. Using peer
dependencies allows you to ensure that only a single module of a certain
library exists in the node_modules
tree of your consumers.
Note that prior to npm@7, peer dependencies are not automatically installed, which means that adding peer dependencies to a library will be a breaking change for your customers.
Unless peerDependencyOptions.pinnedDevDependency
is disabled (it is
enabled by default), projen will automatically add a dev dependency with a
pinned version for each peer dependency. This will ensure that you build &
test your module against the lowest peer version required.
pnpmVersion
Optional
public readonly pnpmVersion: string;
- Type: string
- Default: "7"
The version of PNPM to use if using PNPM as a package manager.
repository
Optional
public readonly repository: string;
- Type: string
The repository is the location where the actual code for your package lives.
See https://classic.yarnpkg.com/en/docs/package-json/#toc-repository
repositoryDirectory
Optional
public readonly repositoryDirectory: string;
- Type: string
If the package.json for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives.
scopedPackagesOptions
Optional
public readonly scopedPackagesOptions: ScopedPackagesOptions[];
- Type: ScopedPackagesOptions[]
- Default: fetch all scoped packages from the public npm registry
Options for privately hosted scoped packages.
scripts
Optional
scripts
- Deprecated: use
project.addTask()
orpackage.setScript()
public readonly scripts: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- Default: {}
npm scripts to include.
If a script has the same name as a standard script, the standard script will be overwritten. Also adds the script as a task.
stability
Optional
public readonly stability: string;
- Type: string
Package's Stability.
yarnBerryOptions
Optional
public readonly yarnBerryOptions: YarnBerryOptions;
- Type: YarnBerryOptions
- Default: Yarn Berry v4 with all default options
Options for Yarn Berry.
bumpPackage
Optional
public readonly bumpPackage: string;
- Type: string
- Default: A recent version of "commit-and-tag-version"
The commit-and-tag-version
compatible package used to bump the package version, as a dependency string.
This can be any compatible package version, including the deprecated standard-version@9
.
jsiiReleaseVersion
Optional
public readonly jsiiReleaseVersion: string;
- Type: string
- Default: "latest"
Version requirement of publib
which is used to publish modules to npm.
majorVersion
Optional
public readonly majorVersion: number;
- Type: number
- Default: Major version is not enforced.
Major version to release from the default branch.
If this is specified, we bump the latest version of this major version line. If not specified, we bump the global latest version.
minMajorVersion
Optional
public readonly minMajorVersion: number;
- Type: number
- Default: No minimum version is being enforced
Minimal Major version to release.
This can be useful to set to 1, as breaking changes before the 1.x major release are not incrementing the major version number.
Can not be set together with majorVersion
.
nextVersionCommand
Optional
public readonly nextVersionCommand: string;
- Type: string
- Default: The next version will be determined based on the commit history and project settings.
A shell command to control the next version to release.
If present, this shell command will be run before the bump is executed, and it determines what version to release. It will be executed in the following environment:
- Working directory: the project directory.
$VERSION
: the current version. Looks like1.2.3
.$LATEST_TAG
: the most recent tag. Looks likeprefix-v1.2.3
, or may be unset.
The command should print one of the following to stdout
:
- Nothing: the next version number will be determined based on commit history.
x.y.z
: the next version number will bex.y.z
.major|minor|patch
: the next version number will be the current version number with the indicated component bumped.
This setting cannot be specified together with minMajorVersion
; the invoked
script can be used to achieve the effects of minMajorVersion
.
npmDistTag
Optional
public readonly npmDistTag: string;
- Type: string
- Default: "latest"
The npmDistTag to use when publishing from the default branch.
To set the npm dist-tag for release branches, set the npmDistTag
property
for each branch.
postBuildSteps
Optional
public readonly postBuildSteps: JobStep[];
- Type: projen.github.workflows.JobStep[]
- Default: []
Steps to execute after build as part of the release workflow.
prerelease
Optional
public readonly prerelease: string;
- Type: string
- Default: normal semantic versions
Bump versions from the default branch as pre-releases (e.g. "beta", "alpha", "pre").
publishDryRun
Optional
public readonly publishDryRun: boolean;
- Type: boolean
- Default: false
Instead of actually publishing to package managers, just print the publishing command.
publishTasks
Optional
public readonly publishTasks: boolean;
- Type: boolean
- Default: false
Define publishing tasks that can be executed manually as well as workflows.
Normally, publishing only happens within automated workflows. Enable this in order to create a publishing task for each publishing activity.
releasableCommits
Optional
public readonly releasableCommits: ReleasableCommits;
- Type: projen.ReleasableCommits
- Default: ReleasableCommits.everyCommit()
Find commits that should be considered releasable Used to decide if a release is required.
releaseBranches
Optional
public readonly releaseBranches: {[ key: string ]: BranchOptions};
- Type: {[ key: string ]: projen.release.BranchOptions}
- Default: no additional branches are used for release. you can use
addBranch()
to add additional branches.
Defines additional release branches.
A workflow will be created for each
release branch which will publish releases from commits in this branch.
Each release branch must be assigned a major version number which is used
to enforce that versions published from that branch always use that major
version. If multiple branches are used, the majorVersion
field must also
be provided for the default branch.
releaseEveryCommit
Optional
releaseEveryCommit
- Deprecated: Use
releaseTrigger: ReleaseTrigger.continuous()
instead
public readonly releaseEveryCommit: boolean;
- Type: boolean
- Default: true
Automatically release new versions every commit to one of branches in releaseBranches
.
releaseFailureIssue
Optional
public readonly releaseFailureIssue: boolean;
- Type: boolean
- Default: false
Create a github issue on every failed publishing task.
releaseFailureIssueLabel
Optional
public readonly releaseFailureIssueLabel: string;
- Type: string
- Default: "failed-release"
The label to apply to issues indicating publish failures.
Only applies if releaseFailureIssue
is true.
releaseSchedule
Optional
releaseSchedule
- Deprecated: Use
releaseTrigger: ReleaseTrigger.scheduled()
instead
public readonly releaseSchedule: string;
- Type: string
- Default: no scheduled releases
CRON schedule to trigger new releases.
releaseTagPrefix
Optional
public readonly releaseTagPrefix: string;
- Type: string
- Default: "v"
Automatically add the given prefix to release tags. Useful if you are releasing on multiple branches with overlapping version numbers.
Note: this prefix is used to detect the latest tagged version when bumping, so if you change this on a project with an existing version history, you may need to manually tag your latest release with the new prefix.
releaseTrigger
Optional
public readonly releaseTrigger: ReleaseTrigger;
- Type: projen.release.ReleaseTrigger
- Default: Continuous releases (
ReleaseTrigger.continuous()
)
The release trigger to use.
releaseWorkflowName
Optional
public readonly releaseWorkflowName: string;
- Type: string
- Default: "release"
The name of the default release workflow.
releaseWorkflowSetupSteps
Optional
public readonly releaseWorkflowSetupSteps: JobStep[];
- Type: projen.github.workflows.JobStep[]
A set of workflow steps to execute in order to setup the workflow container.
versionrcOptions
Optional
public readonly versionrcOptions: {[ key: string ]: any};
- Type: {[ key: string ]: any}
- Default: standard configuration applicable for GitHub repositories
Custom configuration used when creating changelog with commit-and-tag-version package.
Given values either append to default configuration or overwrite values in it.
workflowContainerImage
Optional
public readonly workflowContainerImage: string;
- Type: string
- Default: default image
Container image to use for GitHub workflows.
workflowRunsOn
Optional
public readonly workflowRunsOn: string[];
- Type: string[]
- Default: ["ubuntu-latest"]
Github Runner selection labels.
workflowRunsOnGroup
Optional
public readonly workflowRunsOnGroup: GroupRunnerOptions;
- Type: projen.GroupRunnerOptions
Github Runner Group selection options.
defaultReleaseBranch
Required
public readonly defaultReleaseBranch: string;
- Type: string
- Default: "main"
The name of the main release branch.
artifactsDirectory
Optional
public readonly artifactsDirectory: string;
- Type: string
- Default: "dist"
A directory which will contain build artifacts.
autoApproveUpgrades
Optional
public readonly autoApproveUpgrades: boolean;
- Type: boolean
- Default: true
Automatically approve deps upgrade PRs, allowing them to be merged by mergify (if configued).
Throw if set to true but autoApproveOptions
are not defined.
buildWorkflow
Optional
public readonly buildWorkflow: boolean;
- Type: boolean
- Default: true if not a subproject
Define a GitHub workflow for building PRs.
buildWorkflowOptions
Optional
public readonly buildWorkflowOptions: BuildWorkflowOptions;
- Type: BuildWorkflowOptions
Options for PR build workflow.
buildWorkflowTriggers
Optional
buildWorkflowTriggers
- Deprecated: - Use
buildWorkflowOptions.workflowTriggers
public readonly buildWorkflowTriggers: Triggers;
- Type: projen.github.workflows.Triggers
- Default: "{ pullRequest: {}, workflowDispatch: {} }"
Build workflow triggers.
bundlerOptions
Optional
public readonly bundlerOptions: BundlerOptions;
- Type: BundlerOptions
Options for Bundler
.
checkLicenses
Optional
public readonly checkLicenses: LicenseCheckerOptions;
- Type: LicenseCheckerOptions
- Default: no license checks are run during the build and all licenses will be accepted
Configure which licenses should be deemed acceptable for use by dependencies.
This setting will cause the build to fail, if any prohibited or not allowed licenses ares encountered.
codeCov
Optional
public readonly codeCov: boolean;
- Type: boolean
- Default: false
Define a GitHub workflow step for sending code coverage metrics to https://codecov.io/ Uses codecov/codecov-action@v4 A secret is required for private repos. Configured with @codeCovTokenSecret
.
codeCovTokenSecret
Optional
public readonly codeCovTokenSecret: string;
- Type: string
- Default: if this option is not specified, only public repositories are supported
Define the secret name for a specified https://codecov.io/ token A secret is required to send coverage for private repositories.
copyrightOwner
Optional
public readonly copyrightOwner: string;
- Type: string
- Default: defaults to the value of authorName or "" if
authorName
is undefined.
License copyright owner.
copyrightPeriod
Optional
public readonly copyrightPeriod: string;
- Type: string
- Default: current year
The copyright years to put in the LICENSE file.
dependabot
Optional
public readonly dependabot: boolean;
- Type: boolean
- Default: false
Use dependabot to handle dependency upgrades.
Cannot be used in conjunction with depsUpgrade
.
dependabotOptions
Optional
public readonly dependabotOptions: DependabotOptions;
- Type: projen.github.DependabotOptions
- Default: default options
Options for dependabot.
depsUpgrade
Optional
public readonly depsUpgrade: boolean;
- Type: boolean
- Default: true
Use tasks and github workflows to handle dependency upgrades.
Cannot be used in conjunction with dependabot
.
depsUpgradeOptions
Optional
public readonly depsUpgradeOptions: UpgradeDependenciesOptions;
- Type: UpgradeDependenciesOptions
- Default: default options
Options for UpgradeDependencies
.
gitignore
Optional
public readonly gitignore: string[];
- Type: string[]
Additional entries to .gitignore.
jest
Optional
public readonly jest: boolean;
- Type: boolean
- Default: true
Setup jest unit tests.
jestOptions
Optional
public readonly jestOptions: JestOptions;
- Type: JestOptions
- Default: default options
Jest options.
mutableBuild
Optional
mutableBuild
- Deprecated: - Use
buildWorkflowOptions.mutableBuild
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.
npmignore
Optional
npmignore
- Deprecated: - use
project.addPackageIgnore
public readonly npmignore: string[];
- Type: string[]
Additional entries to .npmignore.
npmignoreEnabled
Optional
public readonly npmignoreEnabled: boolean;
- Type: boolean
- Default: true
Defines an .npmignore file. Normally this is only needed for libraries that are packaged as tarballs.
npmIgnoreOptions
Optional
public readonly npmIgnoreOptions: IgnoreFileOptions;
- Type: projen.IgnoreFileOptions
Configuration options for .npmignore file.
package
Optional
public readonly package: boolean;
- Type: boolean
- Default: true
Defines a package
task that will produce an npm tarball under the artifacts directory (e.g. dist
).
prettier
Optional
public readonly prettier: boolean;
- Type: boolean
- Default: false
Setup prettier.
prettierOptions
Optional
public readonly prettierOptions: PrettierOptions;
- Type: PrettierOptions
- Default: default options
Prettier options.
projenDevDependency
Optional
public readonly projenDevDependency: boolean;
- Type: boolean
- Default: true if not a subproject
Indicates of "projen" should be installed as a devDependency.
projenrcJs
Optional
public readonly projenrcJs: boolean;
- Type: boolean
- Default: true if projenrcJson is false
Generate (once) .projenrc.js (in JavaScript). Set to false
in order to disable .projenrc.js generation.
projenrcJsOptions
Optional
public readonly projenrcJsOptions: ProjenrcOptions;
- Type: ProjenrcOptions
- Default: default options
Options for .projenrc.js.
projenVersion
Optional
public readonly projenVersion: string;
- Type: string
- Default: Defaults to the latest version.
Version of projen to install.
pullRequestTemplate
Optional
public readonly pullRequestTemplate: boolean;
- Type: boolean
- Default: true
Include a GitHub pull request template.
pullRequestTemplateContents
Optional
public readonly pullRequestTemplateContents: string[];
- Type: string[]
- Default: default content
The contents of the pull request template.
release
Optional
public readonly release: boolean;
- Type: boolean
- Default: true (false for subprojects)
Add release management to this project.
releaseToNpm
Optional
public readonly releaseToNpm: boolean;
- Type: boolean
- Default: false
Automatically release to npm when new versions are introduced.
releaseWorkflow
Optional
releaseWorkflow
- Deprecated: see
release
.
public readonly releaseWorkflow: boolean;
- Type: boolean
- Default: true if not a subproject
DEPRECATED: renamed to release
.
workflowBootstrapSteps
Optional
public readonly workflowBootstrapSteps: JobStep[];
- Type: projen.github.workflows.JobStep[]
- Default: "yarn install --frozen-lockfile && yarn projen"
Workflow steps to use in order to bootstrap this repo.
workflowGitIdentity
Optional
public readonly workflowGitIdentity: GitIdentity;
- Type: projen.github.GitIdentity
- Default: GitHub Actions
The git identity to use in workflows.
workflowNodeVersion
Optional
public readonly workflowNodeVersion: string;
- Type: string
- Default:
minNodeVersion
if set, otherwiselts/*
.
The node version used in GitHub Actions workflows.
Always use this option if your GitHub Actions workflows require a specific to run.
workflowPackageCache
Optional
public readonly workflowPackageCache: boolean;
- Type: boolean
- Default: false
Enable Node.js package cache in GitHub workflows.
NpmConfigOptions
Options to configure the local NPM config.
Initializer
import { javascript } from 'projen'
const npmConfigOptions: javascript.NpmConfigOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | Omits empty objects and arrays. |
| string | URL of the registry mirror to use. |
omitEmpty
Optional
public readonly omitEmpty: boolean;
- Type: boolean
- Default: false
Omits empty objects and arrays.
registry
Optional
public readonly registry: string;
- Type: string
- Default: use npmjs default registry
URL of the registry mirror to use.
You can change this or add scoped registries using the addRegistry method