Skip to content

Make tns doctor command readonly #4382

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

Open
cowboyd opened this issue Feb 22, 2019 · 4 comments
Open

Make tns doctor command readonly #4382

cowboyd opened this issue Feb 22, 2019 · 4 comments

Comments

@cowboyd
Copy link

cowboyd commented Feb 22, 2019

Is your feature request related to a problem? Please describe.
We've been working with the nativescript CLI for the past few days trying to get a build up and running for iOS on CircleCI (circleci.com) using mostly the following resources as a reference.

The problem we keep running into is that when we log into the CI virtual machine to debug MacOS builds, the NativeScript CLI is always trying, seemingly whatever command we run, to throw up interactive prompts and write state and modify the system, when what we really need is a way to diagnose what exactly is going on.

For example, a call to tns doctor

  1. asks about whether we want to opt into data collection
  2. asks if we want to install XCode and other dependencies, and if so wants to dump
  3. prompts if we want to use cloud or local builds.
  4. Takes a very long time on resource constrained virtual machines.

This makes it very difficult to debug dependency problems on CI for MacOS (and CI in general really)

For example, this is a transcript of the tns doctor command on a Circle mac vm.

bash-3.2$ yarn tns doctor
yarn run v1.12.1
$ /Users/distiller/project/node_modules/.bin/tns doctor
Do you want to help us improve NativeScript by automatically sending anonymous usage statistics? We will not use this information to identify or contact you. You can read our official Privacy Policy at
? http://www.telerik.com/company/privacy-policy No
TIP: To avoid setting up the necessary environment variables, you can use the Homebrew package manager to install the Android SDK and its dependencies.

There seem to be issues with your configuration.
You are missing the nativescript-cloud extension and you will not be able to execute cloud builds. Your environment is not configured properly and you will not be able to execute local builds. To continue, choose one of the following options:
Select "Sync to Playground" to enjoy NativeScript without any local setup. All you need is a couple of companion apps installed on your devices.
Select "Configure for Cloud Builds" to install the nativescript-cloud extension and automatically configure your environment for cloud builds.
Select "Configure for Local Builds" to run the setup script and automatically configure your environment for local builds.
Select "Configure for Both Local and Cloud Builds" to automatically configure your environment for both options.
Select "Configure for Both Local and Cloud Builds" to automatically configure your environment for both options.
? To continue, choose one of the following options:
  Sync to Playground
  Configure for Cloud Builds
❯ Configure for Local Builds
  Configure for Both Local and Cloud Builds
  Skip Step and Configure Manually

? To continue, choose one of the following options:  Configure for Local Builds
Running the setup script to try and automatically configure your environment.
These scripts require sudo permissions
NativeScript requires Xcode.
If you do not have Xcode installed, download and install it from App Store and run it once to complete its setup.
Do you have Xcode installed? (y/n)

#(snip XCode license agreement)

By typing 'agree' you are agreeing to the terms of the software license agreements. Type 'print' to print them or anything else to cancel, [agree, print, cancel] agree

You can view the license agreements in Xcode's About Box, or at /Applications/Xcode-10.1.app/Contents/Resources/English.lproj/License.rtf

Allow the script to install Homebrew?
(Y)es/(N)o

It goes on from there, updating homebrew, asking to install the android SDK.... In other words, I can't get a diagnosis of the system without changing the system I'm trying to diagnose. Which means that overall, it is not friendly to working with CI.

Describe the solution you'd like

  1. I'd like first and foremost a command, whether tns doctor or otherwise that, only reads system state and produces a list of potential problems with its configuration.
  2. In general, never produce side-effects, or prompt for input unless the user is executing an inherently imperative command. For example, the opt-in dialog to collect metrics happens with every single command. IMHO it should only happen on tns init or tns create (and even in these cases have an option to disable it)
  3. Split commands into those that read state and those that write state and don't intertwine them.

Describe alternatives you've considered
I don't see that there is an alternative other than muddling through.

Additional context

I think NativeScript is a great project and that it could really benefit from a little more disentanglement of side-effects inside the CLI. Especially when it comes to using nativescript CLI as a general purpose build and deployment tool rather than just an individual developer tool.

Thank you for listening!

@cowboyd cowboyd changed the title Make tns doctor command READONLY Make tns doctor command readonly Feb 22, 2019
@cowboyd
Copy link
Author

cowboyd commented Feb 22, 2019

I should also note that because the things that tns doctor is trying to install fail, I'm never actually getting to see the report of tns doctor which may or may not have been generated before the partially failed install and may or may not include results from it.

@cowboyd
Copy link
Author

cowboyd commented Feb 22, 2019

For what it's worth, it looks like this exacerbated by another bug #4383 and that nativescript-cli is failing to actually report the results of doctor before proceeding to a bunch of system installation steps.

I still think this feature would be helpful: I.e. doctor shouldn't try to run a bunch of configuration, but should only report results. I wouldn't have thought this was the expected behavior otherwise.

@rosen-vladimirov
Copy link
Contributor

Hey @cowboyd ,
Please excuse me for the late reply. As discussed in #4383 , with NativeScript CLI 5.2.1 (which is just around the corner), you'll be able to make CLI run in non-interactive mode by setting CI environment variable.
Regarding tns doctor interactivity on its own, we've had a discussion some time ago and decided to use the interactive prompts to help the new users setup their environment. Some of them will not have any knowledge for Android or iOS build systems, so we would like to guide them in case they have any troubles.

Do you think setting CI environment variable and executing tns doctor will resolve the current issue, i.e. in this case CLI will not prompt you for anything - it will just spit the information what is setup correctly and what is not.

@cowboyd
Copy link
Author

cowboyd commented Mar 5, 2019

I think it does work around the issue that we were having so it's not a problem anymore, but stylistically I think it's still off to entwine the separate concerns of diagnosis and remedy by default. I agree that it's a good idea to try and resolve the issues automatically for new users, but imagine if you ran eslint and it reformatted all your code for you by default.

Instead, you have eslint which tells you all of the problems, and eslint --fix that tells you the problems and also tries to modify your codebase in order to resolve each issue.

I'd prefer the same separation of read/write behavior: tns doctor --fix which modifies your system if you want auto fix the problems encountered. Or at the very least tns doctor --diagnosis which only prints out the problems encountered, but explicitly disables and attempt to resolve them.

@rosen-vladimirov rosen-vladimirov removed their assignment Jun 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants