Module ammcore.pkg.builder

Build script API.

Index

Class

PackageArchiver

Creates and unpacks package archives.

PackageBuilder

Manages files that will end up in the final package distribution.

Class

class ammcore.pkg.builder.PackageArchiver : ammcore.class.Base

Creates and unpacks package archives.

New(self: <T: ammcore.pkg.builder.PackageArchiver>, name: string, version: ammcore.pkg.version.Version) <T: ammcore.pkg.builder.PackageArchiver>
Parameters:
name: string

Name of the package that is being built.

version: ammcore.pkg.version.Version

Version of the package that is being built.

FromArchive(self: ammcore.pkg.builder.PackageArchiver, name: string, version: ammcore.pkg.version.Version, archive: string) ammcore.pkg.builder.PackageArchiver

Construct builder from a packaged archive data (i.e. the result of build()).

Parameters:
  • name (string) – name of the package.

  • version (ammcore.pkg.version.Version) – version of the package.

  • archive (string) – data of the package archive.

unpack(self: ammcore.pkg.builder.PackageArchiver, pkgRoot: string)

Unpack the package to the given directory.

Parameters:

pkgRoot (string) – where to write package files.

protected _verify(self: ammcore.pkg.builder.PackageArchiver)

Verify package integrity and throw an error if it’s beroken.

getCode(self: ammcore.pkg.builder.PackageArchiver) code: table<string, string>

Get read-only view of table that maps package filenames to their contents.

Returns:

code (table<string, string>) – table with all files in the package.

build(self: ammcore.pkg.builder.PackageArchiver) archive: string

Compile the package distribution and return it as a string.

Returns:

archive (string) – data of the package archive.

class ammcore.pkg.builder.PackageBuilder : ammcore.pkg.builder.PackageArchiver

Manages files that will end up in the final package distribution.

New(self: <T: ammcore.pkg.builder.PackageBuilder>, name: string, version: ammcore.pkg.version.Version, devRoot: string, pkgRoot: string) <T: ammcore.pkg.builder.PackageBuilder>
devRoot: string

Root directory of the dev installation.

pkgRoot: string

Root directory of the package.

copyDir(self: ammcore.pkg.builder.PackageBuilder, src: string, dst: string, override?: boolean)

Copy a directory to the package.

Parameters:
  • src (string) – directory source, relative to the development root.

  • dst (string) – directory destination, relative to the package root.

  • override? (boolean) – whether to override existing files.

copyFile(self: ammcore.pkg.builder.PackageBuilder, src: string, dst: string, override?: boolean)

Copy a file to the package.

Parameters:
  • src (string) – file source, relative to the dev root.

  • dst (string) – file destination, relative to the package root.

addFile(self: ammcore.pkg.builder.PackageBuilder, dst: string, contents: string, override?: boolean)

Add a file to the package.

Parameters:
  • dst (string) – file destination, relative to the package root.

  • contents (string) – file contents.

clearAllFiles(self: ammcore.pkg.builder.PackageBuilder)

Remove all files from archive.

addDirectoryIndex(self: ammcore.pkg.builder.PackageBuilder, dst: string, dir: string, override: any)

Add a json file containing a table with all paths located in a certain directory.

@override boolean?

Parameters:
  • dst (string) – file destination, relative to the package root.

  • dir (string) – indexed directory root, relative to the package root.