Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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",
});
}
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);
}
}).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;
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",
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?");
}
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?");
}
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?");
});
}
.then(username =>
input('Github password:').then(password => ({
username,
password
}))
)
}
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')