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

Not possible to specify a custom version via the interactive UI #535

Closed
klappradla opened this issue May 14, 2020 · 1 comment · Fixed by #546
Closed

Not possible to specify a custom version via the interactive UI #535

klappradla opened this issue May 14, 2020 · 1 comment · Fixed by #546
Assignees
Labels

Comments

@klappradla
Copy link

Description

Hi 👋

First off: thanks a ton for your work on this really awesome tool 🦄 💜.

Problem

I'm currently running into a problem when trying to a problem when trying to specify a custom version (like v1.0.0.beta) via the interactive UI: Selecting Other (specify) does not show the successive prompt to input the version number string. The release process then fails with an error, since the version number is blank.

The explicit error varies for npm and yarn, but the core problem is the same: they are missing the version number to update to. Here two examples of the error messages:

yarn

click here to expand example
✖ Command failed with exit code 1: yarn version --new-version
error Invalid version supplied.
info Current version: 3.0.0
info Visit https://yarnpkg.com/en/docs/cli/version for documentation about this command.
error Command failed with exit code 1.

npm

click here to expand example ``` ✖ Command failed with exit code 1: npm version npm ERR! npm version [ | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=] | from-git] npm ERR! (run in package dir) npm ERR! 'npm -v' or 'npm --version' to print npm version (6.13.7) npm ERR! 'npm view version' to view a package's published version npm ERR! 'npm ls' to inspect current package/dependency versions error Command failed with exit code 1. ```

Cause

The interactive UI skips showing the next input even though the version is not specified yet and instead continues with the next step.

The next step fails due to the version still being blank, which according to this line would normally have been the condition to actually show the prompt for inputting a custom version 🤔.

Scenarios

I run into this scenario regardless of using npm or yarn, zsh or bash and regardless of "how" I execute np:

  1. in a release script command defned in my package.json
  2. directly calling yarn np or node_modules/.bin/np
  3. from a shell script

The behavior is the same for versions v6.2.3, v6.0.0 and v5.1.1 (I did not try other versions as I felt the problem is probably somewhere on my side).

Question

Am I using the tool wrong? I need to produce versions with names like e.g. v3.2.0beta and would ideally want to do this via the interactive UI 🤔.

Steps to reproduce

Here are the steps for a minimal example to reproduce this problem (also available as gist):

Option 1: Steps as a script:

click here for script 👩‍💻
#!/bin/sh

set -o errexit
set -o nounset

# Create directory
mkdir example && cd example

# Initialize Git repository
git init && git commit --allow-empty -m "init commit"

# Create bare bones `yarn` project with `np`
yarn init -y && yarn add -D np

# Commit everything (for simplicity)
git add --all && git commit -m "all"

# Run `np` and select `Other (specify)` for the version
yarn np --any-branch --no-tests --no-cleanup --no-release-draft --no-publish

Option 2: Steps as a individual steps:

Click here for steps 👨‍💻
  1. Create directory:

    mkdir try && cd try
  2. Initialize Git repository:

    git init && git commit --allow-empty -m "init commit"
  3. Create bare bones yarn project:

    yarn init -y
  4. Install np:

    yarn add -D np
  5. Commit everything (for simplicity):

    git add --all && git commit -m "all"
  6. Run np and select Other (specify) for the version:

    yarn np --any-branch --no-tests --no-cleanup --no-release-draft --no-publish

The output of the failing command looks approximately like this:

click here for output
? Select semver increment or specify new version Other (specify)

  ✔ Git
  ✖ Bumping version using Yarn
    → info Visit https://yarnpkg.com/en/docs/cli/version for documentation about this command.
    Pushing tags

✖ Command failed with exit code 1: yarn version --new-version
error Invalid version supplied.
info Current version: 1.0.0
info Visit https://yarnpkg.com/en/docs/cli/version for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected behavior

The behavior I would expect from reading the code in ui.js would be to show a second input to type in the custom version number after selecting Other (specify) in the interactive UI.

Environment

np - 6.2.3
Node.js - 14.2.0
npm - 6.14.4
Git - 2.26.2
OS - macOS 10.15.4

@dopecodez
Copy link
Collaborator

dopecodez commented Jun 30, 2020

Ah, this was a particularly tricky issue.

The issue is reproducible everywhere we run with np but since the inquirer code looked good, it was difficult to understand what was causing the said issue.

Ended up creating demo projects and trying different combinations of inquirer prompts to see what was going on.

Turns out that the issue was caused just above this line because of us using the same name field for multiple prompts. We had version repeating twice, and tag repeating twice in the name field for prompts which unfortunately meant that inquirer skipped over the second of these names.

Fix was simple enough, use different names and finally map everything to the same name which we could then use throughout our whole program.

Should be fixed with #546

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