From 1f62ae45888e908bc93afd1b8e047288deb2f964 Mon Sep 17 00:00:00 2001 From: "Edgar R. M" Date: Wed, 16 Aug 2023 08:56:36 -0600 Subject: [PATCH] feat(templates): Add email field and use human-readable questions in templates (#1905) --- cookiecutter/mapper-template/cookiecutter.json | 12 +++++++++++- .../{{cookiecutter.mapper_id}}/pyproject.toml | 2 +- cookiecutter/tap-template/cookiecutter.json | 14 +++++++++++++- .../{{cookiecutter.tap_id}}/pyproject.toml | 2 +- cookiecutter/target-template/cookiecutter.json | 13 ++++++++++++- .../{{cookiecutter.target_id}}/pyproject.toml | 2 +- docs/dev_guide.md | 18 ++++++++++++++++++ e2e-tests/cookiecutters/mapper-base.json | 1 + e2e-tests/cookiecutters/tap-graphql-jwt.json | 1 + e2e-tests/cookiecutters/tap-other-custom.json | 1 + .../cookiecutters/tap-rest-api_key-github.json | 1 + .../cookiecutters/tap-rest-basic_auth.json | 1 + .../cookiecutters/tap-rest-bearer_token.json | 1 + e2e-tests/cookiecutters/tap-rest-custom.json | 1 + e2e-tests/cookiecutters/tap-rest-jwt.json | 1 + e2e-tests/cookiecutters/tap-rest-oauth2.json | 1 + e2e-tests/cookiecutters/tap-sql-custom.json | 1 + e2e-tests/cookiecutters/target-per_record.json | 1 + e2e-tests/cookiecutters/target-sql.json | 1 + 19 files changed, 69 insertions(+), 6 deletions(-) diff --git a/cookiecutter/mapper-template/cookiecutter.json b/cookiecutter/mapper-template/cookiecutter.json index 267e45fb9..c42b1cf06 100644 --- a/cookiecutter/mapper-template/cookiecutter.json +++ b/cookiecutter/mapper-template/cookiecutter.json @@ -1,9 +1,19 @@ { "name": "MyMapperName", "admin_name": "FirstName LastName", + "admin_email": "firstname.lastname@example.com", "mapper_id": "mapper-{{ cookiecutter.name.lower() }}", "library_name": "{{ cookiecutter.mapper_id.replace('-', '_') }}", "variant": "None (Skip)", "include_ci_files": ["GitHub", "None (Skip)"], - "license": ["Apache-2.0"] + "license": ["Apache-2.0"], + "__prompts__": { + "name": "The name of the mapper, in CamelCase", + "admin_name": "Provide your [bold yellow]full name[/]", + "admin_email": "Provide your [bold yellow]email[/]", + "mapper_id": "The ID of the tap, in kebab-case", + "library_name": "The name of the library, in snake_case. This is how the library will be imported in Python.", + "include_ci_files": "Whether to include CI files for a common CI services", + "license": "The license for the project" + } } diff --git a/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/pyproject.toml b/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/pyproject.toml index 62fd97284..36c541fca 100644 --- a/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/pyproject.toml +++ b/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/pyproject.toml @@ -7,7 +7,7 @@ name = "{{cookiecutter.mapper_id}}" version = "0.0.1" description = "`{{cookiecutter.mapper_id}}` is a Singer mapper {{cookiecutter.name}}, built with the Meltano Singer SDK." readme = "README.md" -authors = ["{{ cookiecutter.admin_name }}"] +authors = ["{{ cookiecutter.admin_name }} <{{ cookiecutter.admin_email }}>"] keywords = [ "ELT", "Mapper", diff --git a/cookiecutter/tap-template/cookiecutter.json b/cookiecutter/tap-template/cookiecutter.json index 8da7a099b..e297aae54 100644 --- a/cookiecutter/tap-template/cookiecutter.json +++ b/cookiecutter/tap-template/cookiecutter.json @@ -1,6 +1,7 @@ { "source_name": "MySourceName", "admin_name": "FirstName LastName", + "admin_email": "firstname.lastname@example.com", "tap_id": "tap-{{ cookiecutter.source_name.lower() }}", "library_name": "{{ cookiecutter.tap_id.replace('-', '_') }}", "variant": "None (Skip)", @@ -14,5 +15,16 @@ "Custom or N/A" ], "include_ci_files": ["GitHub", "None (Skip)"], - "license": ["Apache-2.0"] + "license": ["Apache-2.0"], + "__prompts__": { + "source_name": "The name of the source, in CamelCase", + "admin_name": "Provide your [bold yellow]full name[/]", + "admin_email": "Provide your [bold yellow]email[/]", + "tap_id": "The ID of the tap, in kebab-case", + "library_name": "The name of the library, in snake_case. This is how the library will be imported in Python.", + "stream_type": "The type of stream the source provides", + "auth_method": "The [bold red]authentication[/] method used by the source, for REST and GraphQL sources", + "include_ci_files": "Whether to include CI files for a common CI services", + "license": "The license for the project" + } } diff --git a/cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml index 6c1e88fbf..46ffb61f7 100644 --- a/cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml +++ b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml @@ -7,7 +7,7 @@ name = "{{cookiecutter.tap_id}}" version = "0.0.1" description = "`{{cookiecutter.tap_id}}` is a Singer tap for {{cookiecutter.source_name}}, built with the Meltano Singer SDK." readme = "README.md" -authors = ["{{ cookiecutter.admin_name }}"] +authors = ["{{ cookiecutter.admin_name }} <{{ cookiecutter.admin_email }}>"] keywords = [ "ELT", "{{cookiecutter.source_name}}", diff --git a/cookiecutter/target-template/cookiecutter.json b/cookiecutter/target-template/cookiecutter.json index 4816b54aa..c7c31835a 100644 --- a/cookiecutter/target-template/cookiecutter.json +++ b/cookiecutter/target-template/cookiecutter.json @@ -1,10 +1,21 @@ { "destination_name": "MyDestinationName", "admin_name": "FirstName LastName", + "admin_email": "firstname.lastname@example.com", "target_id": "target-{{ cookiecutter.destination_name.lower() }}", "library_name": "{{ cookiecutter.target_id.replace('-', '_') }}", "variant": "None (Skip)", "serialization_method": ["Per record", "Per batch", "SQL"], "include_ci_files": ["GitHub", "None (Skip)"], - "license": ["Apache-2.0"] + "license": ["Apache-2.0"], + "__prompts__": { + "name": "The name of the mapper, in CamelCase", + "admin_name": "Provide your [bold yellow]full name[/]", + "admin_email": "Provide your [bold yellow]email[/]", + "mapper_id": "The ID of the tap, in kebab-case", + "library_name": "The name of the library, in snake_case. This is how the library will be imported in Python.", + "serialization_method": "The serialization method to use for loading data", + "include_ci_files": "Whether to include CI files for a common CI services", + "license": "The license for the project" + } } diff --git a/cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml b/cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml index ee8a65192..63ef78785 100644 --- a/cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml +++ b/cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml @@ -7,7 +7,7 @@ name = "{{cookiecutter.target_id}}" version = "0.0.1" description = "`{{cookiecutter.target_id}}` is a Singer target for {{cookiecutter.destination_name}}, built with the Meltano Singer SDK." readme = "README.md" -authors = ["{{ cookiecutter.admin_name }}"] +authors = ["{{ cookiecutter.admin_name }} <{{ cookiecutter.admin_email }}>"] keywords = [ "ELT", "{{cookiecutter.destination_name}}", diff --git a/docs/dev_guide.md b/docs/dev_guide.md index b93eacedd..5a118adf0 100644 --- a/docs/dev_guide.md +++ b/docs/dev_guide.md @@ -76,6 +76,24 @@ generated `README.md` file to complete your new tap or target. You can also refe [Meltano Tutorial](https://docs.meltano.com/tutorials/custom-extractor) for a more detailed guide. +````{admonition} Avoid repeating yourself + If you find yourself repeating the same inputs to the cookiecutter, you can create a + `cookiecutterrc` file in your home directory to set default values for the prompts. + + For example, if you want to set the default value for your name and email, and the + default stream type and authentication method, you can add the following to your + `~/.cookiecutterrc` file: + + ```yaml + # ~/.cookiecutterrc + default_context: + admin_name: Johnny B. Goode + admin_email: jbg@example.com + stream_type: REST + auth_method: Bearer Token + ``` +```` + ### Using an existing library In some cases, there may already be a library that connects to the API and all you need the SDK for diff --git a/e2e-tests/cookiecutters/mapper-base.json b/e2e-tests/cookiecutters/mapper-base.json index 25d40c608..390e8a7ba 100644 --- a/e2e-tests/cookiecutters/mapper-base.json +++ b/e2e-tests/cookiecutters/mapper-base.json @@ -2,6 +2,7 @@ "cookiecutter": { "name": "MyMapperName", "admin_name": "Automatic Tester", + "admin_email": "auto.tester@example.com", "mapper_id": "mapper-base", "library_name": "mapper_base", "variant": "None (Skip)", diff --git a/e2e-tests/cookiecutters/tap-graphql-jwt.json b/e2e-tests/cookiecutters/tap-graphql-jwt.json index 0c322e06f..5daf4ab8f 100644 --- a/e2e-tests/cookiecutters/tap-graphql-jwt.json +++ b/e2e-tests/cookiecutters/tap-graphql-jwt.json @@ -2,6 +2,7 @@ "cookiecutter": { "source_name": "GraphQLJWTTemplateTest", "admin_name": "Automatic Tester", + "admin_email": "auto.tester@example.com", "tap_id": "tap-graphql-jwt", "library_name": "tap_graphql_jwt", "variant": "None (Skip)", diff --git a/e2e-tests/cookiecutters/tap-other-custom.json b/e2e-tests/cookiecutters/tap-other-custom.json index ac3816774..3ea01eaf4 100644 --- a/e2e-tests/cookiecutters/tap-other-custom.json +++ b/e2e-tests/cookiecutters/tap-other-custom.json @@ -2,6 +2,7 @@ "cookiecutter": { "source_name": "AutomaticTestTap", "admin_name": "Automatic Tester", + "admin_email": "auto.tester@example.com", "tap_id": "tap-other-custom", "library_name": "tap_other_custom", "variant": "None (Skip)", diff --git a/e2e-tests/cookiecutters/tap-rest-api_key-github.json b/e2e-tests/cookiecutters/tap-rest-api_key-github.json index e65981940..01570aba8 100644 --- a/e2e-tests/cookiecutters/tap-rest-api_key-github.json +++ b/e2e-tests/cookiecutters/tap-rest-api_key-github.json @@ -2,6 +2,7 @@ "cookiecutter": { "source_name": "AutomaticTestTap", "admin_name": "Automatic Tester", + "admin_email": "auto.tester@example.com", "tap_id": "tap-rest-api_key-github", "library_name": "tap_rest_api_key_github", "variant": "None (Skip)", diff --git a/e2e-tests/cookiecutters/tap-rest-basic_auth.json b/e2e-tests/cookiecutters/tap-rest-basic_auth.json index 33eb7b625..6c7d7fa19 100644 --- a/e2e-tests/cookiecutters/tap-rest-basic_auth.json +++ b/e2e-tests/cookiecutters/tap-rest-basic_auth.json @@ -2,6 +2,7 @@ "cookiecutter": { "source_name": "AutomaticTestTap", "admin_name": "Automatic Tester", + "admin_email": "auto.tester@example.com", "tap_id": "tap-rest-basic_auth", "library_name": "tap_rest_basic_auth", "variant": "None (Skip)", diff --git a/e2e-tests/cookiecutters/tap-rest-bearer_token.json b/e2e-tests/cookiecutters/tap-rest-bearer_token.json index f506061dd..157457462 100644 --- a/e2e-tests/cookiecutters/tap-rest-bearer_token.json +++ b/e2e-tests/cookiecutters/tap-rest-bearer_token.json @@ -2,6 +2,7 @@ "cookiecutter": { "source_name": "AutomaticTestTap", "admin_name": "Automatic Tester", + "admin_email": "auto.tester@example.com", "tap_id": "tap-rest-bearer_token", "library_name": "tap_rest_bearer_token", "variant": "None (Skip)", diff --git a/e2e-tests/cookiecutters/tap-rest-custom.json b/e2e-tests/cookiecutters/tap-rest-custom.json index 5d68d60bf..831135b7a 100644 --- a/e2e-tests/cookiecutters/tap-rest-custom.json +++ b/e2e-tests/cookiecutters/tap-rest-custom.json @@ -2,6 +2,7 @@ "cookiecutter": { "source_name": "AutomaticTestTap", "admin_name": "Automatic Tester", + "admin_email": "auto.tester@example.com", "tap_id": "tap-rest-custom", "library_name": "tap_rest_custom", "variant": "None (Skip)", diff --git a/e2e-tests/cookiecutters/tap-rest-jwt.json b/e2e-tests/cookiecutters/tap-rest-jwt.json index 80837f244..b46807d49 100644 --- a/e2e-tests/cookiecutters/tap-rest-jwt.json +++ b/e2e-tests/cookiecutters/tap-rest-jwt.json @@ -2,6 +2,7 @@ "cookiecutter": { "source_name": "AutomaticTestTap", "admin_name": "Automatic Tester", + "admin_email": "auto.tester@example.com", "tap_id": "tap-rest-jwt", "library_name": "tap_rest_jwt", "variant": "None (Skip)", diff --git a/e2e-tests/cookiecutters/tap-rest-oauth2.json b/e2e-tests/cookiecutters/tap-rest-oauth2.json index 27c7c39df..4a41b80e3 100644 --- a/e2e-tests/cookiecutters/tap-rest-oauth2.json +++ b/e2e-tests/cookiecutters/tap-rest-oauth2.json @@ -2,6 +2,7 @@ "cookiecutter": { "source_name": "AutomaticTestTap", "admin_name": "Automatic Tester", + "admin_email": "auto.tester@example.com", "tap_id": "tap-rest-oauth2", "library_name": "tap_rest_oauth2", "variant": "None (Skip)", diff --git a/e2e-tests/cookiecutters/tap-sql-custom.json b/e2e-tests/cookiecutters/tap-sql-custom.json index 96fa379d7..3c5996860 100644 --- a/e2e-tests/cookiecutters/tap-sql-custom.json +++ b/e2e-tests/cookiecutters/tap-sql-custom.json @@ -2,6 +2,7 @@ "cookiecutter": { "source_name": "AutomaticTestTap", "admin_name": "Automatic Tester", + "admin_email": "auto.tester@example.com", "tap_id": "tap-sql-custom", "library_name": "tap_sql_custom", "variant": "None (Skip)", diff --git a/e2e-tests/cookiecutters/target-per_record.json b/e2e-tests/cookiecutters/target-per_record.json index 9e0047af1..f5dde1cef 100644 --- a/e2e-tests/cookiecutters/target-per_record.json +++ b/e2e-tests/cookiecutters/target-per_record.json @@ -2,6 +2,7 @@ "cookiecutter": { "destination_name": "MyDestinationName", "admin_name": "FirstName LastName", + "admin_email": "firstname.lastname@example.com", "target_id": "target-per_record", "library_name": "target_per_record", "variant": "None (Skip)", diff --git a/e2e-tests/cookiecutters/target-sql.json b/e2e-tests/cookiecutters/target-sql.json index 5802e5ede..63691d718 100644 --- a/e2e-tests/cookiecutters/target-sql.json +++ b/e2e-tests/cookiecutters/target-sql.json @@ -2,6 +2,7 @@ "cookiecutter": { "destination_name": "MyDestinationName", "admin_name": "FirstName LastName", + "admin_email": "firstname.lastname@example.com", "target_id": "target-sql", "library_name": "target_sql", "variant": "None (Skip)",