Use TypescriptBaseBuilder instead

Hierarchy

  • TypeScriptProject
    • TypescriptProject

Constructors

Properties

artifactsDirectory: string

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

artifactsJavascriptDirectory: string

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

autoApprove?: AutoApprove

Auto approve set up for this project.

autoMerge?: AutoMerge

Component that sets up mergify for merging approved pull requests.

buildWorkflow?: BuildWorkflow

The PR build GitHub workflow. undefined if buildWorkflow is disabled.

bundler: Bundler
commitGenerated: boolean

Whether to commit the managed files by default.

defaultTask?: Task

This is the "default" task, the one that executes "projen". Undefined if the project is being ejected.

deps: Dependencies

Project dependencies.

devContainer: undefined | DevContainer

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

This will be undefined if devContainer boolean is false

docgen?: boolean
docsDirectory: string
eslint?: Eslint
gitattributes: GitAttributesFile

The .gitattributes file for this repository.

github: undefined | GitHub

Access all github components.

This will be undefined for subprojects.

gitignore: IgnoreFile

.gitignore

gitpod: undefined | Gitpod

Access for Gitpod

This will be undefined if gitpod boolean is false

initProject?: InitProject

The options used when this project is bootstrapped via projen new. It includes the original set of options passed to the CLI and also the JSII FQN of the project type.

jest?: Jest

The Jest configuration (if enabled)

libdir: string

The directory in which compiled .js files reside.

lintConfig: LintConfig
logger: Logger

Logging utilities.

name: string

Project name.

node: Node

The tree node.

nodeVersion?: string
npmignore?: IgnoreFile

The .npmignore file.

outdir: string

Absolute output directory of this project.

package: NodePackage

API for managing the node package.

parent?: Project

A parent project. If undefined, this is the root project.

pnpm: PnpmWorkspace
prettier?: Prettier
projectBuild: ProjectBuild

Manages the build process of the project.

projectName: ProjectName
projectType: ProjectType
publisher?: Publisher

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

use release.publisher.

release?: Release

Release management.

runScriptCommand: string

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

srcdir: string

The directory in which the .ts sources reside.

tasks: Tasks

Project tasks.

testdir: string

The directory in which tests reside.

tsconfig: TypescriptConfig
tsconfigContainer: TypescriptConfigContainer
tsconfigDev: TypescriptConfig

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

tsconfigEslint?: TypescriptConfig
upgradeWorkflow?: UpgradeDependencies

The upgrade workflow.

vscode: undefined | VsCode

Access all VSCode components.

This will be undefined for subprojects.

watchTask: Task

The "watch" task.

workflowBootstrapSteps: JobStep[]
workflowPackageCache: boolean
DEFAULT_TASK: "default" = "default"

The name of the default task (the task executed when projen is run without arguments). Normally this task should synthesize the project files.

DEFAULT_TS_JEST_TRANFORM_PATTERN: "^.+\\.[t]sx?$" = "^.+\\.[t]sx?$"

Accessors

  • get allowLibraryDependencies(): boolean
  • Returns boolean

    use package.allowLibraryDependencies

  • get buildTask(): Task
  • Returns Task

  • get buildWorkflowJobId(): undefined | string
  • The job ID of the build workflow.

    Returns undefined | string

  • get compileTask(): Task
  • Returns Task

  • get components(): Component[]
  • Returns all the components within this project.

    Returns Component[]

  • get ejected(): boolean
  • Whether or not the project is being ejected.

    Returns boolean

  • get entrypoint(): string
  • Returns string

    use package.entrypoint

  • get files(): FileBase[]
  • All files in this project.

    Returns FileBase[]

  • get manifest(): any
  • Returns any

    use package.addField(x, y)

  • get maxNodeVersion(): undefined | string
  • Maximum node version required by this package.

    Returns undefined | string

  • get minNodeVersion(): undefined | string
  • Minimum node.js version required by this package.

    Returns undefined | string

  • get npmrc(): NpmConfig
  • The .npmrc file

    Returns NpmConfig

  • get packageManager(): NodePackageManager
  • The package manager to use.

    Returns NodePackageManager

    use package.packageManager

  • get packageTask(): Task
  • Returns Task

  • get postCompileTask(): Task
  • Returns Task

  • get preCompileTask(): Task
  • Returns Task

  • get projenCommand(): string
  • The command to use in order to run the projen CLI.

    Returns string

  • get root(): Project
  • The root project.

    Returns Project

  • get subprojects(): Project[]
  • Returns all the subprojects within this project.

    Returns Project[]

  • get testTask(): Task
  • Returns Task

