Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduardo Rodrigues committed Mar 8, 2020
0 parents commit a431842
Show file tree
Hide file tree
Showing 8 changed files with 357 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[run]
branch = True

[report]
fail_under = 100
136 changes: 136 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

.DS_Store
.idea/
.vscode/
*.tar.gz

# We want to allow the tests/lib folder
!tests/lib

# Node.js
node_modules/
coverage/
24 changes: 24 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[MASTER]

ignore=CVS,models.py,handlers.py
jobs=1
persistent=yes

[MESSAGES CONTROL]

disable=
missing-docstring, # not everything needs a docstring
fixme, # work in progress
bad-continuation, # clashes with black
too-few-public-methods, # triggers when inheriting
ungrouped-imports, # clashes with isort
duplicate-code, # broken, setup.py

[BASIC]

good-names=e,ex,f,fp,i,j,k,n,_

[FORMAT]

indent-string=' '
max-line-length=88
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Eduardo Rodrigues

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.
7 changes: 7 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include README.md
include LICENSE

graft python/rpdk/typescript

# last rule wins, put excludes last
global-exclude __pycache__ *.py[co] .DS_Store
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# DEVELOPER PREVIEW (COMMUNITY DRIVEN)

We're excited to share our progress with adding new languages to the CloudFormation CLI! This plugin is an early preview prepared by the community, and not ready for production use.

## AWS CloudFormation Resource Provider TypeScript Plugin

The CloudFormation CLI (cfn) allows you to author your own resource providers that can be used by CloudFormation.

This plugin library helps to provide TypeScript runtime bindings for the execution of your providers by CloudFormation.

Usage
-----

If you are using this package to build resource providers for CloudFormation, install the [CloudFormation CLI TypeScript Plugin](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin) - this will automatically install the the [CloudFormation CLI](https://github.com/aws-cloudformation/cloudformation-cli)! A Python virtual environment is recommended.

**Prerequisites**

- Python version 3.6 or above
- Your choice of TypeScript IDE

**Installation**

```shell
pip3 install git+https://github.com/eduardomourar/cloudformation-cli-typescript-plugin.git#egg=cloudformation-cli-typescript-plugin
```

Refer to the [CloudFormation CLI User Guide](https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-types.html) for the [CloudFormation CLI](https://github.com/aws-cloudformation/cloudformation-cli) for usage instructions.


Development
-----------

For changes to the plugin, a Python virtual environment is recommended. Check out and install the plugin in editable mode:

```shell
python3 -m venv env
source env/bin/activate
pip3 install -e /path/to/cloudformation-cli-typescript-plugin
```

You may also want to check out the [CloudFormation CLI](https://github.com/aws-cloudformation/cloudformation-cli) if you wish to make edits to that. In this case, installing them in one operation works well:

```shell
pip3 install \
-e /path/to/cloudformation-cli \
-e /path/to/cloudformation-cli-typescript-plugin
```

That ensures neither is accidentally installed from PyPI.

Linting and running unit tests is done via [pre-commit](https://pre-commit.com/), and so is performed automatically on commit after being installed (`pre-commit install`). The continuous integration also runs these checks. Manual options are available so you don't have to commit:

```shell
# run all hooks on all files, mirrors what the CI runs
pre-commit run --all-files
# run unit tests only. can also be used for other hooks, e.g. black, flake8, pylint-local
pre-commit run pytest-local
```

License
-------

This library is licensed under the MIT License.
42 changes: 42 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[metadata]
license_file = LICENSE
description-file = README.md

[flake8]
exclude =
.git,
__pycache__,
build,
dist,
*.pyc,
*.egg-info,
.cache,
.eggs,
.tox
max-complexity = 10
max-line-length = 88
select = C,E,F,W,B,B950
# C812, C815, W503 clash with black, F723 false positive
ignore = E501,C812,C815,C816,W503,F723

[isort]
line_length = 88
indent = ' '
multi_line_output = 3
default_section = FIRSTPARTY
skip = env
include_trailing_comma = true
combine_as_imports = True
force_grid_wrap = 0
known_first_party = rpdk
known_third_party = boto3,botocore,jinja2,jsonschema,werkzeug,yaml,requests

[tool:pytest]
# can't do anything about 3rd party modules, so don't spam us
filterwarnings =
ignore::DeprecationWarning:botocore
ignore::DeprecationWarning:werkzeug
ignore::DeprecationWarning:yaml

[mypy-setuptools] # don't want to stub external libraries for now
ignore_missing_imports = True
59 changes: 59 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python
"""Typescript language support for the CloudFormation CLI"""
import os.path
import re

from setuptools import setup

HERE = os.path.abspath(os.path.dirname(__file__))


def read(*parts):
with open(os.path.join(HERE, *parts), "r", encoding="utf-8") as fp:
return fp.read()


# https://packaging.python.org/guides/single-sourcing-package-version/
def find_version(*file_paths):
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")


setup(
name="cloudformation-cli-typescript-plugin",
version=find_version("python", "rpdk", "typescript", "__init__.py"),
description=__doc__,
long_description=read("README.md"),
author="eduardomourar",
url="https://github.com/eduardomourar/cloudformation-cli-typescript-plugin",
packages=["rpdk.typescript"],
package_dir={"": "python"},
# package_data -> use MANIFEST.in instead
include_package_data=True,
zip_safe=True,
python_requires=">=3.6",
install_requires=["cloudformation-cli>=0.1,<0.2", "docker>=3.7,<3.8"],
entry_points={
"rpdk.v1.languages": [
"typescript = rpdk.typescript.codegen:TypescriptLanguagePlugin",
]
},
license="MIT",
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT/X Consortium License",
"Natural Language :: English",
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Code Generators",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
],
keywords="Amazon Web Services AWS CloudFormation",
)

0 comments on commit a431842

Please sign in to comment.