This project is archived. Its data is read-only.

cookiecutter skeleton generation lack's context and validation

Summary

When using cookiecutter to generate the project skeleton, if "source_name" provided includes a hyphen we end up generating invalid python because we end up having class names and imports that contain hyphens.

Steps to reproduce

➜  projects cookiecutter https://gitlab.com/meltano/sdk --directory="cookiecutter/tap-template"
You've downloaded /Users/fhines/.cookiecutters/sdk before. Is it okay to delete and re-download it? [yes]: yes
source_name [MySourceName]: foo-bar
admin_name [FirstName LastName]:
tap_id [tap-foo-bar]:
library_name [tap_foo_bar]:
Select stream_type:
1 - REST
2 - GraphQL
3 - Other
Choose from 1, 2, 3 [1]: 3
Select auth_method:
1 - API Key
2 - Bearer Token
3 - Basic Auth
4 - OAuth2
5 - JWT
6 - Custom or N/A
Choose from 1, 2, 3, 4, 5, 6 [1]: 6

What is the current bug behavior?

We generate invalid python due to the inclusion of the hyphen, eg:

from tap_foo_bar.client import foo-barStream
class UsersStream(foo-barStream):
class GroupsStream(foo-barStream):

What is the expected correct behavior?

That we either warn users and fail to create the project skeleton or proactively work around the provided input to still generate valid/working python.

Relevant logs and/or screenshots

Possible fixes

Probably have two main options:

  1. We kind of hint at the fact that we want you to provide camel case for the source_name, but since we don't describe what the fields are used for it's easy to overlook. So one option is to be more descriptive on these fields (explicitly warning folks), and we may want to validate the input.
  2. We could try and work around this behind the scenes, by sanitizing input and just proactively replace - with _ for use when generating code (or otherwise camel casing source_name without trampling another intentional naming convention).

My personal recommendation would probably be option 1 - being more descriptive and warning users/validating the input. Option 2 feels like a slippery slope and a little bit too magic.

Assignee Loading
Time tracking Loading