Methods

  • Parameters

    • bins: Record<string, string>

    Returns void

  • Defines bundled dependencies.

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

    Parameters

    • Rest...deps: 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.

    Returns void

  • DEPRECATED

    Parameters

    • Rest...commands: string[]

    Returns void

    use project.compileTask.exec()

  • Defines normal dependencies.

    Parameters

    • Rest...deps: 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.

    Returns void

  • Defines development/test dependencies.

    Parameters

    • Rest...deps: 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.

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

    Parameters

    • Rest...globs: string[]

      The glob patterns to match

    Returns void

  • Directly set fields in package.json.

    Parameters

    • fields: {
          [name: string]: any;
      }

      The fields to set

      • [name: string]: any

    Returns void

  • Adds a .gitignore pattern.

    Parameters

    • pattern: string

      The glob pattern to ignore.

    Returns void

  • Adds keywords to package.json (deduplicated)

    Parameters

    • Rest...keywords: string[]

      The keywords to add

    Returns void

  • Adds patterns to be ignored by npm.

    Parameters

    • pattern: string

      The pattern to ignore.

    Returns void

    If you are having trouble getting an ignore to populate, try using your construct or component's preSynthesize method to properly delay calling this method.

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

    Parameters

    • Rest...deps: 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.

    Returns void

  • Replaces the contents of multiple npm package.json scripts.

    Parameters

    • scripts: {
          [name: string]: string;
      }

      The scripts to set

      • [name: string]: string

    Returns void

  • Adds a new task to this project. This will fail if the project already has a task with this name.

    Parameters

    • name: string

      The task name to add

    • Optionalprops: TaskOptions

      Task properties

    Returns Task

  • DEPRECATED

    Parameters

    • Rest...commands: string[]

    Returns void

    use project.testTask.exec()

  • Prints a "tip" message during synthesis.

    Parameters

    • message: string

      The message

    Returns void

    • use project.logger.info(message) to show messages during synthesis
  • Parameters

    • Rest...dependency: [options: string | NodeProject | {
          addTsPath: boolean;
          depType: DependencyType;
      }, ...deps: (string | NodeProject)[]]

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

    Parameters

    • glob: string

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

    Returns void

  • Indicates if a script by the name name is defined.

    Parameters

    • name: string

      The name of the script

    Returns boolean

    Use project.tasks.tryFind(name)

  • Called after all components are synthesized. Order is not guaranteed.

    Returns void

  • Called before all components are synthesized.

    Returns void

  • Removes the npm script (always successful).

    Parameters

    • name: string

      The name of the script.

    Returns void

  • Removes a task from a project.

    Parameters

    • name: string

      The name of the task to remove.

    Returns undefined | Task

    The Task that was removed, otherwise undefined.

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

    Parameters

    • Optionaloptions: RenderWorkflowSetupOptions

      Options.

    Returns JobStep[]

    Job steps

  • Returns the shell command to execute in order to run a task. This will typically be npx projen TASK.

    Parameters

    • task: Task

      The task for which the command is required

    Returns string

  • Replaces the contents of an npm package.json script.

    Parameters

    • name: string

      The script name

    • command: string

      The command to execute

    Returns void

  • Synthesize all project files into outdir.

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

    Returns void

  • Returns a string representation of this construct.

    Returns string

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

    Parameters

    • filePath: string

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

    Returns undefined | FileBase

    a FileBase or undefined if there is no file in that path

  • Finds a json file by name.

    Parameters

    • filePath: string

      The file path.

    Returns undefined | JsonFile

    use tryFindObjectFile

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

    Parameters

    • filePath: string

      The file path.

    Returns undefined | ObjectFile

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

    Parameters

    • filePath: string

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

    Returns undefined | FileBase

    a FileBase if the file was found and removed, or undefined if the file was not found.

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

    Parameters

    • x: any

      Any object

    Returns x is Construct

    true if x is an object created from a class which extends Construct.

  • Test whether the given construct is a project.

    Parameters

    • x: any

    Returns x is Project

  • Find the closest ancestor project for given construct. When given a project, this it the project itself.

    Parameters

    • construct: IConstruct

    Returns Project

    when no project is found in the path to the root