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

feat: make init command more suitable for automation #634

Merged
merged 11 commits into from
Sep 25, 2020

Conversation

NickTolhurst26
Copy link
Contributor

What?

To make this cli tool more 'automatable' it's necessary to remove the dependency of user input when using the init command.

Rather than having a flag that bypasses user input, it would seem more appropriate to have the cli not ask for values that are already provided via the cli options.

This pull request removes the cli options from the 'defaultAnswers' and uses them to determine which prompts are necessary or not.

It then merges the prompt answers with the cli answers to return the same object as before.

Please let me know if I have done anything incorrect in this contribution process as this is the first time I've contributed to a project - feedback is always welcome.

NickTolhurst26 and others added 7 commits September 11, 2020 14:01
Prompts depend on the absence of cli options. The prompt answers and cli
options are then merged.

Provided cli options do not count as 'defaultAnswers'.
* feat: init no longer prompts when cli option is present

Prompts depend on the absence of cli options. The prompt answers and cli
options are then merged.

Provided cli options do not count as 'defaultAnswers'.

* fix: fix lint errors in lib/stencil-init.js

* test: updates integration and unit tests

* test: use better naming of methods and constants

* fix: reverts change to mock test answers

* fix: fix lint errors in lib/stencil-init.spec.js
Copy link
Contributor

@jairo-bc jairo-bc left a comment

Choose a reason for hiding this comment

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

I think it's better to add a parameter to bypass prompts.
Another thing is, that for some reason eslint is not validating. Do you have any ideas why? @MaxGenash

lib/stencil-init.js Outdated Show resolved Hide resolved
@MaxGenash
Copy link
Contributor

@NickTolhurst26 thanks for the interest in contributing to this project.

From the description of the PR it's said that we are going to make the CLI command more suitable for automation by avoiding user input and using CLI options instead. Are you going to use some testing tools to run CLI commands directly to have real e2e tests? Because at the moment I don’t see any substantial improvements in tests - we are still mocking everything with jest.

@MaxGenash
Copy link
Contributor

Just to note: if we accept this PR, I think we should apply similar changes (don’t ask users to input values that were already provided as CLI options) to all the CLI commands to avoid inconsistency in bahavior

@NickTolhurst26
Copy link
Contributor Author

@MaxGenash - I hadn't thought about how to perform e2e tests of a node CLI. Do you know of any particular tools that could achieve this? I've had a browse around and haven't found any strong candidates. I've found a tool called nixt. Is this sort-of what you meant?

My use-case for this pull request is that I have a CD pipeline deploying to BigCommerce using stencil-cli in Azure DevOps. Most of it is done with stencil-cli, but when it comes to using stencil init it fails on waiting for user input so I'm having to generate the .stencil JSON file in PowerShell instead. It's a step better than checking in the .stencil file, but ultimately It'd be nice to see an stencil-cli task in the AzDo marketplace.

Also, I agree that it makes sense to apply these changes across the board. I'll see what I can do. I'm fairly new when it comes to javascript and the stencil init command seems fairly lightweight compared to the rest.

@NickTolhurst26 NickTolhurst26 marked this pull request as draft September 20, 2020 16:50
@NickTolhurst26
Copy link
Contributor Author

Just to note: if we accept this PR, I think we should apply similar changes (don’t ask users to input values that were already provided as CLI options) to all the CLI commands to avoid inconsistency in bahavior

@MaxGenash - looks like only stencil push and stencil init call inquirer.prompt. Stencil push seems to be handed with the --activate and --delete flags.

@MaxGenash
Copy link
Contributor

MaxGenash commented Sep 21, 2020

My use-case for this pull request is that I have a CD pipeline deploying to BigCommerce using stencil-cli in Azure DevOps. Most of it is done with stencil-cli, but when it comes to using stencil init it fails on waiting for user input so I'm having to generate the .stencil JSON file in PowerShell instead.

Oh, ok, I got it. I thought by "more 'automatable'" you meant improving testing tools :)
Your use case sounds reasonable as for me.
If you didn't mean to add e2e tests then don't care about them

@MaxGenash
Copy link
Contributor

Just to note: if we accept this PR, I think we should apply similar changes (don’t ask users to input values that were already provided as CLI options) to all the CLI commands to avoid inconsistency in bahavior

@MaxGenash - looks like only stencil push and stencil init call inquirer.prompt. Stencil push seems to be handed with the --activate and --delete flags.

Yeah, indeed. Moreover, in other CLI commands we already don’t ask users to input values that were already provided as CLI options (e.g. stencil-push --delete, stencil-push --activate ), so stencil-init seems to be the only place to update

@NickTolhurst26 NickTolhurst26 marked this pull request as ready for review September 21, 2020 13:38
lib/stencil-init.js Outdated Show resolved Hide resolved
lib/stencil-init.js Outdated Show resolved Hide resolved
lib/stencil-init.js Outdated Show resolved Hide resolved
@MaxGenash
Copy link
Contributor

MaxGenash commented Sep 23, 2020

@NickTolhurst26 My apologies for the long response, had some other urgent stuff to complete.

Generally, the PR LGTM. Left just a few minor remarks and after they are fixed I think it's good to go.

Could you also squash your commits into 1, so there is no redundant stuff in the history for such a small change? :)

NickTolhurst26 and others added 2 commits September 24, 2020 20:35
- updates JSDoc's that were out-of-date
- removes logic out of Rum() method
- accept required cliOptions oject at earliest stage
@MaxGenash
Copy link
Contributor

@junedkazi reviewed, looks ok for me. If it's ok for you too - let's merge it

@MaxGenash MaxGenash requested a review from junedkazi September 25, 2020 10:05
@junedkazi junedkazi merged commit 4c4adc9 into bigcommerce:master Sep 25, 2020
@NickTolhurst26
Copy link
Contributor Author

Thanks for your time on this guys! And thanks for your advice throughout, @MaxGenash !

What is the release process for this? I'm keen to start using the new feature.

Do I just follow the instructions from the CONTRIBUTING.md (below)?

After the changes are merged to master, pull the latest to your local environment, run gulp release and follow the prompts.

Or is this something one of you guys do?

@junedkazi
Copy link
Contributor

@NickTolhurst26 we are planning on releasing it early next week. We have a couple more PR we want to see through before we cut a release.

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.

4 participants