Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mirrajabi committed Dec 2, 2023
0 parents commit 2c49985
Show file tree
Hide file tree
Showing 23 changed files with 15,791 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
insert_final_newline = true
1 change: 1 addition & 0 deletions .eslintignore
@@ -0,0 +1 @@
dist/
6 changes: 6 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,6 @@
{
"extends": "./node_modules/gts/",
"rules": {
"node/no-unpublished-import": "off"
}
}
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,38 @@
name: release
on:
workflow_call:
secrets:
npm_access_token:
description: Secret for getting JFrog credentials
required: true
push:
branches:
- fix-*
- feature-*
- main

jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm ci
- name: Release
run: npx --yes semantic-release
36 changes: 36 additions & 0 deletions .gitignore
@@ -0,0 +1,36 @@
node_modules/

# Editors
.vscode
.idea
*.iml

# OS metadata
.DS_Store
Thumbs.db

# Build
build/
dist/

# env files
.env.local
.env.*.local
.env

# misc
npm-debug.log*
yarn-debug.log*
yarn-error.log*
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/

# caches and test results
.out/

# tests
coverage/
test-results.xml
test-reports/
17 changes: 17 additions & 0 deletions .npmignore
@@ -0,0 +1,17 @@
.github/
.out/
assets/
coverage/
dist/
node_modules/
src/
test/
test-reports/
.editorconfig
.eslintignore
.eslintrc.*
jest.config.js
tsconfig.json
.prettierrc*
prepublish.js
.releaserc.json
3 changes: 3 additions & 0 deletions .prettierrc.js
@@ -0,0 +1,3 @@
module.exports = {
...require('gts/.prettierrc.json')
}
49 changes: 49 additions & 0 deletions .releaserc.json
@@ -0,0 +1,49 @@
{
"branches": [
{
"name": "main",
"prerelease": false
},
{
"name": "feature-*",
"prerelease": true
},
{
"name": "fix-*",
"prerelease": true
}
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"releaseRules": [
{
"type": "chore",
"scope": "RELEASE",
"release": "patch"
}
]
}
],
[
"@semantic-release/release-notes-generator"
],
[
"@semantic-release/npm"
],
[
"@semantic-release/git",
{
"assets": []
}
],
[
"@semantic-release/github",
{
"successComment": false,
"failTitle": false
}
]
]
}
9 changes: 9 additions & 0 deletions LICENCE
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) Mad Mirrajabi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
65 changes: 65 additions & 0 deletions README.md
@@ -0,0 +1,65 @@
# CloudFormation Template Renderer

This is a simple tool that leverages AWS Application Composer's renderer to render CloudFormation templates. Since **CDK** also generates CloudFormation templates, this tool can be used to render the stacks created by CDK projects as well.

**Beta notice**: This tool is currently in beta. Please report any issues you encounter. also read the [Good to know](#good-to-know) section.

## Example output

Below image is the output of [this template](https://github.com/awslabs/aws-cloudformation-templates/blob/master/community/solutions/StaticWebSiteWithPipeline/stacks/pipeline.json).
![Example output](./assets/example.png)

## Installation

You can install it using npm:

```bash
# To use it as a CLI tool
npm install -g cf-render

# To use it as a library
npm install cf-render
```

## Usage - CLI

```bash
Usage: cf-render [options]

CLI to render AWS CloudFormation templates

Options:
-V, --version output the version number
-i, --input <template-path> Path to the cloudFormation template to render
-o, --output <image-path> Path to the output image. Must end with .png
-h, --help display help for command

Examples:
$ cf-render --input template.json --output template.png
$ cf-render -i template.yaml -o template.png
```

## Usage - Library

```typescript
import { renderTemplate } from 'cf-render';

...
await renderTemplate({
inputPath: './template.yaml',
outputPath: './template.png'
});
...
```

## Roadmap

- [x] Put it out there!
- [ ] Add support for screen size configuration
- [ ] Trim the output image. Currently the canvas area is too large.

## Good to know

- This tool uses the publicly available [AWS Application Composer instance](https://ide-toolkits.app-composer.aws.dev/index.html) to render the templates. I'm not aware of any legal issues with using this public instance. If you represent AWS and you have any issues with this tool, please let me know but just don't tell Jeff.
- Changes to the Application Composer's web UI might affect this library's functionality. If you encounter any issues, please report them. **If your life depends on generating diagrams from CloudFormation templates, you might want to consider using a different tool.** Otherwise, you can help improving this tool.
- You need to have an internet connection to use this tool.
Binary file added assets/example.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions jest.config.js
@@ -0,0 +1,25 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: [
'<rootDir>/src/**/__tests__/**/*.ts?(x)',
'<rootDir>/(test|src)/**/*(*.)@(spec|test).ts?(x)',
],
clearMocks: true,
collectCoverage: true,
coverageReporters: ['json', 'lcov', 'clover', 'cobertura', 'text'],
coverageDirectory: 'coverage',
coveragePathIgnorePatterns: ['/node_modules/'],
testPathIgnorePatterns: ['/node_modules/'],
watchPathIgnorePatterns: ['/node_modules/'],
reporters: [
'default',
[
'jest-junit',
{
outputDirectory: 'test-reports',
},
],
],
};

0 comments on commit 2c49985

Please sign in to comment.