Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 49 additions & 29 deletions src/choose-blueprint-updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,37 +108,57 @@ All blueprints are up-to-date!`);
};
return choices;
}, {});

let { blueprintUpdate } = await chooseBlueprint({
choicesByName,
message: 'Blueprint updates have been found. Which one would you like to update?'
});

existingBlueprint = blueprintUpdate.blueprint;

if (typeof to !== 'string') {
let latestVersion = `${blueprintUpdate.latestVersion} (latest)`;

let answer = await inquirer.prompt([{
type: 'list',
message: 'Do you want the latest version?',
name: 'choice',
choices: [
latestVersion,
'SemVer string'
]
}]);

if (answer.choice === latestVersion) {
to = defaultTo;
} else {
answer = await inquirer.prompt([{
type: 'input',
message: 'What version?',
name: 'semver'

if (typeof to === "string" && to == "latest") {
let keys = Object.keys(choicesByName);
if (
keys.length > 0 &&
choicesByName[keys[0]]?.blueprintUpdate?.latestVersion &&
choicesByName[keys[0]]?.blueprintUpdate?.blueprint
) {
to = choicesByName[keys[0]].blueprintUpdate.latestVersion;
existingBlueprint = choicesByName[keys[0]].blueprintUpdate.blueprint;
}
} else if (typeof to === "string" && to !== "latest") {
let keys = Object.keys(choicesByName);
if (
keys.length > 0 &&
choicesByName[keys[0]]?.blueprintUpdate?.blueprint
) {
existingBlueprint = choicesByName[keys[0]].blueprintUpdate.blueprint;
}
} else {
let { blueprintUpdate } = await chooseBlueprint({
choicesByName,
message: 'Blueprint updates have been found. Which one would you like to update?'
});

existingBlueprint = blueprintUpdate.blueprint;

if (typeof to !== 'string') {
let latestVersion = `${blueprintUpdate.latestVersion} (latest)`;

let answer = await inquirer.prompt([{
type: 'list',
message: 'Do you want the latest version?',
name: 'choice',
choices: [
latestVersion,
'SemVer string'
]
}]);

to = answer.semver;
if (answer.choice === latestVersion) {
to = defaultTo;
} else {
answer = await inquirer.prompt([{
type: 'input',
message: 'What version?',
name: 'semver'
}]);

to = answer.semver;
}
}
}
}
Expand Down