Skip to content

Support versioned/tagged shorthand templates #483

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

Closed
wants to merge 1 commit into from
Closed

Support versioned/tagged shorthand templates #483

wants to merge 1 commit into from

Conversation

Taym95
Copy link
Contributor

@Taym95 Taym95 commented Jul 5, 2019

I tried to fix #475

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Awesome! Can you also please add a test case to templateName.test.js?

);
const nameTagArray = templateName.split('@');
const name = nameTagArray[0];
const tag = nameTagArray[1];
Copy link
Member

Choose a reason for hiding this comment

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

let's assign a default value here, so we can avoid branching:

Suggested change
const tag = nameTagArray[1];
const tag = nameTagArray[1] || 'latest';

const name = nameTagArray[0];
const tag = nameTagArray[1];
const reactNativeTemplatePackage = `react-native-template-${name}`;
var response;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
var response;
const response = await fetch(
`https://registry.yarnpkg.com/${reactNativeTemplatePackage}/${tag}`,
);

@thymikee
Copy link
Member

thymikee commented Jul 7, 2019

Let's hold off with this a bit. I have some issues with the "shorthand" approach in general, and ideally I'd like to either kill it or provide different flag for it. Check the following scenario:

When passing name@next, should we pick name@next or react-native-template-name@next?

  • If we pick name@next, then typescript won't work as a template.
  • If we pick react-native-template-name@next, then anybody can create an abusive package react-native-template-something for package something out there

Both scenarios are bad and we can't really go with that in new init. Even if we queried both packages for presence of template.config.js, the abusive scenarios still holds true.

@thymikee thymikee closed this Jul 7, 2019
@thymikee
Copy link
Member

thymikee commented Jul 7, 2019

Thanks for your help @Taym95, it's greatly appreciated and even though the PR is closed, your work is valuable to me and should help improve this workflow.

@emin93
Copy link
Member

emin93 commented Jul 8, 2019

I really appreciate all of your effort, thanks 🤘

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

Successfully merging this pull request may close these issues.

Support versioned/tagged shorthand templates
3 participants