How to use @lerna/prompt - 9 common examples

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 / core / otplease / otplease.js View on Github external
function getOneTimePassword(message = "This operation requires a one-time password:") {
  // Logic taken from npm internals: https://git.io/fNoMe
  return prompt.input(message, {
    filter: otp => otp.replace(/\s+/g, ""),
    validate: otp =>
      (otp && /^[\d ]+$|^[A-Fa-f0-9]{64,64}$/.test(otp)) ||
      "Must be a valid one-time-password. " +
        "See https://docs.npmjs.com/getting-started/using-two-factor-authentication",
  });
}
github lerna / lerna / commands / version / index.js View on Github external
output("");
    output("Changes:");
    output(changes.join(os.EOL));
    output("");

    if (this.options.yes) {
      this.logger.info("auto-confirmed");
      return true;
    }

    // When composed from `lerna publish`, use this opportunity to confirm publishing
    const message = this.composed
      ? "Are you sure you want to publish these packages?"
      : "Are you sure you want to create these versions?";

    return PromptUtilities.confirm(message);
  }
github lerna / lerna / commands / version / lib / prompt-version.js View on Github external
}).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",
      });
    }

    if (choice === "PRERELEASE") {
      const defaultVersion = semver.inc(currentVersion, "prerelease", prereleaseId);
      const prompt = `(default: "${prereleaseId}", yielding ${defaultVersion})`;

      return PromptUtilities.input(`Enter a prerelease identifier ${prompt}`, {
        filter: v => semver.inc(currentVersion, "prerelease", v || prereleaseId),
      });
    }

    return choice;
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",
github lerna / lerna / commands / import / index.js View on Github external
this.preImportHead = this.getCurrentSHA();

    if (this.execSync("git", ["diff-index", "HEAD"])) {
      throw new ValidationError("ECHANGES", "Local repository has un-committed changes");
    }

    this.logger.info(
      "",
      `About to import ${this.commits.length} commits from ${inputPath} into ${targetDir}`
    );

    if (this.options.yes) {
      return true;
    }

    return PromptUtilities.confirm("Are you sure you want to import these commits onto the current branch?");
  }
github lerna / lerna / commands / publish / index.js View on Github external
const count = this.packagesToPublish.length;
    const message = this.packagesToPublish.map(
      pkg => ` - ${pkg.name} => ${this.updatesVersions.get(pkg.name)}`
    );

    output("");
    output(`Found ${count} ${count === 1 ? "package" : "packages"} to publish:`);
    output(message.join(os.EOL));
    output("");

    if (this.options.yes) {
      this.logger.info("auto-confirmed");
      return true;
    }

    return PromptUtilities.confirm("Are you sure you want to publish these packages?");
  }
github lerna / lerna / commands / clean / index.js View on Github external
return chain.then(() => {
      if (this.options.yes) {
        return true;
      }

      this.logger.info("", "Removing the following directories:");
      this.logger.info(
        "clean",
        this.directoriesToDelete.map(dir => path.relative(this.project.rootPath, dir)).join("\n")
      );

      return PromptUtilities.confirm("Proceed?");
    });
  }
github cssinjs / jss / scripts / create-github-release.js View on Github external
.then(username =>
    input('Github password:').then(password => ({
      username,
      password
    }))
  )
github cssinjs / jss / scripts / create-github-release.js View on Github external
}

      if (hasStarted) {
        hasFinished = line.startsWith('## ')

        return !hasFinished
      }

      hasStarted = line.startsWith(`## ${lerna.version}`)

      return false
    })
    .join('\n')
}

input('Github Username:')
  .then(username =>
    input('Github password:').then(password => ({
      username,
      password
    }))
  )
  .then(auth =>
    axios.request({
      method: 'POST',
      url: `/repos/cssinjs/jss/releases`,
      baseURL: `https://api.github.com`,
      data: {
        tag_name: `v${lerna.version}`,
        name: `v${lerna.version}`,
        body: getChangelog(),
        prerelease: lerna.version.includes('alpha')

@lerna/prompt

An internal Lerna tool

MIT
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis