Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify built-in quickstarts to a simple hello world #849

Merged
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0163474
NodeJS conflicts fixed
heitorlessa Dec 19, 2018
d53c02d
improv: Remove duplicate repo README on code tree
heitorlessa Dec 11, 2018
927d438
fix: Add correct CLI permission needed
heitorlessa Dec 11, 2018
48fc9b6
improv: Simplifies README and steps
heitorlessa Dec 11, 2018
b65bb11
improv: Simplifies Python boilerplate example and update tests
heitorlessa Dec 11, 2018
c539824
improv: Simplifies Go boilerplate example and update tests
heitorlessa Dec 11, 2018
d562ff8
fix: isBase64Encoded key now correctly set to Boolean
heitorlessa Dec 11, 2018
97210ec
fix: Address Sanath/Jacob feedback on tests folder/package.json
heitorlessa Dec 12, 2018
2a3f7d5
fix: Add functional sam build and npm run test preffix while we discu…
heitorlessa Dec 12, 2018
022b827
improv: Add event.json and remove env vars from template
heitorlessa Dec 12, 2018
777fbef
improv: Updates readme to include invoke with event.json, logs and ap…
heitorlessa Dec 12, 2018
a9323d4
improv: Simplify Java sample and update tests
heitorlessa Dec 12, 2018
b8cfc19
improv: Add Cleanup section
heitorlessa Dec 12, 2018
840e662
improv: Simplify DotNet Core sample
heitorlessa Dec 12, 2018
72208d9
fix: Trim whitespace on external link
heitorlessa Dec 12, 2018
0c6abaa
improv: Simplify Ruby and all steps work now too
heitorlessa Dec 12, 2018
68e72c9
fix: Remove unused parameters in appendix for sam deploy
heitorlessa Dec 12, 2018
1caa66d
improv: Clean up parent README
heitorlessa Dec 12, 2018
667e265
feat: Address Jacob's feedback on help message upon project build
heitorlessa Dec 19, 2018
80c68f3
feat: Move Nodejs4.3/6.10 to a legacy template, add sam build under b…
heitorlessa Dec 21, 2018
e75f808
improv: sam package no longer needs --template-file for template.yaml…
heitorlessa Dec 21, 2018
012168e
fix: Correct headings under Appendix
heitorlessa Dec 21, 2018
1b5757f
improv: python simplification after rebase
heitorlessa Dec 21, 2018
7648247
improv: go and java simplification after rebase
heitorlessa Dec 21, 2018
5b91fc4
feat: Add next step message for both strongly styped vs dynamic
heitorlessa Dec 21, 2018
6c5a656
improv: dotnet simplification after rebase
heitorlessa Dec 21, 2018
a9ab5a4
fix: Correct documentation links now pointing to AWS Docs
heitorlessa Dec 21, 2018
89f2e40
improv: ruby simplification after rebase
heitorlessa Dec 21, 2018
8340bb5
fix: revert compiled lang templates
heitorlessa Jan 7, 2019
dd1d16f
improv: Removes NodeJS 4.3 template and option
heitorlessa Jan 7, 2019
14cb8f5
Revert "improv: Removes NodeJS 4.3 template and option"
heitorlessa Jan 7, 2019
58a4f3a
fix: Remove NodeJS 4.3 option from runtime selection
heitorlessa Jan 7, 2019
f02109e
fix: Defaults legacy to 6.10
heitorlessa Jan 7, 2019
a153a30
fix: Remove --template-file from package in Ruby instructions
heitorlessa Jan 10, 2019
f13ef65
fix: jacob's feedback on nodejs legacy folder rename to 6
heitorlessa Jan 11, 2019
348ef5b
fix: jacob's feedback on package.json and appendix commands
heitorlessa Jan 11, 2019
aeaf413
fix: jacob's feedback on README and links to SAM Spec on template too
heitorlessa Jan 11, 2019
d61e3e8
fix: revert dotnet original readmes
heitorlessa Jan 11, 2019
e685a94
Merge branch 'develop' into improv/simplify-init-quickstart-templates
jfuss Jan 14, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions samcli/commands/init/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,34 @@ def do_cli(ctx, location, runtime, output_dir, name, no_input):
LOG.debug("Init command")
click.secho("[+] Initializing project structure...", fg="green")

no_build_msg = """
Project generated: {output_dir}/{name}

Steps you can take next within the project folder
===================================================
[*] Invoke Function: sam local invoke HelloWorldFunction --event event.json
[*] Start API Gateway locally: sam local start-api
""".format(output_dir=output_dir, name=name)

build_msg = """
Project generated: {output_dir}/{name}

Steps you can take next within the project folder
===================================================
[*] Install dependencies
[*] Invoke Function: sam local invoke HelloWorldFunction --event event.json
[*] Start API Gateway locally: sam local start-api
""".format(output_dir=output_dir, name=name)

