Options
All
  • Public
  • Public/Protected
  • All
Menu

@stencila/dockta

Index

Type aliases

PythonSystemPackageLookupMap

PythonSystemPackageLookupMap: Map<string, Map<string, Map<string, Map<string, Array<string> | null>>>>

Variables

Const DOCKER_USER

DOCKER_USER: "guest" = "guest"

Const GENERATED_REQUIREMENTS_FILE

GENERATED_REQUIREMENTS_FILE: ".requirements.txt" = ".requirements.txt"

Const PACKAGE_JSON

PACKAGE_JSON: "package.json" = "package.json"

Const PACKAGE_JSON_GENERATED

PACKAGE_JSON_GENERATED: ".package.json" = ".package.json"

Const PREFERRED_UBUNTU_VERSION

PREFERRED_UBUNTU_VERSION: "19.10" = "19.10"

Const REQUEST_CACHE_DIR

REQUEST_CACHE_DIR: "/tmp/dockta-request-cache" = "/tmp/dockta-request-cache"

Let REQUEST_CACHE_INITIALISED

REQUEST_CACHE_INITIALISED: boolean = false

Const REQUIREMENTS_COMMENT_REGEX

REQUIREMENTS_COMMENT_REGEX: RegExp = /^\s*#/

Const REQUIREMENTS_EDITABLE_SOURCE_REGEX

REQUIREMENTS_EDITABLE_SOURCE_REGEX: RegExp = /^\s*-e\s*([^\s]+)\s*/

Const REQUIREMENTS_FILE_NAME

REQUIREMENTS_FILE_NAME: "requirements.txt" = "requirements.txt"

Const REQUIREMENTS_INCLUDE_PATH_REGEX

REQUIREMENTS_INCLUDE_PATH_REGEX: RegExp = /^\s*-r\s+([^\s]+)\s*/

Const REQUIREMENTS_STANDARD_REGEX

REQUIREMENTS_STANDARD_REGEX: RegExp = /^\s*([^\s]+)/

Const VERSION

VERSION: any = require('../package').version

Const app

app: Express = express()

Const compiler

compiler: DockerCompiler = new DockerCompiler(new CachingUrlFetcher())

Const docker

docker: Dockerode = new Docker()

Const generator

generator: NixGenerator = new NixGenerator(new CachingUrlFetcher(), undefined)

Const log

log: Logger = getLogger('dockta')

Const logger

logger: Logger = logga.getLogger('dockta')

Const router

router: Router = Router()

Functions

applyRegex

  • applyRegex(line: string, regex: RegExp): string | null
  • Execute the given regex against the line and return the first match. If there is no match, return null.

    Parameters

    • line: string
    • regex: RegExp

    Returns string | null

build

  • build(folder: any): Promise<void>
  • Builds a Docker image from a nixDockerfile

    Parameters

    • folder: any

      Path of the folder to build

    Returns Promise<void>

buildClassifierMap

  • buildClassifierMap(classifiers: Array<string>): Map<string, Array<string>>
  • Convert a list of classifiers to a Map between main classification and sub classification(s). e.g: ['A :: B', 'A :: C', 'D :: E'] => {'A': ['B', 'C'], 'D': ['E']}

    Parameters

    • classifiers: Array<string>

    Returns Map<string, Array<string>>

compile

  • compile(environ: void | SoftwareEnvironment | null, folder: any): void
  • Generates a default.nix and a nixDockerfile for a SoftwareEnvironment

    Parameters

    • environ: void | SoftwareEnvironment | null
    • folder: any

      Path of the folder to compile

    Returns void

error

  • error(error: Error): void
  • Print an error to stderr

    Parameters

    • error: Error

      The error to print

    Returns void

execute

  • execute(folder: any, command?: string): Promise<void>
  • Executes nix-shell inside a Docker image from nixDockerfile with a Docker data volume for /nix store

    Parameters

    • folder: any

      Path of folder to build into environment

    • Default value command: string = ""

      The command to execute

    Returns Promise<void>

extractEditableSource

  • extractEditableSource(line: string): string | null
  • Execute the REQUIREMENTS_EDITABLE_SOURCE_REGEX against a line and return the first result (or null if no match). This is used to find a requirements.txt line of a URL source (e.g. including a package from github).

    Parameters

    • line: string

    Returns string | null

