Hierarchy

  • CommandContext
    • default

Constructors

Properties

Deployment: typeof Deployment = Deployment

Default deployment class.

args: string[] = []

Extra arguments passed from the command line.

builder: Builder

Default builder.

commandTree: CommandTree<default> = {}

All registered commands.

config: Config

Fadroma settings.

currentCommand: string = ''

Currently executing command.

cwd: string = ...

Current working directory at launch of process.

description: string = '@hackbg/cmds'
env: Record<string, undefined | string> = ...

Process environment at lauch of process.

label: string = ...
log: any = ...
name: string

Name of the project.

root: OpaqueDirectory

Root directory of the project.

templates: Record<string, Template<any>>

Contract definitions.

timestamp: string = ...

Start of command execution.

uploader: Uploader

Default uploader.

Accessors

  • get dirs(): {
        src: OpaqueDirectory;
        state: OpaqueDirectory;
        wasm: OpaqueDirectory;
    }
  • Returns {
        src: OpaqueDirectory;
        state: OpaqueDirectory;
        wasm: OpaqueDirectory;
    }

    stateless handles for the subdirectories of the project.

    • src: OpaqueDirectory
    • state: OpaqueDirectory
    • wasm: OpaqueDirectory
  • get files(): {
        apiIndex: TextFile;
        cargoToml: TOMLFile<unknown>;
        dockerfile: null;
        droneWorkflow: null;
        envfile: TextFile;
        fadromaYaml: YAMLFile<unknown>;
        githubWorkflow: null;
        gitignore: TextFile;
        opsIndex: TextFile;
        packageJson: JSONFile<unknown>;
        readme: TextFile;
        shellNix: TextFile;
        testIndex: TextFile;
    }
  • Returns {
        apiIndex: TextFile;
        cargoToml: TOMLFile<unknown>;
        dockerfile: null;
        droneWorkflow: null;
        envfile: TextFile;
        fadromaYaml: YAMLFile<unknown>;
        githubWorkflow: null;
        gitignore: TextFile;
        opsIndex: TextFile;
        packageJson: JSONFile<unknown>;
        readme: TextFile;
        shellNix: TextFile;
        testIndex: TextFile;
    }

    stateless handles for various config files that are part of the project.

    • apiIndex: TextFile
    • cargoToml: TOMLFile<unknown>
    • dockerfile: null
    • droneWorkflow: null
    • envfile: TextFile
    • fadromaYaml: YAMLFile<unknown>
    • githubWorkflow: null
    • gitignore: TextFile
    • opsIndex: TextFile
    • packageJson: JSONFile<unknown>
    • readme: TextFile
    • shellNix: TextFile
    • testIndex: TextFile

Methods

  • Define a command after the instance is constructed.

    Parameters

    • name: string
    • description: string
    • Rest ...steps: Steps<default>

    Returns default

    this

    Example

    export default new CommandContext()
    .addCommand('foo', 'do one thing', async () => { ... })
    .addCommand('bar', 'do another thing', () => { ... })
  • Define a command subtree after the instance is constructed.

    Parameters

    • name: string
    • description: string
    • subtree: CommandContext

    Returns default

    this

    Example

    export default new CommandContext()
    .addCommands('empty', 'do nothing in new context', new CommandContext())
    .addCommands('baz', 'do some more things', new CommandContext()
    .addCommand(...)
    .addCommand(...))
  • Builds one or more named templates, or all templates if no arguments are passed.

    Parameters

    • Rest ...names: string[]

    Returns Promise<Built[]>

  • Define a command during construction.

    Type Parameters

    • X extends StepFn<default, unknown>

    Parameters

    • name: string
    • description: string
    • step: X

    Returns X

    the passed command

    Example

    class MyCommands extends CommandContext {
    doThing = this.command('do-thing', 'command example', async function doThing () {
    // implementation
    })
    }
  • Define a command subtree during construction.

    Type Parameters

    • C extends CommandContext

    Parameters

    • name: string
    • description: string
    • subtree: C

    Returns C

    the passed command subtree

    Example

    class MyCommands extends CommandContext {
    doThings = this.commands('sub', 'command subtree example', new SubCommands())
    }
    class SubCommands extends CommandContext {
    // ...
    }
  • Write the files representing the described project to the root directory.

    Returns this

    this

  • If this command tree is the default export of the process entrypoint, run the commands as specified by the process command line.

    Parameters

    • url: string
    • argv: string[] = ...

    Returns default

    Example

    export default myCommands.main(import.meta.url)
    
  • Returns null | Stats

    Boolean whether the project (as defined by fadroma.yml in root) exists

  • End the process.

    Parameters

    • code: number = 0

    Returns void

  • Parameters

    • Optional path: string

    Returns Promise<void>

  • Get the active deployment or a named deployment.

    Parameters

    • Optional name: string
    • contracts: Record<string, Partial<AnyContract>> = {}

    Returns Deployment

    Deployment|null

  • Parameters

    • message: string = ""

    Returns this

    this

  • Create a Git repository in the project directory and make an initial commit.

    Returns this

    this

  • Parameters

    • __namedParameters: any = ...

    Returns this

    this

  • Filter commands by each word from the list of arguments then pass the rest as arguments to the found command.

    Parameters

    • args: string[]

    Returns [null | CommandContext | default<default>, ...string[]]

  • Parameters

    • __namedParameters: CommandContext

    Returns void

  • Parameters

    • Rest ...names: string[]

    Returns Promise<Built[]>

  • Run a command from this command tree.

    Type Parameters

    • T

    Parameters

    • argv: string[]
    • context: any = ...

    Returns Promise<T>

  • Load and execute the default export of an ES module.

    Parameters

    • Optional script: string
    • Rest ...args: string[]

    Returns Promise<any>

  • Run one or more external commands in the project root.

    Parameters

    • Rest ...cmds: string[]

    Returns Buffer[]

  • Start an interactive REPL with this deployment as global context.

    Returns Promise<void>

    Throws

    if the node:repl and node:vm native modules are unavailable.

  • Print the current status of Fadroma, the active devnet, project, and deployment.

    Returns this

    this

  • Uploads one or more named templates, or all templates if no arguments are passed. Builds templates with missing artifacts if sources are available.

    Parameters

    • Rest ...names: string[]

    Returns Promise<(null | Uploaded)[]>

Generated using TypeDoc