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

cfnfmt

v0.1.3

Published

CloudFormation template style formatter

Downloads

12

Readme

cfnfmt

:construction: WORK IN PROGRESS

cfnfmt is an AWS CloudFormation template style formatter. It identifies and corrects things like line spacing, key ordering and other items which could be considered personal preference whilst preserving comments.

It does not check or determine the validity of resource property syntax, for that you should use cfn-lint.

Installation

npm i -g cfnfmt

Usage

Basic usage:

cfnfmt template.yml other-template.yaml

You can also format all templates in a whole directory:

cfnfmt .

Configuration

cfnfmt uses a set of rules to allow you to customize your template styling preference. Each rule is independent from the others, and can be enabled, disabled or changed. All these settings can be gathered in a configuration file.

To use a custom configuration file, use the -c option:

cfnfmt -c config.yaml template.yaml

If -c is not provided, cfnfmt will look for a configuration file in the following locations (by order of preference):

  • .cfnfmt, .cfnfmt.yaml or .cfnfmt.yml in the current working directory
  • the file referenced by $CFNFMT_CONFIG_FILE, if set
  • ~/.config/cfnfmt/config

Finally, if no config file is found the default configuration is applied.

Default Configuration

template-filenames:
- "*.yaml"
- "*.yml"
- "*.template"
rules:
  aws-template-format-version: true
  key-indent-level: 2
  section-order:
  - "AWSTemplateFormatVersion"
  - "Description"
  - "Metadata"
  - "Parameters"
  - "Mappings"
  - "Conditions"
  - "Transform"
  - "Resources"
  - "Outputs"
  resource-key-order:
  - "DependsOn"
  - "Condition"
  - "CreationPolicy"
  - "UpdatePolicy"
  - "UpdateReplacePolicy"
  - "DeletionPolicy"
  - "Type"
  - "Metadata"
  - "Properties"

When specifying configuration with the -c option, the default configuration values are used for any values not explicitly defined.

Template Filenames

You may set the matchable filenames using the template-filenames property within the configuration file. This property will only be considered if the input path is a directory. Files that do not contain a Resources key will be skipped.

Rules

The following settings can be set in the rules section of the configuration file:

aws-template-format-version

If set to true, the template is checked for the presence of the AWSTemplateFormatVersion key. If not found, the key will be added with the 2010-09-09 value.

key-indent-level

An integer representing the number of spaces to indent map/object keys at, relative to its parent key. Lists/sequences are not affected by this setting. Set to false to ignore key indenting.

section-order

A list of sections in the order it should be rearranged to. Not all defined sections have to be defined in the template. Any sections not defined by this list will retain their existing order. Set to false to retain existing order.

resource-key-order

A list of keys in the order they should be rearranged to within resources. Not all defined keys have to be defined in the resource. Any keys not defined by this list will retain their existing order. Set to false to retain existing order.

new-lines-at-end-of-file

An integer representing the desired number of newlines at the end of the file (usually set to 0 or 1). Defaults to 1.