Skip to content

How to handle different CLI versions #39

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
emin93 opened this issue Jun 17, 2019 · 11 comments
Closed

How to handle different CLI versions #39

emin93 opened this issue Jun 17, 2019 · 11 comments
Labels
help wanted Extra attention is needed

Comments

@emin93
Copy link
Member

emin93 commented Jun 17, 2019

Introduction

The new RN CLI will have an updated template feature which is incompatible with the current one. As the current CLI won't go anywhere soon, we have to support both versions for a while.

I created a new branch (cli-v2) with the changes for the new CLI.

Question

How should we handle the support for both versions?

Proposals

  • Maintain two separate branches (e.g. master and master-cli-v2) and release the CLI v2 compatible template with the next tag.
  • Integrate a detection in the post install script and handle the differences there. This would allow us to have only one branch but it will make things a bit messy.
@thymikee
Copy link
Member

Both templates can live next to each other and published together:

root/
  ...old-template-files
  template.config.js
  template/

I don't think extra branching is necessary.

You'll need, however, to release a major version with every RN upgrade, because in new init the template is responsible for everything inside (ios/ and android/ will be included and they change with every RN major bump) – the project will be copied mostly "as is" (with small templateName replacements).

@emin93
Copy link
Member Author

emin93 commented Jun 18, 2019

While I agree that we can solve it by having everything in the same branch, I have some "concerns" / "things we should keep in mind" with it:

  • The v1 template files would live in the root folder, while v2 is in the template subfolder. After setup with the v1 CLI, we'd need to remove the v2 files in the post install script as they will get copied over as well. We could solve this also by not bundling the v2 files when npm publishing the v1 template. But that won't work when developing the template locally.
  • The post install script for v1 runs as an npm post install script, therefore it would also be executed in v2. This means we'd have to detect which CLI version is in use and do the according post install work.

(v1 and v2 relate to the CLI versions and not the template)

Let me know if I misunderstood something.

@thymikee
Copy link
Member

In v2 you can use postInitScript in template.config.js

@emin93
Copy link
Member Author

emin93 commented Jun 18, 2019

Yes, but in v1 we use npm postinstall which will also execute in v2, correct?

@thymikee
Copy link
Member

Ah yea, that's true

@emin93
Copy link
Member Author

emin93 commented Jul 8, 2019

As the shorthand syntax will be removed in the upcoming CLI version (react-native-community/cli#483 (comment)), I'd vote for releasing a new package under a new shorter name for the new CLI.

The template works completely different and is independent from the one for the old CLI, so this would make even more sense. So there is no need for using @next tag anymore.

/edit
For now it is solved by using the @next tag for the new CLI. If someone feels like picking up the topic, feel free 😃!

@fecabianchi

This comment has been minimized.

@emin93

This comment has been minimized.

@radko93
Copy link
Collaborator

radko93 commented Sep 10, 2019

@emin93 we should publish a new package so the default version is for new CLI

@emin93
Copy link
Member Author

emin93 commented Sep 10, 2019

@radko93 Yes, let's do that 👍

@emin93
Copy link
Member Author

emin93 commented Sep 11, 2019

As soon as this PR (#60) gets merged, we can close this issue.

@emin93 emin93 closed this as completed Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants