How to use the @lerna/prompt.select function in @lerna/prompt

To help you get started, we’ve selected a few @lerna/prompt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lerna / lerna / commands / version / lib / prompt-version.js View on Github external
function promptVersion(currentVersion, name, prereleaseId) {
  const patch = semver.inc(currentVersion, "patch");
  const minor = semver.inc(currentVersion, "minor");
  const major = semver.inc(currentVersion, "major");
  const prepatch = semver.inc(currentVersion, "prepatch", prereleaseId);
  const preminor = semver.inc(currentVersion, "preminor", prereleaseId);
  const premajor = semver.inc(currentVersion, "premajor", prereleaseId);

  const message = `Select a new version ${name ? `for ${name} ` : ""}(currently ${currentVersion})`;

  return PromptUtilities.select(message, {
    choices: [
      { value: patch, name: `Patch (${patch})` },
      { value: minor, name: `Minor (${minor})` },
      { value: major, name: `Major (${major})` },
      { value: prepatch, name: `Prepatch (${prepatch})` },
      { value: preminor, name: `Preminor (${preminor})` },
      { value: premajor, name: `Premajor (${premajor})` },
      { value: "PRERELEASE", name: "Custom Prerelease" },
      { value: "CUSTOM", name: "Custom Version" },
    ],
  }).then(choice => {
    if (choice === "CUSTOM") {
      return PromptUtilities.input("Enter a custom version", {
        filter: semver.valid,
        // semver.valid() always returns null with invalid input
        validate: v => v !== null || "Must be a valid semver version",

@lerna/prompt

An internal Lerna tool

MIT
Latest version published 2 years ago

Package Health Score

70 / 100
Full package analysis