extractIncludedRequirementsPath

  • extractIncludedRequirementsPath(line: string): string | null
  • Execute the REQUIREMENTS_INCLUDE_PATH_REGEX against a line and return the first result (or null if no match). This is used to find a requirements.txt line that includes another requirements file.

    Parameters

    • line: string

    Returns string | null

extractStandardRequirements

  • extractStandardRequirements(line: string): string | null
  • Execute the REQUIREMENTS_STANDARD_REGEX against a line and return the first result (or null if no match). This is used to find "standard" requirements.txt lines.

    Parameters

    • line: string

    Returns string | null

folderArg

  • folderArg(yargs: Argv): void
  • Specify the [folder] argument settings

    Parameters

    • yargs: Argv

      The yargs object

    Returns void

lineIsComment

  • lineIsComment(line: string): boolean
  • Return true if the passed in line is a requirements.txt comment (starts with "#" which might be preceded by spaces).

    Parameters

    • line: string

    Returns boolean

loggingErrorHandler

  • loggingErrorHandler(error: Error): void

output

  • output(object: any, format?: string): void
  • Print output to stdout

    Parameters

    • object: any

      The object to print

    • Default value format: string = "json"

      The format use: json or yaml

    Returns void

parseOperatingSystem

  • parseOperatingSystem(operatingSystem: string): Array<OperatingSystem>
  • Convert a string containing an operating system name into an array of OperatingSystems. In some instances the description may map to multiple OperatingSystems, e.g. "Unix" => Linux and macOS.

    Parameters

    • operatingSystem: string

    Returns Array<OperatingSystem>

parseTopics

  • parseTopics(topicsList: Array<string>): [Array<string>, Array<string>]
  • Parse an array of PyPI formatted topics into unique lists, returns a tuple of top level and optionally second level topics. This is because PyPI will repeat top level Topics in sub topics, e.g. the list might contain: ["Topic :: Game", "Topic :: Game :: Arcade"] hence "Game" is defined twice.

    Parameters

    • topicsList: Array<string>

    Returns [Array<string>, Array<string>]

run

  • run(method: string): (Anonymous function)
  • Run a method of DockerCompiler

    Parameters

    • method: string

      The method to run e.g compile, build

    Returns (Anonymous function)

splitStandardRequirementVersion

  • splitStandardRequirementVersion(requirement: string): [string, string | null]
  • Split a requirement line into name and then version. For example "package==1.0.1" => ["package", "==1.0.1"] The version specifier can be ==, <=, >=, ~=, < or >.

    Parameters

    • requirement: string

    Returns [string, string | null]

splitTopic

  • splitTopic(topics: string): Array<string>
  • Each PyPI "Topic" might contain multiple levels of categorisation separated by "::". E.g. "Topic :: Category :: Secondary Category :: Tertiary Category". This will split into an array of strings of the same length as the number of categories, i.e. ["Category", "Secondary Category", "Tertiary Category"]

    Parameters

    • topics: string

    Returns Array<string>

stringifyNode

  • stringifyNode(object: any, format: string): string
  • Convert an object to a string (maybe to go to stdout or back over HTTP)

    Parameters

    • object: any

      The object to print

    • format: string

      The format use: json or yaml

    Returns string

valueToMap

  • valueToMap(value: any): any
  • Parses a value and converts it to a Map (recursively) if it is a plain JavaScript object, otherwise just return the value

    Parameters

    • value: any

    Returns any

versionCompare

  • versionCompare(versionOne: string, versionTwo: string): 0 | 1 | -1
  • Compare semantic version numbers

    Parameters

    • versionOne: string
    • versionTwo: string

    Returns 0 | 1 | -1

who

  • who(folder: string, depth?: number, outputFunction?: Function): Promise<void>
  • List the people your project depends upon.

    Parameters

    • folder: string

      Path of folder to examine

    • Default value depth: number = 100

      Maximum depth of dependencies to traverse to find people

    • Default value outputFunction: Function = console.log

      Optional callback to receive the output. If undefined, utput goes to stdout.

    Returns Promise<void>

Generated using TypeDoc