-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89f2e40
commit 8340bb5
Showing
26 changed files
with
567 additions
and
442 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
samcli/local/init/templates/cookiecutter-aws-sam-hello-dotnet/Pipfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[[source]] | ||
|
||
url = "https://pypi.python.org/simple" | ||
verify_ssl = true | ||
name = "pypi" | ||
|
||
[packages] | ||
|
||
[dev-packages] | ||
|
||
cookiecutter = "*" | ||
pytest-cookies = "*" | ||
pytest = "*" |
35 changes: 28 additions & 7 deletions
35
samcli/local/init/templates/cookiecutter-aws-sam-hello-dotnet/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,42 @@ | ||
# Cookiecutter DotNet Core Hello-world for SAM based Serverless App | ||
# Cookiecutter SAM for dotNet based Lambda functions | ||
|
||
A cookiecutter template to create a DotNet Core Hello world boilerplate using [Serverless Application Model (SAM)](https://github.com/awslabs/serverless-application-model). | ||
This is a [Cookiecutter](https://github.com/audreyr/cookiecutter) template to create a Serverless Hello World App based on Serverless Application Model (SAM) and dotnet 2.0. | ||
|
||
It is important to note that you should not try to `git clone` this project but use `cookiecutter` CLI instead as ``{{cookiecutter.project_name}}`` will be rendered based on your input and therefore all variables and files will be rendered properly. | ||
|
||
## Requirements | ||
|
||
* [AWS SAM CLI](https://github.com/awslabs/aws-sam-cli) | ||
Install `cookiecutter` command line: | ||
|
||
**Pip users**: | ||
|
||
* `pip install cookiecutter` | ||
|
||
**Homebrew users**: | ||
|
||
* `brew install cookiecutter` | ||
|
||
**Windows or Pipenv users**: | ||
|
||
* `pipenv install cookiecutter` | ||
|
||
**NOTE**: [`Pipenv`](https://github.com/pypa/pipenv) is the new and recommended Python packaging tool that works across multiple platforms and makes Windows a first-class citizen. | ||
|
||
## Usage | ||
|
||
Generate a boilerplate template in your current project directory using the following syntax: | ||
Generate a new SAM based Serverless App: `cookiecutter gh:aws-samples/cookiecutter-aws-sam-hello-dotnet`. | ||
|
||
* **DotNet Core 2.1**: `sam init --runtime dotnetcore2.1` | ||
* **DotNet Core 2.0**: `sam init --runtime dotnetcore2.0` | ||
You'll be prompted a few questions to help this cookiecutter template to scaffold this project and after its completed you should see a new folder at your current path with the name of the project you gave as input. | ||
|
||
> **NOTE**: ``--name`` allows you to specify a different project folder name (`sam-app` is the default) | ||
**NOTE**: After you understand how cookiecutter works (cookiecutter.json, mainly), you can fork this repo and apply your own mechanisms to accelerate your development process and this can be followed for any programming language and OS. | ||
|
||
|
||
# Credits | ||
|
||
* This project has been generated with [Cookiecutter](https://github.com/audreyr/cookiecutter) | ||
|
||
|
||
License | ||
------- | ||
|
||
This project is licensed under the terms of the [MIT License with no attribution](/LICENSE) |
47 changes: 47 additions & 0 deletions
47
samcli/local/init/templates/cookiecutter-aws-sam-hello-dotnet/tests/test_cookiecutter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
Tests cookiecutter baking process and rendered content | ||
""" | ||
|
||
|
||
def test_project_tree(cookies): | ||
result = cookies.bake(extra_context={ | ||
'project_name': 'hello sam' | ||
}) | ||
assert result.exit_code == 0 | ||
assert result.exception is None | ||
assert result.project.basename == 'hello sam' | ||
assert result.project.isdir() | ||
assert result.project.join('.gitignore').isfile() | ||
assert result.project.join('template.yaml').isfile() | ||
assert result.project.join('README.md').isfile() | ||
assert result.project.join('src').isdir() | ||
assert result.project.join('test').isdir() | ||
assert result.project.join('src', 'HelloWorld').isdir() | ||
assert result.project.join( | ||
'src', 'HelloWorld', 'HelloWorld.csproj').isfile() | ||
assert result.project.join('src', 'HelloWorld', 'Program.cs').isfile() | ||
assert result.project.join( | ||
'src', 'HelloWorld', 'aws-lambda-tools-defaults.json').isfile() | ||
assert result.project.join( | ||
'test', 'HelloWorld.Test', 'FunctionTest.cs').isfile() | ||
assert result.project.join( | ||
'test', 'HelloWorld.Test', 'HelloWorld.Tests.csproj').isfile() | ||
|
||
|
||
def test_app_content(cookies): | ||
result = cookies.bake(extra_context={'project_name': 'my_lambda'}) | ||
app_file = result.project.join('src', 'HelloWorld', 'Program.cs') | ||
app_content = app_file.readlines() | ||
app_content = ''.join(app_content) | ||
|
||
contents = ( | ||
"GetCallingIP", | ||
"GetStringAsync", | ||
"location", | ||
"message", | ||
"hello world", | ||
"StatusCode" | ||
) | ||
|
||
for content in contents: | ||
assert content in app_content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 0 additions & 62 deletions
62
...init/templates/cookiecutter-aws-sam-hello-dotnet/{{cookiecutter.project_name}}/event.json
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.