Working with packages - Amazon CodeCatalyst

Working with packages

A package is a bundle that includes both software and the metadata that is required to install the software and resolve any dependencies. CodeCatalyst supports the npm package format.

A package consists of:

  • A name (for example, webpack is the name of a popular npm package)

  • An optional namespace (for example, @types in @types/node)

  • A set of versions (for example, 1.0.0, 1.0.1, 1.0.2)

  • Package-level metadata (for example, npm dist tags)

In CodeCatalyst, you can publish packages to and consume packages from CodeCatalyst package repositories in your workflows. You can configure a build or test action with a CodeCatalyst package repository to automatically configure an action's npm client to push and pull packages from the specified repository.

For more information about packages, see Packages in CodeCatalyst.

Note

Currently, build and test actions support CodeCatalyst package repositories.

Using CodeCatalyst package repositories in workflows

In CodeCatalyst, you can add a CodeCatalyst package repository to your build and test actions in your workflow. Your package repository must be configured with a package format, such as npm. You can also choose to include a sequence of scopes for your selected package repository.

Use the following instructions to specify a package configuration to use with a workflow action.

Visual
To specify the package configuration that an action will use (visual editor)
  1. Open the CodeCatalyst console at https://codecatalyst.aws/.

  2. Choose your project.

  3. In the navigation pane, choose CI/CD, and then choose Workflows.

  4. Choose the name of your workflow. You can filter by the source repository or branch name where the workflow is defined, or filter by workflow name.

  5. Choose Edit.

  6. Choose Visual.

  7. In the workflow diagram, choose the action with which you want to configure with a package repository.

  8. Choose Packages.

  9. From the Add configuration dropdown menu, choose the package configuration you want to use with your workflow actions.

  10. Choose Add package repository.

  11. In the Package repository dropdown menu, specify the name of your CodeCatalyst package repository that you want the action to use.

    For more information about package repositories, see Package repositories.

  12. (Optional) In Scopes - optional, specify a sequence of scopes that you want to define in your package registry.

    When defining scopes, the specified package repository is configured as the registry for all listed scopes. If a package with the scope is requested through the npm client, it will use that repository instead of the default. Each scope name must be prefixed with "@".

    If Scopes is omitted, then the specified package repository is configured as the default registry for all packages used by the action.

    For more information about scopes, see Package namespaces and Scoped packages.

  13. Choose Add.

  14. (Optional) Choose Validate to validate the workflow's YAML code before committing.

  15. Choose Commit, enter a commit message, and choose Commit again.

YAML
To specify the package configuration that an action will use (YAML editor)
  1. Open the CodeCatalyst console at https://codecatalyst.aws/.

  2. Choose your project.

  3. In the navigation pane, choose CI/CD, and then choose Workflows.

  4. Choose the name of your workflow. You can filter by the source repository or branch name where the workflow is defined, or filter by workflow name.

  5. Choose Edit.

  6. Choose YAML.

  7. In an action, add code similar to the following:

    action-name: Configuration: Packages: NpmConfiguration: PackageRegistries: - PackagesRepository: package-repository Scopes: - "@scope"

    For more information, see the description of the Packages property in Build and test action reference for your action.

  8. (Optional) Choose Validate to validate the workflow's YAML code before committing.

  9. Choose Commit, enter a commit message, and choose Commit again.

Examples of using packages in workflows

The following examples show how to reference packages in the workflow definition file.

Example: Defining packages with NpmConfiguration

The following example shows how to define a package with NpmConfiguration in your workflow definition file.

Actions: Build: Identifier: aws/build-beta@v1 Configuration: Packages: NpmConfiguration: PackageRegistries: - PackagesRepository: main-repo - PackagesRepository: scoped-repo Scopes: - "@scope1"

This example configures the npm client as such:

default: main-repo @scope1: scoped-repo

In this example, there are two repositories defined. The default registry is set as main-repo as it is defined without a scope. Scope @scope1 is configured in PackageRegistries for scoped-repo.

Example: Overriding the default registry

The following example shows you how to override the default registry.

NpmConfiguration: PackageRegistries: - PackagesRepository: my-repo-1 - PackagesRepository: my-repo-2 - PackagesRepository: my-repo-3

This example configures the npm client as such:

default: my-repo-3

If you specify multiple default repositories, the last repository will take priority. In this example, the last repository listed is my-repo-3, meaning that npm will connect to my-repo-3. This overrides the repositories my-repo-1 and my-repo-2.

Example: Overriding scopes in your package registry

The following example shows you how to override a scope in your package registry.

NpmConfiguration: PackageRegistries: - PackagesRepository: my-default-repo - PackagesRepository: my-repo-1 Scopes: - "@scope1" - "@scope2" - PackagesRepository: my-repo-2 Scopes: - "@scope2"

This example configures the npm client as such:

default: my-default-repo @scope1: my-repo-1 @scope2: my-repo-2

If you include overriding scopes, the last repository will take priority. In this example, the last time that scope @scope2 is configured in PackageRegistries is for my-repo-2. This overrides the scope @scope2 configured for my-repo-1.