@cats-cradle/create-artifact
TypeScript icon, indicating that this package has built-in type declarations

2.0.8 • Public • Published

@cats-cradle/create-artifact

npm version License GitHub Stars

create-artifact is a tool for bundling a single package into an artifact. It was designed to help create small fast deployable projects.

How it Works

create-artifact creates a copy of the workspace, replaces any dynamic package.json workspace:* references with the actual versions, and compresses the project as a ZIP file.

Note In CI/CD pipelines make sure to publish each workspace dependency prior to services that use it being deployed.

Usage

Example in RushJS

For each project that needs an artifact, add create-artifact as a dev dependency:

# example of how to add dev dependency in RushJS
rush add --package @cats-cradle/create-artifact --dev

Add a script command to bundle your package to the project's package.json. Make sure to replace my-package-name with the name of your package.

{
  "name": "my-package-name",
  "scripts": {
    "artifact": "create-artifact my-package-name"
  }
}

Run the script to bundle the project.

rushx artifact

Opinions

Originally, our RushJS monorepo CI/CD process started in Github CI and next went to AWS CodePipeline, Although it was quicker to get a mirror of the repository in AWS CodeCommit and trigger a CodePipeline build from pushes to main, that approach had several costly drawbacks:

  • In order for a pipeline to build from that source it must clone the entire monorepo within CodePipeline.
  • RushJS diffs to determine which projects changed are based on git histories. This meant the clone had to be a deep fetch (had to download all git histories) to work, which is an even larger file.
  • A step that built all applicable projects and download the dependencies was required.
  • It exponentially increases the amount of downloading and processing that needs to be done within a CodePipeline. This in turn can create prolonged contract variations between microservices when deploying multi service changes, which can cause system errors.
  • This exponentially increases disaster recovery time, as pipelines take longer to ship code.

Instead create-artifact was favored. It enables for a single dedicated Github CI build stage to individually bundle, compress each project changed (along with workspace and non-workspace dependencies), and put the compress object in a S3 bucket. A CodePipeline is then triggered on each object put to deploy the project. This prevents the need for a CodePipeline to fetch and process large amounts of code and drastically speeds up CI/CD pipelines, allowing engineers to ship code faster.

References

Readme

Keywords

none

Package Sidebar

Install

npm i @cats-cradle/create-artifact

Weekly Downloads

13

Version

2.0.8

License

MIT

Unpacked Size

57.7 kB

Total Files

40

Last publish

Collaborators

  • hxtree