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

content type names/ids not handled correctly #11

Closed
janro1 opened this issue Jun 9, 2020 · 5 comments · Fixed by #12
Closed

content type names/ids not handled correctly #11

janro1 opened this issue Jun 9, 2020 · 5 comments · Fixed by #12
Labels

Comments

@janro1
Copy link

janro1 commented Jun 9, 2020

Hi,

if a content type has an id starting with a number or if the id contains dashes, like "3-0-Model" the type generation breaks.

@marcolink
Copy link
Collaborator

@janro1 good catch, will look into it.

@marcolink
Copy link
Collaborator

@janro1
Ok, we currently don't generate validate module names for all cases. The id field is used to later generate a module name here:
https://github.com/contentful-labs/cf-content-types-generator/blob/1f90fc8a979e60ca492b646e59844bce3df80de4/src/utils.ts#L3

I can think of a transform like this:

expect(moduleName('helloWorld')).to.equal('HelloWorld');
expect(moduleName('hello-World')).to.equal('HelloWorld');
expect(moduleName('0helloWorld')).to.equal('HelloWorld0');
expect(moduleName('0-helloWorld')).to.equal('HelloWorld0');
expect(moduleName('0123-helloWorld')).to.equal('HelloWorld0123');
expect(moduleName('hello World')).to.equal('HelloWorld');
expect(moduleName('hello-World')).to.equal('HelloWorld');

Would that work for you?

@janro1
Copy link
Author

janro1 commented Jun 15, 2020

Hi @marcolink, LGTM :)

@marcolink
Copy link
Collaborator

@janro1 provided a fix here #12

@github-actions
Copy link

🎉 This issue has been resolved in version 1.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants