Options
All
  • Public
  • Public/Protected
  • All
Menu

The class helps you bundle apps for deployment on Layer0.

Hierarchy

  • DeploymentBuilder

Index

Constructors

constructor

Properties

appDir

appDir: string

jsDir

jsDir: string

layer0Dir

layer0Dir: string

permanentStaticAssetsDir

permanentStaticAssetsDir: string

sourcesDir

sourcesDir: string

staticAssetsDir

staticAssetsDir: string

Accessors

Static layer0Version

  • get layer0Version(): string
  • Layer0 version of @layer0/core.

    Returns string

Methods

addDefaultAppResources

  • addDefaultAppResources(defaultAppPath: string): this
  • Ensures all assets in the "all", "js", and "ts" subdirectories of defaultAppPath are either already present in the user's app or are copied over from defaultAppPath.

    Parameters

    • defaultAppPath: string

    Returns this

    A self reference, suitable for chaining

addDefaultLayer0Scripts

  • addDefaultLayer0Scripts(scriptsOverride?: {}, overrideExisting?: boolean): this
  • Copies all the layer0 scripts into the package.json file, if they don't already exist.

    Parameters

    • Default value scriptsOverride: {} = {}

      Used to pass framework-specific script overrides

    • Default value overrideExisting: boolean = false

    Returns this

    A self reference, suitable for chaining

addJSAsset

  • addJSAsset(src: string, dest?: undefined | string, options?: CopyOptionsSync): this
  • Adds an asset to the bundle for JavaScript workers

    Parameters

    • src: string

      The source path

    • Optional dest: undefined | string

      An optional destination path within the lambda root directory. If not provided, the destination path will be the same as the source path.

    • Optional options: CopyOptionsSync

      Options for copySync

    Returns this

    a self reference, suitable for chaining

addSource

  • addSource(src: string): void
  • Copies a file or directory into .layer0/src

    Parameters

    • src: string

    Returns void

addStaticAsset

  • addStaticAsset(src: string, dest?: undefined | string, __namedParameters?: { exclude: string[]; permanent: boolean }): this
  • Adds a folder or file as static asset. Also register directories as asset aliases when they contains an index.html file

    Parameters

    • src: string

      The source path

    • Optional dest: undefined | string

      An optional destination path in s3. If not provided, the destination path will be the same as the source path.

    • Default value __namedParameters: { exclude: string[]; permanent: boolean } = {}
      • exclude: string[]
      • permanent: boolean

    Returns this

    a self reference, suitable for chaining

build

  • build(__namedParameters?: { layer0SourceMaps: boolean }): Promise<void>
  • Copies all of the standard assets into the JS and static asset bundles. These are the same for any framework.

    Parameters

    • Default value __namedParameters: { layer0SourceMaps: boolean } = {}
      • layer0SourceMaps: boolean

    Returns Promise<void>

clearPreviousBuildOutput

  • clearPreviousBuildOutput(): this
  • Deletes the output of the previous build.

    Returns this

copySync

  • copySync(from: string, to: string, copySyncOptions?: CopyOptionsSync): void
  • Copies a file

    Parameters

    • from: string

      the source path

    • to: string

      the destination path

    • Default value copySyncOptions: CopyOptionsSync = {}

    Returns void

emptyDirSync

  • emptyDirSync(dir: string): void
  • Deletes all files in a directory

    Parameters

    • dir: string

      The directory to empty

    Returns void

exec

  • exec(command: string, options?: ExecOptions): Promise<unknown>
  • Runs a command.

    Parameters

    • command: string
    • Default value options: ExecOptions = {}

      Options for shelljs

    Returns Promise<unknown>

    A promise that resolves when the command is finished.

getRouter

  • getRouter(): Promise<Router>
  • Returns the router instance.

    Returns Promise<Router>

includeFiles

  • includeFiles(): Promise<void>
  • Adds all configured extra files to the lamdba directory

    Returns Promise<void>

includeNodeModules

  • includeNodeModules(): Promise<void>
  • Adds all dependencies from package.json to the JS bundle (excluding devDependencies)

    Returns Promise<void>

isYarn

  • isYarn(): boolean
  • Returns boolean

log

  • log(...msg: any[]): void
  • Logs a message to the console if process.env.debug is set to true

    Parameters

    • Rest ...msg: any[]

      The message to log

    Returns void

preparePackageJson

  • preparePackageJson(): void
  • Copies the package.json file into the lambda and adjust all dependencies that use file paths

    Returns void

readFileSync

  • readFileSync(path: string, __namedParameters?: { encoding: "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" }): string
  • Reads a file

    Parameters

    • path: string

      the file path

    • Default value __namedParameters: { encoding: "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" } = {}
      • encoding: "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex"

    Returns string

    The file contents

removeSync

  • removeSync(path: string): void
  • Deletes a file

    Parameters

    • path: string

      The file to delete

    Returns void

setStaticAssetExpiration

  • setStaticAssetExpiration(path: string, maxAgeSeconds: number, staleWhileRevalidateSeconds: number): this
  • Configures the TTL for a static asset. Once the TTL has expired, it will be refreshed by forwarding requests for that asset to serverless.

    Parameters

    • path: string

      The path to the asset within the app

    • maxAgeSeconds: number

      The TTL in seconds

    • staleWhileRevalidateSeconds: number

    Returns this

    A self-reference, suitable for chaining

writeFileSync

  • writeFileSync(to: string, content: string, encoding?: string): void
  • Writes a file

    Parameters

    • to: string

      the destination path

    • content: string

      the contents of the file

    • Default value encoding: string = "utf8"

      the encoding

    Returns void

Generated using TypeDoc