npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@henrist/cdk-snapshot

v1.4.0

Published

Create a snapshot of an CDK application

Downloads

161

Readme

CDK snapshot

Create a snapshot friendly version of a CDK (both v1 and v2) Cloud Assembly that can be commited as part of the source code. The goal is to have better control over structural stack changes before it is merged.

This can help automate the process of keeping CDK up-to-date while manually approving structural stack changes. It also helps reviewing code changes since the affected CloudFormation stack changes will be reviewable as well.

Usage

npm install --save-dev @henrist/cdk-snapshot rimraf

Add run-script to package.json:

{
  "scripts": {
    "cdk-snapshot": "rimraf cdk.out __snapshots__ && IS_SNAPSHOT=true npm run cdk -- synth && cdk-snapshot"
  }
}

Setting IS_SNAPSHOT means we can add conditionals in the code to stub some parts of the templates during snapshot mode. It is not needed for normal use.

Updated snapshot can now be created by running the script:

npm run cdk-snapshot

By default the cdk-snapshot script will take what it finds in cdk.out directory and transform it to a snapshot friendly version that it stores in __snapshots__.

Asserting snapshot is up-to-date

In your CI/CD-pipeline you can add:

npm run cdk-snapshot
git status
git diff --exit-code

This will cause the build to fail if the snapshot is not up-to-date.

In depth

A snapshot friendly version means an opinionated transformation of the Cloud Assembly so that "innocent" changes does not always invalidate the snapshot, to keep the maintenance burdon down.

The following is performed:

  • The cdk.out file is removed. This only contains the version of the Cloud Manifest, which we think is not neccessary to keep track of.
  • The tree.json file is removed. We think this does not contribute to the goal.
  • The asset directories is removed. Asset changes are not kept track of, and should generally not invalidate the snapshot.
  • The manifest.json file is modified to remove the Cloud Assemby version, runtime version informasjon (CDK library versions), trace output and asset details.
  • From every template *.template.json the asset details is removed.

Collapsing changes in PR by default

To make GitHub not show preview of changes to snapshots by default in a PR, you can add this to the .gitattributes file:

# See https://help.github.com/en/github/administering-a-repository/customizing-how-changed-files-appear-on-github
**/__snapshots__/** linguist-generated=true