no_build_step_required = (
"python", "python3.7", "python3.6", "python2.7", "nodejs", "nodejs4.3", "nodejs6.10", "nodejs8.10", "ruby2.5")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lambda has moved nodejs4.3 to depreciated, meaning creating and updating functions is no longer allows/supported. Can we match that expectation here and remove creation of Nodejs.4.3 functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, done!

next_step_msg = no_build_msg if runtime in no_build_step_required else build_msg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a custom template takes in a the --runtime arg? This message may or may not be true then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean by a custom template takes in 'a in the --runtime arg' -- This is a quick workaround until sam build fully supports all runtimes so the message will remain consistent and this will be deleted, though the workaround is flawed in the sense of as sam build supports more native runtimes this will need updating.

    no_build_step_required = (
        "python", "python3.7", "python3.6", "python2.7", "nodejs", "nodejs4.3", "nodejs6.10", "nodejs8.10", "ruby2.5")
    next_step_msg = no_build_msg if runtime in no_build_step_required else build_msg

--runtime arg is validated against the ones we support and no_build_step_required essentially borrows the ones that have sam build support.

What would you suggest instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I was getting two PRs mixed up, where I thought we were passing runtime to cookiecutter examples that are passed to --location. You can ignore this comment and can handle in the other pr that enables that.


try:
generate_project(location, runtime, output_dir, name, no_input)
# Custom templates can implement their own visual cues so let's not repeat the message
if not location:
click.secho(
"[SUCCESS] - Read {name}/README.md for further instructions on how to proceed"
.format(name=name), bold=True)
click.secho(next_step_msg, bold=True)
click.secho("Read {name}/README.md for further instructions\n".format(name=name), bold=True)
click.secho("[*] Project initialization is now complete", fg="green")
except GenerateProjectFailedError as e:
raise UserException(str(e))
4 changes: 2 additions & 2 deletions samcli/local/init/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"python2.7": os.path.join(_templates, "cookiecutter-aws-sam-hello-python"),
"python": os.path.join(_templates, "cookiecutter-aws-sam-hello-python"),
"ruby2.5": os.path.join(_templates, "cookiecutter-aws-sam-hello-ruby"),
"nodejs6.10": os.path.join(_templates, "cookiecutter-aws-sam-hello-nodejs"),
"nodejs6.10": os.path.join(_templates, "cookiecutter-aws-sam-hello-nodejs-legacy"),
"nodejs8.10": os.path.join(_templates, "cookiecutter-aws-sam-hello-nodejs"),
"nodejs4.3": os.path.join(_templates, "cookiecutter-aws-sam-hello-nodejs"),
"nodejs4.3": os.path.join(_templates, "cookiecutter-aws-sam-hello-nodejs-legacy"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove 4.3 support since Lambda does not support creating or updating functions with runtimes of nodejs4.3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

"nodejs": os.path.join(_templates, "cookiecutter-aws-sam-hello-nodejs"),
"dotnetcore2.0": os.path.join(_templates, "cookiecutter-aws-sam-hello-dotnet"),
"dotnetcore2.1": os.path.join(_templates, "cookiecutter-aws-sam-hello-dotnet"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Install `cookiecutter` command line:

## Usage

Generate a new SAM based Serverless App: `cookiecutter gh:aws-samples/cookiecutter-aws-sam-hello-dotnet`.
Generate a new SAM based Serverless App: `cookiecutter gh:aws-samples/cookiecutter-aws-sam-hello-dotnet`.

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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Create your own .NET Core solution template to use with SAM CLI. [Cookiecutter f
sam init --location gh:aws-samples/cookiecutter-aws-sam-dotnet
```

For more information and examples of how to use `sam init` run
For more information and examples of how to use `sam init` run

``` bash
sam init --help
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@

# Created by https://www.gitignore.io/api/osx,linux,python,windows

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### OSX ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Python ###
# 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/
*.egg-info/
.installed.cfg
*.egg

# 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/
.coverage
.coverage.*
.cache
.pytest_cache/
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# 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/

### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk


# End of https://www.gitignore.io/api/osx,linux,python,windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.

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.

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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Cookiecutter legacy NodeJS Hello-world for SAM based Serverless App

A cookiecutter template to create a legacy NodeJS Hello world boilerplate using [Serverless Application Model (SAM)](https://github.com/awslabs/serverless-application-model).

## Requirements

* [AWS SAM CLI](https://github.com/awslabs/aws-sam-cli)

## Usage

Generate a boilerplate template in your current project directory using the following syntax:

* **NodeJS 8**: `sam init --runtime nodejs6.10`
* **NodeJS 6**: `sam init --runtime nodejs4.3`

> **NOTE**: ``--name`` allows you to specify a different project folder name (`sam-app` is the default)

# Credits

* This project has been generated with [Cookiecutter](https://github.com/audreyr/cookiecutter)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"project_name": "Name of the project",
"runtime": "nodejs8.10"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[install]
prefix=
Loading