diff --git a/samcli/commands/init/__init__.py b/samcli/commands/init/__init__.py index a5915cb24e..7186978c0f 100644 --- a/samcli/commands/init/__init__.py +++ b/samcli/commands/init/__init__.py @@ -8,7 +8,7 @@ from samcli.cli.main import pass_context, common_options from samcli.commands.exceptions import UserException -from samcli.local.common.runtime_template import INIT_RUNTIMES, SUPPORTED_DEP_MANAGERS, DEFAULT_RUNTIME +from samcli.local.common.runtime_template import INIT_RUNTIMES, SUPPORTED_DEP_MANAGERS from samcli.local.init import generate_project from samcli.local.init.exceptions import GenerateProjectFailedError from samcli.lib.telemetry.metrics import track_command @@ -19,7 +19,7 @@ @click.command(context_settings=dict(help_option_names=[u'-h', u'--help'])) @click.option('-l', '--location', help="Template location (git, mercurial, http(s), zip, path)") -@click.option('-r', '--runtime', type=click.Choice(INIT_RUNTIMES), default=DEFAULT_RUNTIME, +@click.option('-r', '--runtime', type=click.Choice(INIT_RUNTIMES), default="nodejs8.10", help="Lambda Runtime of your app") @click.option('-d', '--dependency-manager', type=click.Choice(SUPPORTED_DEP_MANAGERS), default=None, help="Dependency manager of your Lambda runtime", required=False) diff --git a/samcli/local/common/runtime_template.py b/samcli/local/common/runtime_template.py index 3535553160..ef67fe93ea 100644 --- a/samcli/local/common/runtime_template.py +++ b/samcli/local/common/runtime_template.py @@ -13,12 +13,10 @@ _init_path = str(pathlib.Path(os.path.dirname(__file__)).parent) _templates = os.path.join(_init_path, 'init', 'templates') - -# Note(TheSriram): The ordering of the runtimes list per language is based on the latest to oldest. RUNTIME_DEP_TEMPLATE_MAPPING = { "python": [ { - "runtimes": ["python3.7", "python3.6", "python2.7"], + "runtimes": ["python2.7", "python3.6", "python3.7"], "dependency_manager": "pip", "init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-python"), "build": True @@ -34,7 +32,7 @@ ], "nodejs": [ { - "runtimes": ["nodejs10.x", "nodejs8.10"], + "runtimes": ["nodejs8.10", "nodejs10.x"], "dependency_manager": "npm", "init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-nodejs"), "build": True @@ -48,7 +46,7 @@ ], "dotnet": [ { - "runtimes": ["dotnetcore2.1", "dotnetcore2.0", "dotnetcore1.0", "dotnetcore"], + "runtimes": ["dotnetcore", "dotnetcore1.0", "dotnetcore2.0", "dotnetcore2.1"], "dependency_manager": "cli-package", "init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-dotnet"), "build": True @@ -83,6 +81,3 @@ RUNTIMES = set(itertools.chain(*[c['runtimes'] for c in list( itertools.chain(*(RUNTIME_DEP_TEMPLATE_MAPPING.values())))])) INIT_RUNTIMES = RUNTIMES.union(RUNTIME_DEP_TEMPLATE_MAPPING.keys()) - -# NOTE(TheSriram): Default Runtime Choice when runtime is not chosen -DEFAULT_RUNTIME = RUNTIME_DEP_TEMPLATE_MAPPING['nodejs'][0]['runtimes'][0] diff --git a/samcli/local/init/__init__.py b/samcli/local/init/__init__.py index 84ec28c6b9..89e4bc52c9 100644 --- a/samcli/local/init/__init__.py +++ b/samcli/local/init/__init__.py @@ -14,7 +14,7 @@ def generate_project( - location=None, runtime="nodejs10.x", dependency_manager=None, + location=None, runtime="nodejs", dependency_manager=None, output_dir=".", name='sam-sample-app', no_input=False): """Generates project using cookiecutter and options given @@ -51,9 +51,11 @@ def generate_project( for mapping in list(itertools.chain(*(RUNTIME_DEP_TEMPLATE_MAPPING.values()))): if runtime in mapping['runtimes'] or any([r.startswith(runtime) for r in mapping['runtimes']]): - if not dependency_manager or dependency_manager == mapping['dependency_manager']: + if not dependency_manager: template = mapping['init_location'] break + elif dependency_manager == mapping['dependency_manager']: + template = mapping['init_location'] if not template: msg = "Lambda Runtime {} does not support dependency manager: {}".format(runtime, dependency_manager)